[Intel-gfx] [PATCH 2/4] drm/i915/selftests: Include arbitration points in preemption smoketest
Include a batch full of a page of arbitration points in order to provide a window for inject_preempt_context() in the preemption smoketests. Signed-off-by: Chris Wilson --- drivers/gpu/drm/i915/selftests/intel_lrc.c | 130 +++-- 1 file changed, 97 insertions(+), 33 deletions(-) diff --git a/drivers/gpu/drm/i915/selftests/intel_lrc.c b/drivers/gpu/drm/i915/selftests/intel_lrc.c index d68a924c530e..44b3e97948f9 100644 --- a/drivers/gpu/drm/i915/selftests/intel_lrc.c +++ b/drivers/gpu/drm/i915/selftests/intel_lrc.c @@ -588,6 +588,7 @@ struct preempt_smoke { struct drm_i915_private *i915; struct i915_gem_context **contexts; struct intel_engine_cs *engine; + struct drm_i915_gem_object *batch; unsigned int ncontext; struct rnd_state prng; unsigned long count; @@ -599,6 +600,49 @@ static struct i915_gem_context *smoke_context(struct preempt_smoke *smoke) &smoke->prng)]; } +static int smoke_submit(struct preempt_smoke *smoke, + struct i915_gem_context *ctx, int prio, + struct drm_i915_gem_object *batch) +{ + struct i915_request *rq; + struct i915_vma *vma = NULL; + int err = 0; + + if (batch) { + vma = i915_vma_instance(batch, &ctx->ppgtt->vm, NULL); + if (IS_ERR(vma)) + return PTR_ERR(vma); + + err = i915_vma_pin(vma, 0, 0, PIN_USER); + if (err) + return err; + } + + ctx->sched.priority = prio; + + rq = i915_request_alloc(smoke->engine, ctx); + if (IS_ERR(rq)) { + err = PTR_ERR(rq); + goto unpin; + } + + if (vma) { + err = rq->engine->emit_bb_start(rq, + vma->node.start, + PAGE_SIZE, 0); + if (!err) + err = i915_vma_move_to_active(vma, rq, 0); + } + + i915_request_add(rq); + +unpin: + if (vma) + i915_vma_unpin(vma); + + return err; +} + static int smoke_crescendo_thread(void *arg) { struct preempt_smoke *smoke = arg; @@ -608,21 +652,15 @@ static int smoke_crescendo_thread(void *arg) count = 0; do { struct i915_gem_context *ctx = smoke_context(smoke); - struct i915_request *rq; + int err; mutex_lock(&smoke->i915->drm.struct_mutex); - - ctx->sched.priority = count % I915_PRIORITY_MAX; - - rq = i915_request_alloc(smoke->engine, ctx); - if (IS_ERR(rq)) { - mutex_unlock(&smoke->i915->drm.struct_mutex); - return PTR_ERR(rq); - } - - i915_request_add(rq); - + err = smoke_submit(smoke, + ctx, count % I915_PRIORITY_MAX, + smoke->batch); mutex_unlock(&smoke->i915->drm.struct_mutex); + if (err) + return err; count++; } while (!__igt_timeout(end_time, NULL)); @@ -631,7 +669,8 @@ static int smoke_crescendo_thread(void *arg) return 0; } -static int smoke_crescendo(struct preempt_smoke *smoke) +static int smoke_crescendo(struct preempt_smoke *smoke, unsigned int flags) +#define BATCH BIT(0) { struct task_struct *tsk[I915_NUM_ENGINES] = {}; struct preempt_smoke arg[I915_NUM_ENGINES]; @@ -645,6 +684,8 @@ static int smoke_crescendo(struct preempt_smoke *smoke) for_each_engine(engine, smoke->i915, id) { arg[id] = *smoke; arg[id].engine = engine; + if (!(flags & BATCH)) + arg[id].batch = NULL; arg[id].count = 0; tsk[id] = kthread_run(smoke_crescendo_thread, &arg, @@ -671,37 +712,37 @@ static int smoke_crescendo(struct preempt_smoke *smoke) mutex_lock(&smoke->i915->drm.struct_mutex); - pr_info("Submitted %lu crescendo requests across %d engines and %d contexts\n", - count, INTEL_INFO(smoke->i915)->num_rings, smoke->ncontext); + pr_info("Submitted %lu crescendo:%x requests across %d engines and %d contexts\n", + count, flags, + INTEL_INFO(smoke->i915)->num_rings, smoke->ncontext); return 0; } -static int smoke_random(struct preempt_smoke *smoke) +static int smoke_random(struct preempt_smoke *smoke, unsigned int flags) { - struct intel_engine_cs *engine; enum intel_engine_id id; IGT_TIMEOUT(end_time); unsigned long count; count = 0; do { - for_each_engine(engine, smoke->i915, id) { + for_each_engine(smoke->engine, smoke->i915, id) {
[Intel-gfx] [PATCH 2/4] drm/i915/selftests: Include arbitration points in preemption smoketest
Include a batch full of a page of arbitration points in order to provide a window for inject_preempt_context() in the preemption smoketests. Signed-off-by: Chris Wilson --- drivers/gpu/drm/i915/selftests/intel_lrc.c | 134 - 1 file changed, 101 insertions(+), 33 deletions(-) diff --git a/drivers/gpu/drm/i915/selftests/intel_lrc.c b/drivers/gpu/drm/i915/selftests/intel_lrc.c index d68a924c530e..d67fe8335ceb 100644 --- a/drivers/gpu/drm/i915/selftests/intel_lrc.c +++ b/drivers/gpu/drm/i915/selftests/intel_lrc.c @@ -588,6 +588,7 @@ struct preempt_smoke { struct drm_i915_private *i915; struct i915_gem_context **contexts; struct intel_engine_cs *engine; + struct drm_i915_gem_object *batch; unsigned int ncontext; struct rnd_state prng; unsigned long count; @@ -599,6 +600,49 @@ static struct i915_gem_context *smoke_context(struct preempt_smoke *smoke) &smoke->prng)]; } +static int smoke_submit(struct preempt_smoke *smoke, + struct i915_gem_context *ctx, int prio, + struct drm_i915_gem_object *batch) +{ + struct i915_request *rq; + struct i915_vma *vma = NULL; + int err = 0; + + if (batch) { + vma = i915_vma_instance(batch, &ctx->ppgtt->vm, NULL); + if (IS_ERR(vma)) + return PTR_ERR(vma); + + err = i915_vma_pin(vma, 0, 0, PIN_USER); + if (err) + return err; + } + + ctx->sched.priority = prio; + + rq = i915_request_alloc(smoke->engine, ctx); + if (IS_ERR(rq)) { + err = PTR_ERR(rq); + goto unpin; + } + + if (vma) { + err = rq->engine->emit_bb_start(rq, + vma->node.start, + PAGE_SIZE, 0); + if (!err) + err = i915_vma_move_to_active(vma, rq, 0); + } + + i915_request_add(rq); + +unpin: + if (vma) + i915_vma_unpin(vma); + + return err; +} + static int smoke_crescendo_thread(void *arg) { struct preempt_smoke *smoke = arg; @@ -608,21 +652,15 @@ static int smoke_crescendo_thread(void *arg) count = 0; do { struct i915_gem_context *ctx = smoke_context(smoke); - struct i915_request *rq; + int err; mutex_lock(&smoke->i915->drm.struct_mutex); - - ctx->sched.priority = count % I915_PRIORITY_MAX; - - rq = i915_request_alloc(smoke->engine, ctx); - if (IS_ERR(rq)) { - mutex_unlock(&smoke->i915->drm.struct_mutex); - return PTR_ERR(rq); - } - - i915_request_add(rq); - + err = smoke_submit(smoke, + ctx, count % I915_PRIORITY_MAX, + smoke->batch); mutex_unlock(&smoke->i915->drm.struct_mutex); + if (err) + return err; count++; } while (!__igt_timeout(end_time, NULL)); @@ -631,7 +669,8 @@ static int smoke_crescendo_thread(void *arg) return 0; } -static int smoke_crescendo(struct preempt_smoke *smoke) +static int smoke_crescendo(struct preempt_smoke *smoke, unsigned int flags) +#define BATCH BIT(0) { struct task_struct *tsk[I915_NUM_ENGINES] = {}; struct preempt_smoke arg[I915_NUM_ENGINES]; @@ -645,6 +684,8 @@ static int smoke_crescendo(struct preempt_smoke *smoke) for_each_engine(engine, smoke->i915, id) { arg[id] = *smoke; arg[id].engine = engine; + if (!(flags & BATCH)) + arg[id].batch = NULL; arg[id].count = 0; tsk[id] = kthread_run(smoke_crescendo_thread, &arg, @@ -671,37 +712,37 @@ static int smoke_crescendo(struct preempt_smoke *smoke) mutex_lock(&smoke->i915->drm.struct_mutex); - pr_info("Submitted %lu crescendo requests across %d engines and %d contexts\n", - count, INTEL_INFO(smoke->i915)->num_rings, smoke->ncontext); + pr_info("Submitted %lu crescendo:%x requests across %d engines and %d contexts\n", + count, flags, + INTEL_INFO(smoke->i915)->num_rings, smoke->ncontext); return 0; } -static int smoke_random(struct preempt_smoke *smoke) +static int smoke_random(struct preempt_smoke *smoke, unsigned int flags) { - struct intel_engine_cs *engine; enum intel_engine_id id; IGT_TIMEOUT(end_time); unsigned long count; count = 0; do { - for_each_engine(engine, smoke->i915, id) { + for_each_engine(smoke->engine, smoke->i915, id) {
Re: [Intel-gfx] [PATCH 2/4] drm/i915/selftests: Include arbitration points in preemption smoketest
On 01/10/2018 13:32, Chris Wilson wrote: Include a batch full of a page of arbitration points in order to provide a window for inject_preempt_context() in the preemption smoketests. Signed-off-by: Chris Wilson --- drivers/gpu/drm/i915/selftests/intel_lrc.c | 134 - 1 file changed, 101 insertions(+), 33 deletions(-) diff --git a/drivers/gpu/drm/i915/selftests/intel_lrc.c b/drivers/gpu/drm/i915/selftests/intel_lrc.c index d68a924c530e..d67fe8335ceb 100644 --- a/drivers/gpu/drm/i915/selftests/intel_lrc.c +++ b/drivers/gpu/drm/i915/selftests/intel_lrc.c @@ -588,6 +588,7 @@ struct preempt_smoke { struct drm_i915_private *i915; struct i915_gem_context **contexts; struct intel_engine_cs *engine; + struct drm_i915_gem_object *batch; unsigned int ncontext; struct rnd_state prng; unsigned long count; @@ -599,6 +600,49 @@ static struct i915_gem_context *smoke_context(struct preempt_smoke *smoke) &smoke->prng)]; } +static int smoke_submit(struct preempt_smoke *smoke, + struct i915_gem_context *ctx, int prio, + struct drm_i915_gem_object *batch) +{ + struct i915_request *rq; + struct i915_vma *vma = NULL; + int err = 0; + + if (batch) { + vma = i915_vma_instance(batch, &ctx->ppgtt->vm, NULL); + if (IS_ERR(vma)) + return PTR_ERR(vma); + + err = i915_vma_pin(vma, 0, 0, PIN_USER); + if (err) + return err; + } + + ctx->sched.priority = prio; + + rq = i915_request_alloc(smoke->engine, ctx); + if (IS_ERR(rq)) { + err = PTR_ERR(rq); + goto unpin; + } + + if (vma) { + err = rq->engine->emit_bb_start(rq, + vma->node.start, + PAGE_SIZE, 0); + if (!err) + err = i915_vma_move_to_active(vma, rq, 0); + } + + i915_request_add(rq); + +unpin: + if (vma) + i915_vma_unpin(vma); + + return err; +} + static int smoke_crescendo_thread(void *arg) { struct preempt_smoke *smoke = arg; @@ -608,21 +652,15 @@ static int smoke_crescendo_thread(void *arg) count = 0; do { struct i915_gem_context *ctx = smoke_context(smoke); - struct i915_request *rq; + int err; mutex_lock(&smoke->i915->drm.struct_mutex); - - ctx->sched.priority = count % I915_PRIORITY_MAX; - - rq = i915_request_alloc(smoke->engine, ctx); - if (IS_ERR(rq)) { - mutex_unlock(&smoke->i915->drm.struct_mutex); - return PTR_ERR(rq); - } - - i915_request_add(rq); - + err = smoke_submit(smoke, + ctx, count % I915_PRIORITY_MAX, + smoke->batch); mutex_unlock(&smoke->i915->drm.struct_mutex); + if (err) + return err; count++; } while (!__igt_timeout(end_time, NULL)); @@ -631,7 +669,8 @@ static int smoke_crescendo_thread(void *arg) return 0; } -static int smoke_crescendo(struct preempt_smoke *smoke) +static int smoke_crescendo(struct preempt_smoke *smoke, unsigned int flags) +#define BATCH BIT(0) { struct task_struct *tsk[I915_NUM_ENGINES] = {}; struct preempt_smoke arg[I915_NUM_ENGINES]; @@ -645,6 +684,8 @@ static int smoke_crescendo(struct preempt_smoke *smoke) for_each_engine(engine, smoke->i915, id) { arg[id] = *smoke; arg[id].engine = engine; + if (!(flags & BATCH)) + arg[id].batch = NULL; arg[id].count = 0; tsk[id] = kthread_run(smoke_crescendo_thread, &arg, @@ -671,37 +712,37 @@ static int smoke_crescendo(struct preempt_smoke *smoke) mutex_lock(&smoke->i915->drm.struct_mutex); - pr_info("Submitted %lu crescendo requests across %d engines and %d contexts\n", - count, INTEL_INFO(smoke->i915)->num_rings, smoke->ncontext); + pr_info("Submitted %lu crescendo:%x requests across %d engines and %d contexts\n", + count, flags, + INTEL_INFO(smoke->i915)->num_rings, smoke->ncontext); return 0; } -static int smoke_random(struct preempt_smoke *smoke) +static int smoke_random(struct preempt_smoke *smoke, unsigned int flags) { - struct intel_engine_cs *engine; enum intel_engine_id id; IGT_TIMEOUT(end_time); unsigned long count; count = 0; do { - for_each_engine(engine, smoke->i915, id) { + for_each_engine(smoke->engine, smoke->i915, id) {