From 89496dcdca7873eb7457bdaeb1c142aee1914d2f Mon Sep 17 00:00:00 2001 From: Mukul Joshi Date: Wed, 12 Nov 2025 14:00:01 -0500 Subject: [PATCH] drm/amdgpu: Control NPA DMA-buf importing NPA DMA-Bufs can only be imported on the same device as the original BO. In source-identification mode NPA addresses are importer-specific. Each GPU needs to import the UALink handle by themselves. Sharing the NPA addresses between devices is meaningless and potentially dangerous. Put controls to ensure this is not violated. Signed-off-by: Mukul Joshi Reviewed-by: Felix Kuehling Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c index b33c300e26e2..b4fbd8a407f1 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c @@ -558,6 +558,11 @@ struct drm_gem_object *amdgpu_gem_prime_import(struct drm_device *dev, */ drm_gem_object_get(obj); return obj; + } else { + struct ttm_resource *mem = gem_to_amdgpu_bo(obj)->tbo.resource; + /* NPA DMA-buf can only be imported on the same device. */ + if (mem && mem->mem_type == AMDGPU_PL_NPA) + return ERR_PTR(-EPERM); } }