From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Cc: stable@vger.kernel.org
Subject: Re: [Intel-gfx] [PATCH 4/4] drm/i915/gem: Always test execution status on closing the context
Date: Thu, 24 Sep 2020 15:26:56 +0100 [thread overview]
Message-ID: <e665fc1d-1b9d-a6ee-1798-df32d1296118@linux.intel.com> (raw)
In-Reply-To: <20200916094219.3878-4-chris@chris-wilson.co.uk>
On 16/09/2020 10:42, Chris Wilson wrote:
> Verify that if a context is active at the time it is closed, that it is
> either persistent and preemptible (with hangcheck running) or it shall
> be removed from execution.
>
> Fixes: 9a40bddd47ca ("drm/i915/gt: Expose heartbeat interval via sysfs")
> Testcase: igt/gem_ctx_persistence/heartbeat-close
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: <stable@vger.kernel.org> # v5.7+
> ---
> drivers/gpu/drm/i915/gem/i915_gem_context.c | 48 +++++----------------
> 1 file changed, 10 insertions(+), 38 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> index a548626fa8bc..4fd38101bb56 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> @@ -390,24 +390,6 @@ __context_engines_static(const struct i915_gem_context *ctx)
> return rcu_dereference_protected(ctx->engines, true);
> }
>
> -static bool __reset_engine(struct intel_engine_cs *engine)
> -{
> - struct intel_gt *gt = engine->gt;
> - bool success = false;
> -
> - if (!intel_has_reset_engine(gt))
> - return false;
> -
> - if (!test_and_set_bit(I915_RESET_ENGINE + engine->id,
> - >->reset.flags)) {
> - success = intel_engine_reset(engine, NULL) == 0;
> - clear_and_wake_up_bit(I915_RESET_ENGINE + engine->id,
> - >->reset.flags);
> - }
> -
> - return success;
> -}
> -
> static void __reset_context(struct i915_gem_context *ctx,
> struct intel_engine_cs *engine)
> {
> @@ -431,12 +413,7 @@ static bool __cancel_engine(struct intel_engine_cs *engine)
> * kill the banned context, we fallback to doing a local reset
> * instead.
> */
> - if (IS_ACTIVE(CONFIG_DRM_I915_PREEMPT_TIMEOUT) &&
> - !intel_engine_pulse(engine))
> - return true;
> -
> - /* If we are unable to send a pulse, try resetting this engine. */
> - return __reset_engine(engine);
> + return intel_engine_pulse(engine) == 0;
Where is the path now which actually resets the currently running
workload (engine) of a non-persistent context? Pulse will be sent and
then rely on hangcheck but otherwise let it run?
Regards,
Tvrtko
> }
>
> static bool
> @@ -506,7 +483,7 @@ static struct intel_engine_cs *active_engine(struct intel_context *ce)
> return engine;
> }
>
> -static void kill_engines(struct i915_gem_engines *engines)
> +static void kill_engines(struct i915_gem_engines *engines, bool ban)
> {
> struct i915_gem_engines_iter it;
> struct intel_context *ce;
> @@ -521,7 +498,7 @@ static void kill_engines(struct i915_gem_engines *engines)
> for_each_gem_engine(ce, engines, it) {
> struct intel_engine_cs *engine;
>
> - if (intel_context_set_banned(ce))
> + if (ban && intel_context_set_banned(ce))
> continue;
>
> /*
> @@ -534,7 +511,7 @@ static void kill_engines(struct i915_gem_engines *engines)
> engine = active_engine(ce);
>
> /* First attempt to gracefully cancel the context */
> - if (engine && !__cancel_engine(engine))
> + if (engine && !__cancel_engine(engine) && ban)
> /*
> * If we are unable to send a preemptive pulse to bump
> * the context from the GPU, we have to resort to a full
> @@ -544,8 +521,10 @@ static void kill_engines(struct i915_gem_engines *engines)
> }
> }
>
> -static void kill_stale_engines(struct i915_gem_context *ctx)
> +static void kill_context(struct i915_gem_context *ctx)
> {
> + bool ban = (!i915_gem_context_is_persistent(ctx) ||
> + !ctx->i915->params.enable_hangcheck);
> struct i915_gem_engines *pos, *next;
>
> spin_lock_irq(&ctx->stale.lock);
> @@ -558,7 +537,7 @@ static void kill_stale_engines(struct i915_gem_context *ctx)
>
> spin_unlock_irq(&ctx->stale.lock);
>
> - kill_engines(pos);
> + kill_engines(pos, ban);
>
> spin_lock_irq(&ctx->stale.lock);
> GEM_BUG_ON(i915_sw_fence_signaled(&pos->fence));
> @@ -570,11 +549,6 @@ static void kill_stale_engines(struct i915_gem_context *ctx)
> spin_unlock_irq(&ctx->stale.lock);
> }
>
> -static void kill_context(struct i915_gem_context *ctx)
> -{
> - kill_stale_engines(ctx);
> -}
> -
> static void engines_idle_release(struct i915_gem_context *ctx,
> struct i915_gem_engines *engines)
> {
> @@ -609,7 +583,7 @@ static void engines_idle_release(struct i915_gem_context *ctx,
>
> kill:
> if (list_empty(&engines->link)) /* raced, already closed */
> - kill_engines(engines);
> + kill_engines(engines, true);
>
> i915_sw_fence_commit(&engines->fence);
> }
> @@ -667,9 +641,7 @@ static void context_close(struct i915_gem_context *ctx)
> * case we opt to forcibly kill off all remaining requests on
> * context close.
> */
> - if (!i915_gem_context_is_persistent(ctx) ||
> - !ctx->i915->params.enable_hangcheck)
> - kill_context(ctx);
> + kill_context(ctx);
>
> i915_gem_context_put(ctx);
> }
>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2020-09-24 14:27 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-16 9:42 [Intel-gfx] [PATCH 1/4] drm/i915/gem: Hold request reference for canceling an active context Chris Wilson
2020-09-16 9:42 ` [Intel-gfx] [PATCH 2/4] drm/i915: Cancel outstanding work after disabling heartbeats on an engine Chris Wilson
2020-09-24 13:35 ` Tvrtko Ursulin
2020-09-25 11:04 ` Joonas Lahtinen
2020-09-16 9:42 ` [Intel-gfx] [PATCH 3/4] drm/i915/gt: Always send a pulse down the engine after disabling heartbeat Chris Wilson
2020-09-24 13:43 ` Tvrtko Ursulin
2020-09-25 10:01 ` Chris Wilson
2020-09-25 13:19 ` Tvrtko Ursulin
2020-09-25 14:13 ` Chris Wilson
2020-09-16 9:42 ` [Intel-gfx] [PATCH 4/4] drm/i915/gem: Always test execution status on closing the context Chris Wilson
2020-09-24 14:26 ` Tvrtko Ursulin [this message]
2020-09-25 10:05 ` Chris Wilson
2020-09-25 13:23 ` Tvrtko Ursulin
2020-09-16 13:03 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/4] drm/i915/gem: Hold request reference for canceling an active context Patchwork
2020-09-16 13:04 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2020-09-16 13:28 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2020-09-16 17:19 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
2020-09-24 13:34 ` [Intel-gfx] [PATCH 1/4] " Tvrtko Ursulin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e665fc1d-1b9d-a6ee-1798-df32d1296118@linux.intel.com \
--to=tvrtko.ursulin@linux.intel.com \
--cc=chris@chris-wilson.co.uk \
--cc=intel-gfx@lists.freedesktop.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox