diff mbox series

[SRU,J:linux-bluefield,v3,5/6] UBUNTU: SAUCE: vfio/pci: Fix p2p address

Message ID 20240906194908.1127733-6-witu@nvidia.com
State New
Headers show
Series Add VFIO P2P support | expand

Commit Message

William Tu Sept. 6, 2024, 7:49 p.m. UTC
From: Sergey Gorenko <sergeygo@nvidia.com>

BugLink: https://bugs.launchpad.net/bugs/2077887

Use pci_bus_address instead of pci_resource_start. Bus address must
be used for P2PDMA operations. It is simple for x86_64 because bus
address is equal to PA. However, bus address is not equal to PA for
ARM (at least for BF, I did not tested the other ARM platforms.).
That's why pci_resource_start() work fine on x86_64 and we had to
replace it to pci_bus_address() on ARM.

Co-authored-by: William Tu <witu@nvidia.com>
Signed-off-by: Sergey Gorenko <sergeygo@nvidia.com>
Signed-off-by: William Tu <witu@nvidia.com>
---
 drivers/vfio/pci/dma_buf.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/vfio/pci/dma_buf.c b/drivers/vfio/pci/dma_buf.c
index 14d32a580190..58fd3db9c249 100644
--- a/drivers/vfio/pci/dma_buf.c
+++ b/drivers/vfio/pci/dma_buf.c
@@ -4,6 +4,9 @@ 
 #include <linux/dma-buf.h>
 #include <linux/pci-p2pdma.h>
 #include <linux/dma-resv.h>
+#include <linux/module.h>
+#include <uapi/linux/vfio.h>
+#include <linux/vfio_pci_core.h>
 
 #include "vfio_pci_priv.h"
 
@@ -81,7 +84,7 @@  vfio_pci_dma_buf_map(struct dma_buf_attachment *attachment,
 	 */
 	dma_addr = dma_map_resource(
 		attachment->dev,
-		pci_resource_start(priv->vdev->pdev, priv->index) +
+		pci_bus_address(priv->vdev->pdev, priv->index) +
 			priv->offset,
 		priv->dmabuf->size, dir, DMA_ATTR_SKIP_CPU_SYNC);
 	ret = dma_mapping_error(attachment->dev, dma_addr);