From: Knut Omang <knut.omang@oracle.com>
To: qemu-devel@nongnu.org
Cc: "Knut Omang" <knut.omang@oracle.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Michael Tokarev" <mjt@tls.msk.ru>,
"Marcel Apfelbaum" <marcel.a@redhat.com>,
"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
"Alexander Graf" <agraf@suse.de>,
"Markus Armbruster" <armbru@redhat.com>,
"Andreas Färber" <andreas.faerber@web.de>,
"Hervé Poussineau" <hpoussin@reactos.org>,
"Anthony Liguori" <aliguori@amazon.com>,
"Stefan Weil" <sw@weilnetz.de>,
qemu-ppc@nongnu.org, "Richard Henderson" <rth@twiddle.net>
Subject: [Qemu-devel] [PATCH 1/2] iommu: Replace bus+devfn arguments with PCIDevice* in PCIIOMMUFunc
Date: Tue, 21 Oct 2014 00:34:02 +0200 [thread overview]
Message-ID: <1413844443-28894-2-git-send-email-knut.omang@oracle.com> (raw)
In-Reply-To: <1413844443-28894-1-git-send-email-knut.omang@oracle.com>
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 <knut.omang@oracle.com>
---
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 5310006..62f7178 100644
--- a/hw/alpha/typhoon.c
+++ b/hw/alpha/typhoon.c
@@ -725,7 +725,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 f573875..06b6daa 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 1de3681..ba997a8 100644
--- a/hw/pci-host/prep.c
+++ b/hw/pci-host/prep.c
@@ -194,8 +194,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 b20bad8..c087c96 100644
--- a/hw/pci-host/q35.c
+++ b/hw/pci-host/q35.c
@@ -347,11 +347,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 6ce75aa..b077173 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -808,7 +808,6 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pci_dev);
PCIConfigReadFunc *config_read = pc->config_read;
PCIConfigWriteFunc *config_write = pc->config_write;
- AddressSpace *dma_as;
if (devfn < 0) {
for(devfn = bus->devfn_min ; devfn < ARRAY_SIZE(bus->devices);
@@ -827,11 +826,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);
@@ -2280,7 +2279,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 ad0da7f..656fae3 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -472,7 +472,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 c352c7b..4bcf151 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -242,6 +242,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 */
@@ -408,7 +409,8 @@ int pci_parse_devaddr(const char *addr, int *domp, int *busp,
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);
--
1.9.0
next prev parent reply other threads:[~2014-10-20 22:36 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-20 22:34 [Qemu-devel] [PATCH 0/2] intel_iommu: Add support for translation for devices behind bridges Knut Omang
2014-10-20 22:34 ` Knut Omang [this message]
2014-10-20 22:34 ` [Qemu-devel] [PATCH 2/2] " Knut Omang
2014-10-25 11:36 ` Jan Kiszka
2014-10-25 12:24 ` Jan Kiszka
2014-10-26 4:46 ` Knut Omang
2014-10-25 12:28 ` Jan Kiszka
2014-10-26 12:06 ` Jan Kiszka
2014-10-26 13:15 ` Knut Omang
2014-10-26 15:20 ` Michael S. Tsirkin
2014-10-20 23:29 ` [Qemu-devel] [PATCH 0/2] " Alexander Graf
2014-10-21 5:26 ` Knut Omang
2014-10-21 9:07 ` Alexander Graf
2014-10-21 9:35 ` Knut Omang
2014-10-21 11:15 ` Alexander Graf
2014-10-21 11:26 ` Michael S. Tsirkin
2014-10-21 11:37 ` Knut Omang
2014-10-21 12:20 ` Michael S. Tsirkin
2014-10-21 15:07 ` Alex Williamson
2014-10-21 22:26 ` Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1413844443-28894-2-git-send-email-knut.omang@oracle.com \
--to=knut.omang@oracle.com \
--cc=agraf@suse.de \
--cc=aliguori@amazon.com \
--cc=andreas.faerber@web.de \
--cc=armbru@redhat.com \
--cc=hpoussin@reactos.org \
--cc=marcel.a@redhat.com \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=mjt@tls.msk.ru \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=rth@twiddle.net \
--cc=sw@weilnetz.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).