[Intel-gfx] [PATCH 29/38] drm/i915: Remove locking for get_tiling

Daniel Vetter daniel at ffwll.ch
Wed Jun 8 10:02:01 UTC 2016


On Fri, Jun 03, 2016 at 05:55:44PM +0100, Chris Wilson wrote:
> Since we are not concerned with userspace racing itself with set-tiling
> (the order is indeterminant even if we take a lock), then we can safely
> read back the single obj->tiling_mode and do the static lookup of
> swizzle mode without having to take a lock.
> 
> get-tiling is reasonably frequent due to the back-channel passing around
> of tiling parameters in DRI2/DRI3.
> 
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> ---
>  drivers/gpu/drm/i915/i915_gem_tiling.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem_tiling.c b/drivers/gpu/drm/i915/i915_gem_tiling.c
> index 326de7eae101..d6acd0a27c06 100644
> --- a/drivers/gpu/drm/i915/i915_gem_tiling.c
> +++ b/drivers/gpu/drm/i915/i915_gem_tiling.c
> @@ -302,10 +302,8 @@ i915_gem_get_tiling(struct drm_device *dev, void *data,
>  	if (!obj)
>  		return -ENOENT;
>  
> -	mutex_lock(&dev->struct_mutex);
> -
>  	args->tiling_mode = obj->tiling_mode;

READ_ONCE here. With that Reviewed-by: Daniel Vetter <daniel.vetter at ffwll.ch>

> -	switch (obj->tiling_mode) {
> +	switch (args->tiling_mode) {
>  	case I915_TILING_X:
>  		args->swizzle_mode = dev_priv->mm.bit_6_swizzle_x;
>  		break;
> @@ -329,8 +327,6 @@ i915_gem_get_tiling(struct drm_device *dev, void *data,
>  	if (args->swizzle_mode == I915_BIT_6_SWIZZLE_9_10_17)
>  		args->swizzle_mode = I915_BIT_6_SWIZZLE_9_10;
>  
> -	i915_gem_object_put(obj);
> -	mutex_unlock(&dev->struct_mutex);
> -
> +	i915_gem_object_put_unlocked(obj);
>  	return 0;
>  }
> -- 
> 2.8.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


More information about the Intel-gfx mailing list