Skip to content

Commit

Permalink
drm/amdgpu: add checks if DMA-buf P2P is supported
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Christian König committed Apr 1, 2020
1 parent 57b7b62 commit 48262cd
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 48262cd

Please sign in to comment.