qemu-arm
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC PATCH 6/6] include/hw/pci: Send PCI dma requests with memory attrib


From: Jason Chien
Subject: [RFC PATCH 6/6] include/hw/pci: Send PCI dma requests with memory attributes containing BDF
Date: Mon, 16 Dec 2024 08:48:57 +0800

In order to distinguish which PCIe device sends the request over the IOMMU,
the requester_id must be set with the BDF of the device.

Signed-off-by: Jason Chien <jason.chien@sifive.com>
---
 include/hw/pci/pci_device.h | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/include/hw/pci/pci_device.h b/include/hw/pci/pci_device.h
index 8eaf0d58bb..e22d05dae8 100644
--- a/include/hw/pci/pci_device.h
+++ b/include/hw/pci/pci_device.h
@@ -263,8 +263,11 @@ static inline MemTxResult pci_dma_rw(PCIDevice *dev, 
dma_addr_t addr,
 static inline MemTxResult pci_dma_read(PCIDevice *dev, dma_addr_t addr,
                                        void *buf, dma_addr_t len)
 {
+    MemTxAttrs attrs = {};
+    attrs.requester_id = pci_requester_id(dev);
+
     return pci_dma_rw(dev, addr, buf, len,
-                      DMA_DIRECTION_TO_DEVICE, MEMTXATTRS_UNSPECIFIED);
+                      DMA_DIRECTION_TO_DEVICE, attrs);
 }
 
 /**
@@ -282,8 +285,11 @@ static inline MemTxResult pci_dma_read(PCIDevice *dev, 
dma_addr_t addr,
 static inline MemTxResult pci_dma_write(PCIDevice *dev, dma_addr_t addr,
                                         const void *buf, dma_addr_t len)
 {
+    MemTxAttrs attrs = {};
+    attrs.requester_id = pci_requester_id(dev);
+
     return pci_dma_rw(dev, addr, (void *) buf, len,
-                      DMA_DIRECTION_FROM_DEVICE, MEMTXATTRS_UNSPECIFIED);
+                      DMA_DIRECTION_FROM_DEVICE, attrs);
 }
 
 #define PCI_DMA_DEFINE_LDST(_l, _s, _bits) \
@@ -327,8 +333,11 @@ PCI_DMA_DEFINE_LDST(q_be, q_be, 64);
 static inline void *pci_dma_map(PCIDevice *dev, dma_addr_t addr,
                                 dma_addr_t *plen, DMADirection dir)
 {
+    MemTxAttrs attrs = {};
+    attrs.requester_id = pci_requester_id(dev);
+
     return dma_memory_map(pci_get_address_space(dev), addr, plen, dir,
-                          MEMTXATTRS_UNSPECIFIED);
+                          attrs);
 }
 
 static inline void pci_dma_unmap(PCIDevice *dev, void *buffer, dma_addr_t len,
-- 
2.43.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]