[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PATCH 05/11] pci: Introduce helper to retrieve a PCI device'
From: |
David Gibson |
Subject: |
[Qemu-ppc] [PATCH 05/11] pci: Introduce helper to retrieve a PCI device's DMA address space |
Date: |
Tue, 14 May 2013 19:13:51 +1000 |
A PCI device's DMA address space (possibly an IOMMU) is returned by a
method on the PCIBus. At the moment that only has one caller, so the
method is simply open coded. We'll need another caller for VFIO, so
this patch introduces a helper/wrapper function.
Signed-off-by: David Gibson <address@hidden>
---
hw/pci/pci.c | 9 ++++++++-
include/hw/pci/pci.h | 1 +
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 39085d8..e7a9735 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -811,7 +811,7 @@ static PCIDevice *do_pci_register_device(PCIDevice
*pci_dev, PCIBus *bus,
}
pci_dev->bus = bus;
- dma_as = bus->iommu_fn(bus, bus->iommu_opaque, devfn);
+ dma_as = pci_iommu_as(pci_dev);
memory_region_init_alias(&pci_dev->bus_master_enable_region, "bus master",
dma_as->root, 0,
memory_region_size(dma_as->root));
memory_region_set_enabled(&pci_dev->bus_master_enable_region, false);
@@ -2233,6 +2233,13 @@ static void pci_device_class_init(ObjectClass *klass,
void *data)
k->props = pci_props;
}
+AddressSpace *pci_iommu_as(PCIDevice *dev)
+{
+ PCIBus *bus = PCI_BUS(dev->bus);
+
+ return bus->iommu_fn(bus, bus->iommu_opaque, dev->devfn);
+}
+
void pci_setup_iommu(PCIBus *bus, PCIIOMMUFunc fn, void *opaque)
{
bus->iommu_fn = fn;
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index 6ef1f97..21e2132 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -402,6 +402,7 @@ void pci_device_deassert_intx(PCIDevice *dev);
typedef AddressSpace *(*PCIIOMMUFunc)(PCIBus *, void *, int);
+AddressSpace *pci_iommu_as(PCIDevice *dev);
void pci_setup_iommu(PCIBus *bus, PCIIOMMUFunc fn, void *opaque);
static inline void
--
1.7.10.4
- [Qemu-ppc] [PATCH 09/11] memory: Add iova to IOMMUTLBEntry, (continued)
- [Qemu-ppc] [PATCH 09/11] memory: Add iova to IOMMUTLBEntry, David Gibson, 2013/05/14
- [Qemu-ppc] [PATCH 11/11] vfio: Add guest side IOMMU support, David Gibson, 2013/05/14
- [Qemu-ppc] [PATCH 08/11] vfio: Create VFIOAddressSpace objects as needed, David Gibson, 2013/05/14
- [Qemu-ppc] [PATCH 04/11] pci: Use AddressSpace rather than MemoryRegion to represent PCI DMA space, David Gibson, 2013/05/14
- [Qemu-ppc] [PATCH 05/11] pci: Introduce helper to retrieve a PCI device's DMA address space,
David Gibson <=
- [Qemu-ppc] [PATCH 01/11] iommu: Fix compile error in ioapic.c, David Gibson, 2013/05/14
- [Qemu-ppc] [PATCH 10/11] memory: Add iommu map/unmap notifiers, David Gibson, 2013/05/14
- [Qemu-ppc] [PATCH 03/11] pci: Rework PCI iommu lifetime assumptions, David Gibson, 2013/05/14
- Re: [Qemu-ppc] [0/11] RFC: VFIO and guest side IOMMUs, version 3, Paolo Bonzini, 2013/05/14