qemu-arm
[Top][All Lists]
Advanced

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

[RFC PATCH 2/6] hw/pci: Add an API to set the downstream memory region o


From: Jason Chien
Subject: [RFC PATCH 2/6] hw/pci: Add an API to set the downstream memory region of a PCI bus
Date: Mon, 16 Dec 2024 08:48:53 +0800

pci_setup_iommu_downstream_mem() invokes PCIIOMMUOps.set_memory_region()
to set the downstream memroy region of a PCI bus.

Signed-off-by: Jason Chien <jason.chien@sifive.com>
---
 hw/pci/pci.c         | 6 ++++++
 include/hw/pci/pci.h | 7 +++++++
 2 files changed, 13 insertions(+)

diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 1416ae202c..8703d75ac3 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -2811,6 +2811,12 @@ void pci_setup_iommu(PCIBus *bus, const PCIIOMMUOps 
*ops, void *opaque)
     bus->iommu_opaque = opaque;
 }
 
+void pci_setup_iommu_downstream_mem(PCIBus *bus, MemoryRegion *mr)
+{
+    assert(bus->iommu_ops && bus->iommu_ops->set_memory_region);
+    bus->iommu_ops->set_memory_region(bus->iommu_opaque, mr);
+}
+
 static void pci_dev_get_w64(PCIBus *b, PCIDevice *dev, void *opaque)
 {
     Range *range = opaque;
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index cb3039bce8..9ae2cc61f1 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -450,6 +450,13 @@ void pci_device_unset_iommu_device(PCIDevice *dev);
  * @opaque: passed to callbacks of the @ops structure.
  */
 void pci_setup_iommu(PCIBus *bus, const PCIIOMMUOps *ops, void *opaque);
+/**
+ * pci_setup_iommu_downstream_mem: Designate a memory region for a PCIBus
+ *
+ * @bus: the #PCIBus being updated.
+ * @mr: the designated memory region.
+ */
+void pci_setup_iommu_downstream_mem(PCIBus *bus, MemoryRegion *mr);
 
 pcibus_t pci_bar_address(PCIDevice *d,
                          int reg, uint8_t type, pcibus_t size);
-- 
2.43.2




reply via email to

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