[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
- [RFC PATCH 0/6] Avoid contention for PCIIOMMUOps between IOMMU and PCIe host, Jason Chien, 2024/12/15
- [RFC PATCH 1/6] include/hw/pci: Add a callback to set the downstream memory region of a pci bus, Jason Chien, 2024/12/15
- [RFC PATCH 2/6] hw/pci: Add an API to set the downstream memory region of a PCI bus, Jason Chien, 2024/12/15
- [RFC PATCH 3/6] hw/pci-host: Enable DW PCIe host to send memory transactions over specific mr, Jason Chien, 2024/12/15
- [RFC PATCH 4/6] hw/riscv/riscv-iommu: Allow PCI hosts with iommu_ops registered connecting to the IOMMU, Jason Chien, 2024/12/15
- [RFC PATCH 5/6] hw/riscv/riscv-iommu: Acquire device IDs dynamically, Jason Chien, 2024/12/15
- [RFC PATCH 6/6] include/hw/pci: Send PCI dma requests with memory attributes containing BDF,
Jason Chien <=