summaryrefslogtreecommitdiff
path: root/drivers/gpu
diff options
context:
space:
mode:
authorFelix Kuehling <felix.kuehling@amd.com>2025-04-17 10:23:15 -0400
committerAlex Deucher <alexander.deucher@amd.com>2025-04-21 10:59:05 -0400
commit3940796a6eefa555fec688a4adee5659ef9fa431 (patch)
treef3023e1bb7a0403ef9213438fd1d1fbe41f85296 /drivers/gpu
parentcb808ab833d1a9bbca0c7ed27e5a31c5c2c9f8cb (diff)
drm/amdgpu: Use allowed_domains for pinning dmabufs
When determining the domains for pinning DMABufs, filter allowed_domains and fail with a warning if VRAM is forbidden and GTT is not an allowed domain. Fixes: f5e7fabd1f5c ("drm/amdgpu: allow pinning DMA-bufs into VRAM if all importers can do P2P") Suggested-by: Christian König <christian.koenig@amd.com> Signed-off-by: Felix Kuehling <felix.kuehling@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
index 667080cc9ae1..0446586bd5a7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
@@ -77,7 +77,7 @@ static int amdgpu_dma_buf_pin(struct dma_buf_attachment *attach)
{
struct dma_buf *dmabuf = attach->dmabuf;
struct amdgpu_bo *bo = gem_to_amdgpu_bo(dmabuf->priv);
- u32 domains = bo->preferred_domains;
+ u32 domains = bo->allowed_domains;
dma_resv_assert_held(dmabuf->resv);
@@ -93,6 +93,9 @@ static int amdgpu_dma_buf_pin(struct dma_buf_attachment *attach)
if (domains & AMDGPU_GEM_DOMAIN_VRAM)
bo->flags |= AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED;
+ if (WARN_ON(!domains))
+ return -EINVAL;
+
return amdgpu_bo_pin(bo, domains);
}