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")
Tested-by: Gang Ba <gang...@amd.com>
Signed-off-by: Felix Kuehling <felix.kuehl...@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
index 7bd8e33b14be..271e30e34d93 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
@@ -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,
-- 
2.32.0

Reply via email to