[PATCH 4/6] drm/amd/amdgpu: Pin bos from imported dma-bufs to GTT.

Michel Dänzer michel at daenzer.net
Wed Mar 29 01:57:48 UTC 2017


On 29/03/17 09:27 AM, raof at ubuntu.com wrote:
> From: Christopher James Halse Rogers <christopher.halse.rogers at canonical.com>
> 
> Attempting to migrate the bo will break the sharing of the buffer.
> 
> Signed-off-by: Christopher James Halse Rogers <christopher.halse.rogers at canonical.com>
> CC: amd-gfx at lists.freedesktop.org
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c
> index 3826d5aea0a6..3c84ec5c6ac8 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c
> @@ -74,6 +74,17 @@ amdgpu_gem_prime_import_sg_table(struct drm_device *dev,
>  	if (ret)
>  		return ERR_PTR(ret);
>  
> +	/* Imported bo must be pinned to GTT, as moving it breaks sharing */
> +	ret = amdgpu_bo_reserve(bo, false);
> +	if (ret)
> +		return ERR_PTR(ret);
> +
> +	ret = amdgpu_bo_pin(bo, AMDGPU_GEM_DOMAIN_GTT, NULL);
> +	if (ret)
> +		return ERR_PTR(ret);
> +
> +	amdgpu_bo_unreserve(bo);
> +
>  	bo->prime_shared_count = 1;
>  	return &bo->gem_base;
>  }
> 

Thanks for beating me to this! :) This patch and patch 6 are

Reviewed-by: Michel Dänzer <michel.daenzer at amd.com>


-- 
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer


More information about the amd-gfx mailing list