[Intel-gfx] [PATCH 19/42] drm/i915/dmabuf: Acquire the backing storage outside of struct_mutex

Joonas Lahtinen joonas.lahtinen at linux.intel.com
Thu Oct 13 11:54:39 UTC 2016


On pe, 2016-10-07 at 10:46 +0100, Chris Wilson wrote:
> @@ -72,21 +68,18 @@ static struct sg_table *i915_gem_map_dma_buf(struct dma_buf_attachment *attachme
>  	}
>  
>  	if (!dma_map_sg(attachment->dev, st->sgl, st->nents, dir)) {
> -		ret =-ENOMEM;
> +		ret = -ENOMEM;
>  		goto err_free_sg;
>  	}
>  
> -	mutex_unlock(&obj->base.dev->struct_mutex);
>  	return st;
>  
>  err_free_sg:
>  	sg_free_table(st);
>  err_free:
>  	kfree(st);
> -err_unpin:
> +err_put_pages:
>  	i915_gem_object_unpin_pages(obj);

I do not quite follow the logic leading to rename in here.

> @@ -177,15 +155,22 @@ static int i915_gem_begin_cpu_access(struct dma_buf *dma_buf, enum dma_data_dire
>  {
>  	struct drm_i915_gem_object *obj = dma_buf_to_obj(dma_buf);
>  	struct drm_device *dev = obj->base.dev;
> -	int ret;
>  	bool write = (direction == DMA_BIDIRECTIONAL || direction == DMA_TO_DEVICE);
> +	int ret;
>  
> -	ret = i915_mutex_lock_interruptible(dev);
> +	ret = i915_gem_object_pin_pages(obj);
>  	if (ret)
>  		return ret;
>  
> +	ret = i915_mutex_lock_interruptible(dev);
> +	if (ret)
> +		goto err;
> +
>  	ret = i915_gem_object_set_to_cpu_domain(obj, write);
>  	mutex_unlock(&dev->struct_mutex);
> +
> +err:

combined path, 'out:'
 
> @@ -195,13 +180,19 @@ static int i915_gem_end_cpu_access(struct dma_buf *dma_buf, enum dma_data_direct
>  	struct drm_device *dev = obj->base.dev;
>  	int ret;
>  
> -	ret = i915_mutex_lock_interruptible(dev);
> +	ret = i915_gem_object_pin_pages(obj);
>  	if (ret)
>  		return ret;
>  
> +	ret = i915_mutex_lock_interruptible(dev);
> +	if (ret)
> +		goto err;
> +
>  	ret = i915_gem_object_set_to_gtt_domain(obj, false);
> 	mutex_unlock(&dev->struct_mutex);
>  
> +err:

Ditto.

With above fixed;

Reviewed-by: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>

Regards, Joonas
-- 
Joonas Lahtinen
Open Source Technology Center
Intel Corporation


More information about the Intel-gfx mailing list