public inbox for intel-gfx@lists.freedesktop.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] drm/i915: Remove locking for get-caching query
Date: Thu, 7 May 2015 15:22:41 +0200	[thread overview]
Message-ID: <20150507132241.GC30184@phenom.ffwll.local> (raw)
In-Reply-To: <1430997295-8336-1-git-send-email-chris@chris-wilson.co.uk>

On Thu, May 07, 2015 at 12:14:55PM +0100, Chris Wilson wrote:
> Reading a single value from the object, the locking only provides futile
> protection against userspace races. The locking is useless so remove it.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
>  drivers/gpu/drm/i915/i915_gem.c | 17 ++++-------------
>  1 file changed, 4 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 2b2b74dbb446..d071d0af2a6c 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -3983,17 +3983,10 @@ int i915_gem_get_caching_ioctl(struct drm_device *dev, void *data,
>  {
>  	struct drm_i915_gem_caching *args = data;
>  	struct drm_i915_gem_object *obj;
> -	int ret;
> -
> -	ret = i915_mutex_lock_interruptible(dev);
> -	if (ret)
> -		return ret;
>  
>  	obj = to_intel_bo(drm_gem_object_lookup(dev, file, args->handle));
> -	if (&obj->base == NULL) {
> -		ret = -ENOENT;
> -		goto unlock;
> -	}
> +	if (&obj->base == NULL)
> +		return -ENOENT;
>  
>  	switch (obj->cache_level) {

Wrap this in ACCESS_ONCE, just for documentation purpose? Can do while
applying if you ack.
-Daniel

>  	case I915_CACHE_LLC:
> @@ -4010,10 +4003,8 @@ int i915_gem_get_caching_ioctl(struct drm_device *dev, void *data,
>  		break;
>  	}
>  
> -	drm_gem_object_unreference(&obj->base);
> -unlock:
> -	mutex_unlock(&dev->struct_mutex);
> -	return ret;
> +	drm_gem_object_unreference_unlocked(&obj->base);
> +	return 0;
>  }
>  
>  int i915_gem_set_caching_ioctl(struct drm_device *dev, void *data,
> -- 
> 2.1.4
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://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
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2015-05-07 13:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-07 11:14 [PATCH] drm/i915: Remove locking for get-caching query Chris Wilson
2015-05-07 13:22 ` Daniel Vetter [this message]
2015-05-07 13:22   ` Chris Wilson
2015-05-07 13:45 ` Mika Kuoppala
2015-05-08  6:39 ` shuang.he

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=20150507132241.GC30184@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