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

Christian König deathsimple at vodafone.de
Wed Mar 29 07:14:33 UTC 2017


Am 29.03.2017 um 02:27 schrieb raof at ubuntu.com:
> 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

NAK on this one and the radeon version.

We can't migrate the buffers to VRAM, but we shouldn't pin it either 
cause that will lock down the GTT space used for it.

Instead you should modify amdgpu_bo_pin() and fail if anybody tries to 
migrate a BO which has prime_shared_count != 0 to VRAM (you migth need 
to add this for radeon).

Regards,
Christian.

> ---
>   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;
>   }




More information about the amd-gfx mailing list