[SRU][J:linux-bluefield][PATCH v6 5/6] UBUNTU: SAUCE: vfio/pci: Fix p2p address
William Tu
witu at nvidia.com
Mon Sep 23 22:35:21 UTC 2024
From: Sergey Gorenko <sergeygo at 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 at nvidia.com>
Signed-off-by: Sergey Gorenko <sergeygo at nvidia.com>
Signed-off-by: William Tu <witu at nvidia.com>
---
drivers/vfio/pci/dma_buf.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
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);
--
2.34.1
More information about the kernel-team
mailing list