]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
drm/amdgpu: add checks if DMA-buf P2P is supported
authorChristian König <christian.koenig@amd.com>
Fri, 23 Mar 2018 15:33:57 +0000 (16:33 +0100)
committerChristian König <christian.koenig@amd.com>
Wed, 1 Apr 2020 07:02:45 +0000 (09:02 +0200)
Check if we can do peer2peer on the PCIe bus.

Signed-off-by: Christian König <christian.koenig@amd.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: Sumit Semwal <sumit.semwal@linaro.org>
Link: https://patchwork.freedesktop.org/patch/359294
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c

index aef12ee2f1e32080a87df3243fcb74e87b078f53..bbf67800c8a6373f5a1919d1779940610bf26c52 100644 (file)
@@ -38,6 +38,7 @@
 #include <drm/amdgpu_drm.h>
 #include <linux/dma-buf.h>
 #include <linux/dma-fence-array.h>
+#include <linux/pci-p2pdma.h>
 
 /**
  * amdgpu_gem_prime_vmap - &dma_buf_ops.vmap implementation
@@ -179,6 +180,9 @@ static int amdgpu_dma_buf_attach(struct dma_buf *dmabuf,
        struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
        int r;
 
+       if (pci_p2pdma_distance_many(adev->pdev, &attach->dev, 1, true) < 0)
+               attach->peer2peer = false;
+
        if (attach->dev->driver == adev->dev->driver)
                return 0;