Skip to content

Commit 48262cd

Browse files
drm/amdgpu: add checks if DMA-buf P2P is supported
Check if we can do peer2peer on the PCIe bus. Signed-off-by: Christian König <[email protected]> Acked-by: Daniel Vetter <[email protected]> Acked-by: Sumit Semwal <[email protected]> Link: https://patchwork.freedesktop.org/patch/359294
1 parent 57b7b62 commit 48262cd

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include <drm/amdgpu_drm.h>
3939
#include <linux/dma-buf.h>
4040
#include <linux/dma-fence-array.h>
41+
#include <linux/pci-p2pdma.h>
4142

4243
/**
4344
* amdgpu_gem_prime_vmap - &dma_buf_ops.vmap implementation
@@ -179,6 +180,9 @@ static int amdgpu_dma_buf_attach(struct dma_buf *dmabuf,
179180
struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
180181
int r;
181182

183+
if (pci_p2pdma_distance_many(adev->pdev, &attach->dev, 1, true) < 0)
184+
attach->peer2peer = false;
185+
182186
if (attach->dev->driver == adev->dev->driver)
183187
return 0;
184188

0 commit comments

Comments
 (0)