Skip to contentSkip to conversation

drm/amdgpu: Inherit coherence flags on dmabuf import

PATCH In review Felix Kuehling 2 participants 2 messages Nov 4, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: Inherit coherence flags on dmabuf import

When importing dmabufs from other amdgpu devices, inherit the coherence flags from the exported BO. This ensures correct MTYPEs in the GPU PTEs for multi-GPU mappings of shared BOs.

Fixes 763fbebb20e1 ("drm/amdgpu: Set MTYPE in PTE based on BO flags")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +3 -1
index 7bd8e33b14be..271e30e34d93 100644
@@ -328,7 +328,9 @@ amdgpu_dma_buf_create_obj(struct drm_device *dev, struct dma_buf *dma_buf)
 	if (dma_buf->ops == &amdgpu_dmabuf_ops) {
 		struct amdgpu_bo *other = gem_to_amdgpu_bo(dma_buf->priv);
 
-		flags |= other->flags & AMDGPU_GEM_CREATE_CPU_GTT_USWC;
+		flags |= other->flags & (AMDGPU_GEM_CREATE_CPU_GTT_USWC |
+					 AMDGPU_GEM_CREATE_COHERENT |
+					 AMDGPU_GEM_CREATE_UNCACHED);
 	}
 
 	ret = amdgpu_gem_object_create(adev, dma_buf->size, PAGE_SIZE,
Signature · 1 line
2.32.0
maintainer Acked-by on v1 1/1
#1 lore raw

Am 04.11.22 um 16:40 schrieb Felix Kuehling:

Quoted 7 lines

When importing dmabufs from other amdgpu devices, inherit the coherence flags from the exported BO. This ensures correct MTYPEs in the GPU PTEs for multi-GPU mappings of shared BOs.

Fixes 763fbebb20e1 ("drm/amdgpu: Set MTYPE in PTE based on BO flags")
Quoted 19 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +3 -1
index 7bd8e33b14be..271e30e34d93 100644
@@ -328,7 +328,9 @@ amdgpu_dma_buf_create_obj(struct drm_device *dev, struct dma_buf *dma_buf)
  	if (dma_buf->ops == &amdgpu_dmabuf_ops) {
  		struct amdgpu_bo *other = gem_to_amdgpu_bo(dma_buf->priv);
 
-		flags |= other->flags & AMDGPU_GEM_CREATE_CPU_GTT_USWC;
+		flags |= other->flags & (AMDGPU_GEM_CREATE_CPU_GTT_USWC |
+					 AMDGPU_GEM_CREATE_COHERENT |
+					 AMDGPU_GEM_CREATE_UNCACHED);
  	}
 
  	ret = amdgpu_gem_object_create(adev, dma_buf->size, PAGE_SIZE,