All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Marcel Apfelbaum <marcel@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Richard Henderson <rth@twiddle.net>,
	Eduardo Habkost <ehabkost@redhat.com>
Subject: [Qemu-devel] [PULL 05/36] hw/iommu: enable iommu with -device
Date: Mon, 4 Jul 2016 19:46:23 +0300	[thread overview]
Message-ID: <20160704194623-mutt-send-email-mst@redhat.com> (raw)
In-Reply-To: <1467650742-17580-1-git-send-email-mst@redhat.com>

From: Marcel Apfelbaum <marcel@redhat.com>

Use the standard '-device intel-iommu' to create the IOMMU device.
The legacy '-machine,iommu=on' can still be used.

Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/i386/intel_iommu.c | 16 ++++++++++++++++
 hw/i386/pc_q35.c      |  1 -
 hw/pci-host/q35.c     | 17 +----------------
 3 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index 5eba704..464f2a0 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -25,6 +25,7 @@
 #include "intel_iommu_internal.h"
 #include "hw/pci/pci.h"
 #include "hw/pci/pci_bus.h"
+#include "hw/i386/pc.h"
 
 /*#define DEBUG_INTEL_IOMMU*/
 #ifdef DEBUG_INTEL_IOMMU
@@ -2026,8 +2027,20 @@ static void vtd_reset(DeviceState *dev)
     vtd_init(s);
 }
 
+static AddressSpace *vtd_host_dma_iommu(PCIBus *bus, void *opaque, int devfn)
+{
+    IntelIOMMUState *s = opaque;
+    VTDAddressSpace *vtd_as;
+
+    assert(0 <= devfn && devfn <= VTD_PCI_DEVFN_MAX);
+
+    vtd_as = vtd_find_add_as(s, bus, devfn);
+    return &vtd_as->as;
+}
+
 static void vtd_realize(DeviceState *dev, Error **errp)
 {
+    PCIBus *bus = PC_MACHINE(qdev_get_machine())->bus;
     IntelIOMMUState *s = INTEL_IOMMU_DEVICE(dev);
 
     VTD_DPRINTF(GENERAL, "");
@@ -2041,6 +2054,8 @@ static void vtd_realize(DeviceState *dev, Error **errp)
     s->vtd_as_by_busptr = g_hash_table_new_full(vtd_uint64_hash, vtd_uint64_equal,
                                               g_free, g_free);
     vtd_init(s);
+    sysbus_mmio_map(SYS_BUS_DEVICE(s), 0, Q35_HOST_BRIDGE_IOMMU_ADDR);
+    pci_setup_iommu(bus, vtd_host_dma_iommu, dev);
 }
 
 static void vtd_class_init(ObjectClass *klass, void *data)
@@ -2051,6 +2066,7 @@ static void vtd_class_init(ObjectClass *klass, void *data)
     dc->realize = vtd_realize;
     dc->vmsd = &vtd_vmstate;
     dc->props = vtd_properties;
+    dc->hotpluggable = false;
 }
 
 static const TypeInfo vtd_info = {
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index fbaf2e6..c0b9961 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -179,7 +179,6 @@ static void pc_q35_init(MachineState *machine)
     qdev_init_nofail(DEVICE(q35_host));
     phb = PCI_HOST_BRIDGE(q35_host);
     host_bus = phb->bus;
-    pcms->bus = phb->bus;
     /* create ISA bus */
     lpc = pci_create_simple_multifunction(host_bus, PCI_DEVFN(ICH9_LPC_DEV,
                                           ICH9_LPC_FUNC), true,
diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
index 0150039..8d060a5 100644
--- a/hw/pci-host/q35.c
+++ b/hw/pci-host/q35.c
@@ -52,6 +52,7 @@ static void q35_host_realize(DeviceState *dev, Error **errp)
     pci->bus = pci_bus_new(DEVICE(s), "pcie.0",
                            s->mch.pci_address_space, s->mch.address_space_io,
                            0, TYPE_PCIE_BUS);
+    PC_MACHINE(qdev_get_machine())->bus = pci->bus;
     qdev_set_parent_bus(DEVICE(&s->mch), BUS(pci->bus));
     qdev_init_nofail(DEVICE(&s->mch));
 }
@@ -446,28 +447,12 @@ static void mch_reset(DeviceState *qdev)
     mch_update(mch);
 }
 
-static AddressSpace *q35_host_dma_iommu(PCIBus *bus, void *opaque, int devfn)
-{
-    IntelIOMMUState *s = opaque;
-    VTDAddressSpace *vtd_as;
-
-    assert(0 <= devfn && devfn <= VTD_PCI_DEVFN_MAX);
-
-    vtd_as = vtd_find_add_as(s, bus, devfn);
-    return &vtd_as->as;
-}
-
 static void mch_init_dmar(MCHPCIState *mch)
 {
-    PCIBus *pci_bus = PCI_BUS(qdev_get_parent_bus(DEVICE(mch)));
-
     mch->iommu = INTEL_IOMMU_DEVICE(qdev_create(NULL, TYPE_INTEL_IOMMU_DEVICE));
     object_property_add_child(OBJECT(mch), "intel-iommu",
                               OBJECT(mch->iommu), NULL);
     qdev_init_nofail(DEVICE(mch->iommu));
-    sysbus_mmio_map(SYS_BUS_DEVICE(mch->iommu), 0, Q35_HOST_BRIDGE_IOMMU_ADDR);
-
-    pci_setup_iommu(pci_bus, q35_host_dma_iommu, mch->iommu);
 }
 
 static void mch_realize(PCIDevice *d, Error **errp)
-- 
MST

  parent reply	other threads:[~2016-07-04 16:46 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
2016-07-04 16:46 ` [Qemu-devel] [PULL 01/36] xen: fix ram init regression Michael S. Tsirkin
2016-07-04 16:46   ` Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 02/36] hw/ppc: realize the PCI root bus as part of mac99 init Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 03/36] hw/pci: delay bus_master_enable_region initialization Michael S. Tsirkin
2016-07-09  1:34   ` Mark Cave-Ayland
2016-07-09  7:07     ` Marcel Apfelbaum
2016-07-09  9:09       ` Mark Cave-Ayland
2016-07-11 14:42   ` Leon Alrae
2016-07-11 15:18     ` Marcel Apfelbaum
2016-07-11 18:41       ` Mark Cave-Ayland
2016-07-14 12:40         ` Marcel Apfelbaum
2016-07-04 16:46 ` [Qemu-devel] [PULL 04/36] q35: allow dynamic sysbus Michael S. Tsirkin
2016-07-04 16:46 ` Michael S. Tsirkin [this message]
2016-07-04 16:46 ` [Qemu-devel] [PULL 06/36] machine: remove iommu property Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 07/36] piix: Set I440FXState member pci_info.w32 in one place Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 08/36] pc: Eliminate PcPciInfo Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 09/36] virtio: revert host notifiers to old semantics Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 10/36] virtio: set low features early on load Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 11/36] Revert "virtio-net: unbreak self announcement and guest offloads after migration" Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 12/36] pci_register_bar: cleanup Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 13/36] log: Clean up misuse of Range for -dfilter Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 14/36] range: Eliminate direct Range member access Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 15/36] range: Replace internal representation of Range Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 16/36] log: Permit -dfilter 0..0xffffffffffffffff Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 17/36] tests: acpi: add CPU hotplug testcase Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 18/36] tests: add APIC.cphp and DSDT.cphp blobs Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 19/36] tests/acpi: add pxb/pxb-pcie tests Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 20/36] hw/pxb: declare pxb devices as not hot-pluggable Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 21/36] hw/acpi: fix a DSDT table issue when a pxb is present Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 22/36] acpi: refactor pxb crs computation Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 23/36] hw/apci: handle 64-bit MMIO regions correctly Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 24/36] tests/acpi: Add pxb/pxb-pcie tests blobs Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 25/36] change pvscsi_init_msi() type to void Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 26/36] usb xhci: change msi/msix property type Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 27/36] intel-hda: change msi " Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 28/36] mptsas: " Michael S. Tsirkin
2016-07-04 16:48 ` [Qemu-devel] [PULL 29/36] megasas: change msi/msix " Michael S. Tsirkin
2016-07-04 16:48 ` [Qemu-devel] [PULL 30/36] pci bridge dev: change msi " Michael S. Tsirkin
2016-07-04 16:48 ` [Qemu-devel] [PULL 31/36] pci: Convert msi_init() to Error and fix callers to check it Michael S. Tsirkin
2016-07-04 16:48 ` [Qemu-devel] [PULL 32/36] megasas: remove unnecessary megasas_use_msi() Michael S. Tsirkin
2016-07-04 16:48 ` [Qemu-devel] [PULL 33/36] mptsas: remove unnecessary internal msi state flag Michael S. Tsirkin
2016-07-04 16:48 ` [Qemu-devel] [PULL 34/36] vmxnet3: " Michael S. Tsirkin
2016-07-04 16:48 ` [Qemu-devel] [PULL 35/36] e1000e: " Michael S. Tsirkin
2016-07-04 16:48 ` [Qemu-devel] [PULL 36/36] vmw_pvscsi: " 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=20160704194623-mutt-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=marcel@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.