drm/i915/selftests: Be engine agnostic

When using MI operations, we do not care which engine we use, so use
them all where possible, and where inconvenient double check we have the
engine we selected at random.

v2: Drop the local copy of engine->sseu to avoid an unchecked deref

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190704212343.6820-1-chris@chris-wilson.co.uk
This commit is contained in:
Chris Wilson 2019-07-04 22:23:43 +01:00
parent ec22f256a6
commit 8f856c743c
4 changed files with 60 additions and 27 deletions

View File

@ -1422,6 +1422,9 @@ static int igt_ppgtt_pin_update(void *arg)
struct drm_i915_gem_object *obj; struct drm_i915_gem_object *obj;
struct i915_vma *vma; struct i915_vma *vma;
unsigned int flags = PIN_USER | PIN_OFFSET_FIXED; unsigned int flags = PIN_USER | PIN_OFFSET_FIXED;
struct intel_engine_cs *engine;
enum intel_engine_id id;
unsigned int n;
int first, last; int first, last;
int err; int err;
@ -1519,11 +1522,20 @@ static int igt_ppgtt_pin_update(void *arg)
* land in the now stale 2M page. * land in the now stale 2M page.
*/ */
err = gpu_write(vma, ctx, dev_priv->engine[RCS0], 0, 0xdeadbeaf); n = 0;
if (err) for_each_engine(engine, dev_priv, id) {
goto out_unpin; if (!intel_engine_can_store_dword(engine))
continue;
err = cpu_check(obj, 0, 0xdeadbeaf); err = gpu_write(vma, ctx, engine, n++, 0xdeadbeaf);
if (err)
goto out_unpin;
}
while (n--) {
err = cpu_check(obj, n, 0xdeadbeaf);
if (err)
goto out_unpin;
}
out_unpin: out_unpin:
i915_vma_unpin(vma); i915_vma_unpin(vma);
@ -1599,8 +1611,11 @@ static int igt_shrink_thp(void *arg)
struct drm_i915_private *i915 = ctx->i915; struct drm_i915_private *i915 = ctx->i915;
struct i915_address_space *vm = ctx->vm ?: &i915->ggtt.vm; struct i915_address_space *vm = ctx->vm ?: &i915->ggtt.vm;
struct drm_i915_gem_object *obj; struct drm_i915_gem_object *obj;
struct intel_engine_cs *engine;
enum intel_engine_id id;
struct i915_vma *vma; struct i915_vma *vma;
unsigned int flags = PIN_USER; unsigned int flags = PIN_USER;
unsigned int n;
int err; int err;
/* /*
@ -1636,9 +1651,15 @@ static int igt_shrink_thp(void *arg)
if (err) if (err)
goto out_unpin; goto out_unpin;
err = gpu_write(vma, ctx, i915->engine[RCS0], 0, 0xdeadbeaf); n = 0;
if (err) for_each_engine(engine, i915, id) {
goto out_unpin; if (!intel_engine_can_store_dword(engine))
continue;
err = gpu_write(vma, ctx, engine, n++, 0xdeadbeaf);
if (err)
goto out_unpin;
}
i915_vma_unpin(vma); i915_vma_unpin(vma);
@ -1663,7 +1684,12 @@ static int igt_shrink_thp(void *arg)
if (err) if (err)
goto out_close; goto out_close;
err = cpu_check(obj, 0, 0xdeadbeaf); while (n--) {
err = cpu_check(obj, n, 0xdeadbeaf);
if (err)
goto out_unpin;
}
out_unpin: out_unpin:
i915_vma_unpin(vma); i915_vma_unpin(vma);

View File

@ -250,6 +250,9 @@ static bool needs_mi_store_dword(struct drm_i915_private *i915)
if (i915_terminally_wedged(i915)) if (i915_terminally_wedged(i915))
return false; return false;
if (!HAS_ENGINE(i915, RCS0))
return false;
return intel_engine_can_store_dword(i915->engine[RCS0]); return intel_engine_can_store_dword(i915->engine[RCS0]);
} }

View File

@ -1025,7 +1025,6 @@ __igt_ctx_sseu(struct drm_i915_private *i915,
unsigned int flags) unsigned int flags)
{ {
struct intel_engine_cs *engine = i915->engine[RCS0]; struct intel_engine_cs *engine = i915->engine[RCS0];
struct intel_sseu default_sseu = engine->sseu;
struct drm_i915_gem_object *obj; struct drm_i915_gem_object *obj;
struct i915_gem_context *ctx; struct i915_gem_context *ctx;
struct intel_context *ce; struct intel_context *ce;
@ -1033,26 +1032,26 @@ __igt_ctx_sseu(struct drm_i915_private *i915,
struct drm_file *file; struct drm_file *file;
int ret; int ret;
if (INTEL_GEN(i915) < 9) if (INTEL_GEN(i915) < 9 || !engine)
return 0; return 0;
if (!RUNTIME_INFO(i915)->sseu.has_slice_pg) if (!RUNTIME_INFO(i915)->sseu.has_slice_pg)
return 0; return 0;
if (hweight32(default_sseu.slice_mask) < 2) if (hweight32(engine->sseu.slice_mask) < 2)
return 0; return 0;
/* /*
* Gen11 VME friendly power-gated configuration with half enabled * Gen11 VME friendly power-gated configuration with half enabled
* sub-slices. * sub-slices.
*/ */
pg_sseu = default_sseu; pg_sseu = engine->sseu;
pg_sseu.slice_mask = 1; pg_sseu.slice_mask = 1;
pg_sseu.subslice_mask = pg_sseu.subslice_mask =
~(~0 << (hweight32(default_sseu.subslice_mask) / 2)); ~(~0 << (hweight32(engine->sseu.subslice_mask) / 2));
pr_info("SSEU subtest '%s', flags=%x, def_slices=%u, pg_slices=%u\n", pr_info("SSEU subtest '%s', flags=%x, def_slices=%u, pg_slices=%u\n",
name, flags, hweight32(default_sseu.slice_mask), name, flags, hweight32(engine->sseu.slice_mask),
hweight32(pg_sseu.slice_mask)); hweight32(pg_sseu.slice_mask));
file = mock_file(i915); file = mock_file(i915);
@ -1088,7 +1087,7 @@ __igt_ctx_sseu(struct drm_i915_private *i915,
goto out_context; goto out_context;
/* First set the default mask. */ /* First set the default mask. */
ret = __sseu_test(i915, name, flags, ce, obj, default_sseu); ret = __sseu_test(i915, name, flags, ce, obj, engine->sseu);
if (ret) if (ret)
goto out_fail; goto out_fail;
@ -1098,7 +1097,7 @@ __igt_ctx_sseu(struct drm_i915_private *i915,
goto out_fail; goto out_fail;
/* Back to defaults. */ /* Back to defaults. */
ret = __sseu_test(i915, name, flags, ce, obj, default_sseu); ret = __sseu_test(i915, name, flags, ce, obj, engine->sseu);
if (ret) if (ret)
goto out_fail; goto out_fail;

View File

@ -328,7 +328,8 @@ next_tiling: ;
static int make_obj_busy(struct drm_i915_gem_object *obj) static int make_obj_busy(struct drm_i915_gem_object *obj)
{ {
struct drm_i915_private *i915 = to_i915(obj->base.dev); struct drm_i915_private *i915 = to_i915(obj->base.dev);
struct i915_request *rq; struct intel_engine_cs *engine;
enum intel_engine_id id;
struct i915_vma *vma; struct i915_vma *vma;
int err; int err;
@ -340,18 +341,22 @@ static int make_obj_busy(struct drm_i915_gem_object *obj)
if (err) if (err)
return err; return err;
rq = i915_request_create(i915->engine[RCS0]->kernel_context); for_each_engine(engine, i915, id) {
if (IS_ERR(rq)) { struct i915_request *rq;
i915_vma_unpin(vma);
return PTR_ERR(rq); rq = i915_request_create(engine->kernel_context);
if (IS_ERR(rq)) {
i915_vma_unpin(vma);
return PTR_ERR(rq);
}
i915_vma_lock(vma);
err = i915_vma_move_to_active(vma, rq, EXEC_OBJECT_WRITE);
i915_vma_unlock(vma);
i915_request_add(rq);
} }
i915_vma_lock(vma);
err = i915_vma_move_to_active(vma, rq, EXEC_OBJECT_WRITE);
i915_vma_unlock(vma);
i915_request_add(rq);
i915_vma_unpin(vma); i915_vma_unpin(vma);
i915_gem_object_put(obj); /* leave it only alive via its active ref */ i915_gem_object_put(obj); /* leave it only alive via its active ref */