From: Christian König Date: Fri, 23 Mar 2018 15:33:57 +0000 (+0100) Subject: drm/amdgpu: add checks if DMA-buf P2P is supported X-Git-Tag: block-5.8-2020-06-11~21^2~17^2~89 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=48262cd9499c9cd0faf687ef9427cc0b0a3b0189;p=linux-block.git 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 Acked-by: Daniel Vetter Acked-by: Sumit Semwal Link: https://patchwork.freedesktop.org/patch/359294 --- diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c index aef12ee2f1e3..bbf67800c8a6 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c @@ -38,6 +38,7 @@ #include #include #include +#include /** * 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;