[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PATCH v2 1/2] iommu: Replace bus+devfn arguments with PCIDev
From: |
Knut Omang |
Subject: |
[Qemu-ppc] [PATCH v2 1/2] iommu: Replace bus+devfn arguments with PCIDevice* in PCIIOMMUFunc |
Date: |
Tue, 1 Sep 2015 20:48:21 +0200 |
The dev pointer is needed by intel_iommu to enable it to store the dma address
pointer
with the device.
Signed-off-by: Knut Omang <address@hidden>
---
hw/alpha/typhoon.c | 2 +-
hw/pci-host/apb.c | 2 +-
hw/pci-host/prep.c | 3 +--
hw/pci-host/q35.c | 5 +++--
hw/pci/pci.c | 7 +++----
hw/ppc/spapr_pci.c | 2 +-
include/hw/pci/pci.h | 4 +++-
7 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/hw/alpha/typhoon.c b/hw/alpha/typhoon.c
index 421162e..7e9a521 100644
--- a/hw/alpha/typhoon.c
+++ b/hw/alpha/typhoon.c
@@ -726,7 +726,7 @@ static const MemoryRegionIOMMUOps typhoon_iommu_ops = {
.translate = typhoon_translate_iommu,
};
-static AddressSpace *typhoon_pci_dma_iommu(PCIBus *bus, void *opaque, int
devfn)
+static AddressSpace *typhoon_pci_dma_iommu(PCIDevice *dev, void *opaque)
{
TyphoonState *s = opaque;
return &s->pchip.iommu_as;
diff --git a/hw/pci-host/apb.c b/hw/pci-host/apb.c
index 599768e..6c78887 100644
--- a/hw/pci-host/apb.c
+++ b/hw/pci-host/apb.c
@@ -198,7 +198,7 @@ static inline void pbm_clear_request(APBState *s, unsigned
int irq_num)
s->irq_request = NO_IRQ_REQUEST;
}
-static AddressSpace *pbm_pci_dma_iommu(PCIBus *bus, void *opaque, int devfn)
+static AddressSpace *pbm_pci_dma_iommu(PCIDevice *dev, void *opaque)
{
IOMMUState *is = opaque;
diff --git a/hw/pci-host/prep.c b/hw/pci-host/prep.c
index c63f45d..cfe5594 100644
--- a/hw/pci-host/prep.c
+++ b/hw/pci-host/prep.c
@@ -196,8 +196,7 @@ static void raven_set_irq(void *opaque, int irq_num, int
level)
qemu_set_irq(pic[irq_num] , level);
}
-static AddressSpace *raven_pcihost_set_iommu(PCIBus *bus, void *opaque,
- int devfn)
+static AddressSpace *raven_pcihost_set_iommu(PCIDevice *dev, void *opaque)
{
PREPPCIState *s = opaque;
diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
index bd74094..7892482 100644
--- a/hw/pci-host/q35.c
+++ b/hw/pci-host/q35.c
@@ -423,11 +423,12 @@ static void mch_reset(DeviceState *qdev)
mch_update(mch);
}
-static AddressSpace *q35_host_dma_iommu(PCIBus *bus, void *opaque, int devfn)
+static AddressSpace *q35_host_dma_iommu(PCIDevice *dev, void *opaque)
{
IntelIOMMUState *s = opaque;
VTDAddressSpace **pvtd_as;
- int bus_num = pci_bus_num(bus);
+ int bus_num = pci_bus_num(dev->bus);
+ int devfn = dev->devfn;
assert(0 <= bus_num && bus_num <= VTD_PCI_BUS_MAX);
assert(0 <= devfn && devfn <= VTD_PCI_DEVFN_MAX);
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 251bcbf..5ece4c0 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -870,7 +870,6 @@ static PCIDevice *do_pci_register_device(PCIDevice
*pci_dev, PCIBus *bus,
PCIConfigReadFunc *config_read = pc->config_read;
PCIConfigWriteFunc *config_write = pc->config_write;
Error *local_err = NULL;
- AddressSpace *dma_as;
if (devfn < 0) {
for(devfn = bus->devfn_min ; devfn < ARRAY_SIZE(bus->devices);
@@ -892,11 +891,11 @@ static PCIDevice *do_pci_register_device(PCIDevice
*pci_dev, PCIBus *bus,
pci_dev->bus = bus;
pci_dev->devfn = devfn;
- dma_as = pci_device_iommu_address_space(pci_dev);
+ pci_dev->dma_as = pci_device_iommu_address_space(pci_dev);
memory_region_init_alias(&pci_dev->bus_master_enable_region,
OBJECT(pci_dev), "bus master",
- dma_as->root, 0,
memory_region_size(dma_as->root));
+ pci_dev->dma_as->root, 0,
memory_region_size(pci_dev->dma_as->root));
memory_region_set_enabled(&pci_dev->bus_master_enable_region, false);
address_space_init(&pci_dev->bus_master_as,
&pci_dev->bus_master_enable_region,
name);
@@ -2442,7 +2441,7 @@ AddressSpace *pci_device_iommu_address_space(PCIDevice
*dev)
PCIBus *bus = PCI_BUS(dev->bus);
if (bus->iommu_fn) {
- return bus->iommu_fn(bus, bus->iommu_opaque, dev->devfn);
+ return bus->iommu_fn(dev, bus->iommu_opaque);
}
if (bus->parent_dev) {
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index a8f79d8..7d39317 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -747,7 +747,7 @@ static const MemoryRegionOps spapr_msi_ops = {
/*
* PHB PCI device
*/
-static AddressSpace *spapr_pci_dma_iommu(PCIBus *bus, void *opaque, int devfn)
+static AddressSpace *spapr_pci_dma_iommu(PCIDevice *dev, void *opaque)
{
sPAPRPHBState *phb = opaque;
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index 2e9d8ba..e142641 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -247,6 +247,7 @@ struct PCIDevice {
char name[64];
PCIIORegion io_regions[PCI_NUM_REGIONS];
AddressSpace bus_master_as;
+ AddressSpace *dma_as;
MemoryRegion bus_master_enable_region;
/* do not access the following fields */
@@ -415,7 +416,8 @@ void pci_bus_get_w64_range(PCIBus *bus, Range *range);
void pci_device_deassert_intx(PCIDevice *dev);
-typedef AddressSpace *(*PCIIOMMUFunc)(PCIBus *, void *, int);
+typedef AddressSpace *(*PCIIOMMUFunc)(PCIDevice *, void *);
+void pci_set_dma_address_space(AddressSpace *dma_address_space);
AddressSpace *pci_device_iommu_address_space(PCIDevice *dev);
void pci_setup_iommu(PCIBus *bus, PCIIOMMUFunc fn, void *opaque);
--
2.4.3
- [Qemu-ppc] [PATCH v2 0/2] intel_iommu: Add support for translation for devices behind bridges, Knut Omang, 2015/09/01
- [Qemu-ppc] [PATCH v2 1/2] iommu: Replace bus+devfn arguments with PCIDevice* in PCIIOMMUFunc,
Knut Omang <=
- [Qemu-ppc] [PATCH v2 2/2] intel_iommu: Add support for translation for devices behind bridges., Knut Omang, 2015/09/01
- Re: [Qemu-ppc] [Qemu-devel] [PATCH v2 0/2] intel_iommu: Add support for translation for devices behind bridges, Marcel Apfelbaum, 2015/09/02
- Re: [Qemu-ppc] [Qemu-devel] [PATCH v2 0/2] intel_iommu: Add support for translation for devices behind bridges, Knut Omang, 2015/09/02
- Re: [Qemu-ppc] [Qemu-devel] [PATCH v2 0/2] intel_iommu: Add support for translation for devices behind bridges, Alex Williamson, 2015/09/02
- Re: [Qemu-ppc] [Qemu-devel] [PATCH v2 0/2] intel_iommu: Add support for translation for devices behind bridges, Benjamin Herrenschmidt, 2015/09/02
- Re: [Qemu-ppc] [Qemu-devel] [PATCH v2 0/2] intel_iommu: Add support for translation for devices behind bridges, Knut Omang, 2015/09/03
- Re: [Qemu-ppc] [Qemu-devel] [PATCH v2 0/2] intel_iommu: Add support for translation for devices behind bridges, Knut Omang, 2015/09/12
- Re: [Qemu-ppc] [Qemu-devel] [PATCH v2 0/2] intel_iommu: Add support for translation for devices behind bridges, Benjamin Herrenschmidt, 2015/09/12
- Re: [Qemu-ppc] [Qemu-devel] [PATCH v2 0/2] intel_iommu: Add support for translation for devices behind bridges, Knut Omang, 2015/09/13