public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/i915: Reorder context-close to avoid calling i915_vma_close() under RCU
Date: Thu, 9 Nov 2017 08:37:29 +0000	[thread overview]
Message-ID: <07e0da43-bd3a-2590-e9b1-68f83bf0b936@linux.intel.com> (raw)
In-Reply-To: <20171109082048.29408-1-chris@chris-wilson.co.uk>


On 09/11/2017 08:20, Chris Wilson wrote:
> When we close the VMA, we unbind it from the ppgtt and tear down the
> page directory pointing at it. That may trigger us to return WC pages
> back to the system, requiring conversion back to WB which itself may
> sleep. That makes i915_vma_close() unsuitable for use inside the RCU
> read lock, which we need to hold to iterate the radixtree.
> 
> The fix is quite simple, we can close all the VMA as we close the ppgtt,
> we only need to do that instead of closing them during destruction of
> the LUT.
> 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103638
> Fixes: 547da76b5777 ("drm/i915: Hold rcu_read_lock when iterating over the radixtree (vma idr)")
> Fixes: d1b48c1e7184 ("drm/i915: Replace execbuf vma ht with an idr")
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Matthew Auld <matthew.william.auld@gmail.com>
> ---
>   drivers/gpu/drm/i915/i915_gem_context.c | 10 +++-------
>   1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
> index 10affb35ac56..0e1c4626870e 100644
> --- a/drivers/gpu/drm/i915/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/i915_gem_context.c
> @@ -107,14 +107,9 @@ static void lut_close(struct i915_gem_context *ctx)
>   	rcu_read_lock();
>   	radix_tree_for_each_slot(slot, &ctx->handles_vma, &iter, 0) {
>   		struct i915_vma *vma = rcu_dereference_raw(*slot);
> -		struct drm_i915_gem_object *obj = vma->obj;
>   
>   		radix_tree_iter_delete(&ctx->handles_vma, &iter, slot);
> -
> -		if (!i915_vma_is_ggtt(vma))
> -			i915_vma_close(vma);
> -
> -		__i915_gem_object_release_unless_active(obj);
> +		__i915_gem_object_release_unless_active(vma->obj);
>   	}
>   	rcu_read_unlock();
>   }
> @@ -200,10 +195,11 @@ static void context_close(struct i915_gem_context *ctx)
>   {
>   	i915_gem_context_set_closed(ctx);
>   
> -	lut_close(ctx);
>   	if (ctx->ppgtt)
>   		i915_ppgtt_close(&ctx->ppgtt->base);
>   
> +	lut_close(ctx);
> +
>   	ctx->file_priv = ERR_PTR(-EBADF);
>   	i915_gem_context_put(ctx);
>   }
> 

Looks straightforward enough. Was a bit unsure about how the pre-ppgtt 
world works but that too looks fine.

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Regards,

Tvrtko
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2017-11-09  8:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-09  8:20 [PATCH] drm/i915: Reorder context-close to avoid calling i915_vma_close() under RCU Chris Wilson
2017-11-09  8:37 ` Tvrtko Ursulin [this message]
2017-11-09  8:42 ` ✗ Fi.CI.BAT: failure for " Patchwork
2017-11-09  8:50 ` [PATCH] " Chris Wilson
2017-11-09  8:55 ` [PATCH v2] " Chris Wilson
2017-11-09  9:32   ` Tvrtko Ursulin
2017-11-09 10:00     ` Tvrtko Ursulin
2017-11-09 10:16       ` Chris Wilson
2017-11-09  9:36 ` ✓ Fi.CI.BAT: success for drm/i915: Reorder context-close to avoid calling i915_vma_close() under RCU (rev2) Patchwork
2017-11-09 11:01 ` ✓ Fi.CI.IGT: " 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=07e0da43-bd3a-2590-e9b1-68f83bf0b936@linux.intel.com \
    --to=tvrtko.ursulin@linux.intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.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