All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andi Shyti <andi.shyti@linux.intel.com>
To: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org, drm-devel@lists.freedesktop.org,
	Daniel Vetter <daniel@ffwll.ch>,
	Chris Wilson <chris@chris-wilson.co.uk>
Subject: Re: [Intel-gfx] [PATCH 1/2] drm/i915/gem: Flush contexts on driver release
Date: Wed, 14 Sep 2022 15:56:03 +0200	[thread overview]
Message-ID: <YyHdc21ao+K2tnnm@alfio.lan> (raw)
In-Reply-To: <20220913161039.155964-2-janusz.krzysztofik@linux.intel.com>

Hi Krzysztofik,

On Tue, Sep 13, 2022 at 06:10:38PM +0200, Janusz Krzysztofik wrote:
> Due to i915_perf assuming that it can use the i915_gem_context reference
> to protect its i915->gem.contexts.list iteration, we need to defer removal
> of the context from the list until last reference to the context is put.
> However, there is a risk of triggering kernel warning on contexts list not
> empty at driver release time if we deleagate that task to a worker for
> i915_gem_context_release_work(), unless that work is flushed first.
> Unfortunately, it is not flushed on driver release.  Fix it.
> 
> Instead of additionally calling flush_workqueue(), either directly of via
> a new dedicated wrapper around it, replace last call to
> i915_gem_drain_freed_objects() with existing i915_gem_drain_workqueue()
> that performs both tasks.
> 
> Fixes: 75eefd82581f ("drm/i915: Release i915_gem_context from a worker")
> Suggested-by: Chris Wilson <chris@chris-wilson.co.uk>
> Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
> Cc: stable@kernel.org # v5.16+

Thanks for the fix and for taking this on you!

Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com>

Andi

> ---
>  drivers/gpu/drm/i915/i915_gem.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index a3373699835d7..31c197f2d8cb9 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -1191,7 +1191,8 @@ void i915_gem_driver_release(struct drm_i915_private *dev_priv)
>  
>  	intel_uc_cleanup_firmwares(&to_gt(dev_priv)->uc);
>  
> -	i915_gem_drain_freed_objects(dev_priv);
> +	/* Flush any outstanding work, including i915_gem_context.release_work. */
> +	i915_gem_drain_workqueue(dev_priv);
>  
>  	drm_WARN_ON(&dev_priv->drm, !list_empty(&dev_priv->gem.contexts.list));
>  }
> -- 
> 2.25.1

  reply	other threads:[~2022-09-14 13:56 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-13 16:10 [Intel-gfx] [PATCH 0/2] drm/i915/gem: Really move i915_gem_context.link under ref protection Janusz Krzysztofik
2022-09-13 16:10 ` [Intel-gfx] [PATCH 1/2] drm/i915/gem: Flush contexts on driver release Janusz Krzysztofik
2022-09-14 13:56   ` Andi Shyti [this message]
2022-09-13 16:10 ` [Intel-gfx] [PATCH 2/2] drm/i915/gem: Really move i915_gem_context.link under ref protection Janusz Krzysztofik
2022-09-14 15:15   ` Andi Shyti
2022-09-14 16:09     ` Janusz Krzysztofik
2022-09-14 15:37   ` Tvrtko Ursulin
2022-09-14 16:24     ` Janusz Krzysztofik
2022-09-14 17:50     ` Andi Shyti
2022-09-13 21:39 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915/gem: Really move i915_gem_context.link under ref protection (rev2) Patchwork
2022-09-13 21:39 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2022-09-13 22:08 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2022-09-14 12:20 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
2022-09-14 13:59   ` Andi Shyti
2022-09-14 15:45 ` Patchwork
2022-09-14 16:35 ` [Intel-gfx] ✓ Fi.CI.IGT: success " Patchwork

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=YyHdc21ao+K2tnnm@alfio.lan \
    --to=andi.shyti@linux.intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=daniel@ffwll.ch \
    --cc=drm-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=janusz.krzysztofik@linux.intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.