Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 1/2] drm/i915: Wrap the protected active RCU dereference in a helper
Date: Tue, 9 Aug 2016 08:36:56 +0200	[thread overview]
Message-ID: <20160809063655.GJ6232@phenom.ffwll.local> (raw)
In-Reply-To: <1470641328-18252-1-git-send-email-chris@chris-wilson.co.uk>

On Mon, Aug 08, 2016 at 08:28:47AM +0100, Chris Wilson wrote:
> As we do the lockdep protected RCU lookup in a couple of places,
> refactor that code to a common helper i915_gem_active_raw()..
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
>  drivers/gpu/drm/i915/i915_gem_request.h | 21 +++++++++++++++++----
>  1 file changed, 17 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem_request.h b/drivers/gpu/drm/i915/i915_gem_request.h
> index 3496e28785e7..6dd01cbf4895 100644
> --- a/drivers/gpu/drm/i915/i915_gem_request.h
> +++ b/drivers/gpu/drm/i915/i915_gem_request.h
> @@ -360,6 +360,21 @@ __i915_gem_active_peek(const struct i915_gem_active *active)
>  }
>  
>  /**
> + * i915_gem_active_raw - return the active request
> + * @active - the active tracker
> + *
> + * i915_gem_active_raw() returns the current request being tracked, or NULL.
> + * It does not obtain a reference on the request for the caller, so the caller
> + * must hold struct_mutex.
> + */
> +static inline struct drm_i915_gem_request *
> +i915_gem_active_raw(const struct i915_gem_active *active, struct mutex *mutex)

There's a rcu_dereference_raw helper which doesn't bother with any lockdep
checking. A bit confusing naming, otoh I couldn't come up with something
better.

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> +{
> +	return rcu_dereference_protected(active->request,
> +					 lockdep_is_held(mutex));
> +}
> +
> +/**
>   * i915_gem_active_peek - report the active request being monitored
>   * @active - the active tracker
>   *
> @@ -372,8 +387,7 @@ i915_gem_active_peek(const struct i915_gem_active *active, struct mutex *mutex)
>  {
>  	struct drm_i915_gem_request *request;
>  
> -	request = rcu_dereference_protected(active->request,
> -					    lockdep_is_held(mutex));
> +	request = i915_gem_active_raw(active, mutex);
>  	if (!request || i915_gem_request_completed(request))
>  		return NULL;
>  
> @@ -635,8 +649,7 @@ i915_gem_active_retire(struct i915_gem_active *active,
>  	struct drm_i915_gem_request *request;
>  	int ret;
>  
> -	request = rcu_dereference_protected(active->request,
> -					    lockdep_is_held(mutex));
> +	request = i915_gem_active_raw(active, mutex);
>  	if (!request)
>  		return 0;
>  
> -- 
> 2.8.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2016-08-09  6:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-08  7:28 [PATCH 1/2] drm/i915: Wrap the protected active RCU dereference in a helper Chris Wilson
2016-08-08  7:28 ` [PATCH 2/2] drm/i915: Don't check for idleness before retiring after a GPU hang Chris Wilson
2016-08-09  6:43   ` Daniel Vetter
2016-08-12 10:20   ` Joonas Lahtinen
2016-08-08  7:56 ` ✗ Ro.CI.BAT: failure for series starting with [1/2] drm/i915: Wrap the protected active RCU dereference in a helper Patchwork
2016-08-09  6:36 ` Daniel Vetter [this message]
2016-08-09  7:08   ` [PATCH 1/2] " Chris Wilson
2016-08-10 10:21     ` Daniel Vetter

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=20160809063655.GJ6232@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --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