qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Auger <eric.auger@linaro.org>
To: eric.auger@st.com, christoffer.dall@linaro.org,
	qemu-devel@nongnu.org, agraf@suse.de, pbonzini@redhat.com,
	kim.phillips@freescale.com, a.rigo@virtualopensystems.com,
	manish.jaggi@caviumnetworks.com, joel.schopp@amd.com,
	zhaoshenglong@huawei.com, ard.biesheuvel@linaro.org
Cc: peter.maydell@linaro.org, patches@linaro.org,
	eric.auger@linaro.org, will.deacon@arm.com,
	stuart.yoder@freescale.com, Bharat.Bhushan@freescale.com,
	alex.williamson@redhat.com, a.motakis@virtualopensystems.com,
	kvmarm@lists.cs.columbia.edu
Subject: [Qemu-devel] [PATCH v8 14/19] hw/arm/virt: add support for VFIO devices
Date: Sun, 30 Nov 2014 18:35:19 +0000	[thread overview]
Message-ID: <1417372524-12936-15-git-send-email-eric.auger@linaro.org> (raw)
In-Reply-To: <1417372524-12936-1-git-send-email-eric.auger@linaro.org>

VFIO devices are dynamic sysbus devices. They could already be
instantiated. However for them to be functional, IRQ injection must
be programmed and started. This programming must happen after the
sysbus devices are attached to the platform bus and IRQ are bound.
Only at that time the GSI they are connected to are identified and
irqfd can be programmed.

Binding happens in a machine init done notifier registered by the
platform bus init. The IRQ start is done in a reset notifier.

This patchs adds the registration of the IRQ start notifier in machvirt.

Signed-off-by: Eric Auger <eric.auger@linaro.org>

---

v7 -> v8:
- vfio_kick_irqs replaces older vfio_register_irq_starter. The new
function registers a reset notifier while the older registered a
machine init done notifier.
- Given the fact platform_bus_first_irq has become part of a const
struct its handle cannot be passed as a void* to the reset notifier.
We now pass the interrupt DeviceState*.
- create_gic now returns the DeviceState handle of the gic so that it
can be passed to the reset notifier registration
---
 hw/arm/virt.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 37326a9..346b04a 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -44,6 +44,7 @@
 #include "qemu/error-report.h"
 #include "hw/arm/sysbus-fdt.h"
 #include "hw/platform-bus.h"
+#include "hw/vfio/vfio-platform.h"
 
 #define NUM_VIRTIO_TRANSPORTS 32
 
@@ -330,7 +331,7 @@ static void fdt_add_gic_node(const VirtBoardInfo *vbi)
     qemu_fdt_setprop_cell(vbi->fdt, "/intc", "phandle", gic_phandle);
 }
 
-static void create_gic(const VirtBoardInfo *vbi, qemu_irq *pic)
+static DeviceState *create_gic(const VirtBoardInfo *vbi, qemu_irq *pic)
 {
     /* We create a standalone GIC v2 */
     DeviceState *gicdev;
@@ -378,6 +379,7 @@ static void create_gic(const VirtBoardInfo *vbi, qemu_irq *pic)
     }
 
     fdt_add_gic_node(vbi);
+    return gicdev;
 }
 
 static void create_uart(const VirtBoardInfo *vbi, qemu_irq *pic)
@@ -537,7 +539,8 @@ static void create_flash(const VirtBoardInfo *vbi)
 }
 
 static void create_platform_bus(VirtBoardInfo *vbi, qemu_irq *pic,
-                                const ARMPlatformBusSystemParams *system_params)
+                                const ARMPlatformBusSystemParams *system_params,
+                                DeviceState *gic)
 {
     DeviceState *dev;
     SysBusDevice *s;
@@ -571,6 +574,9 @@ static void create_platform_bus(VirtBoardInfo *vbi, qemu_irq *pic,
     memory_region_add_subregion(sysmem,
                                 system_params->platform_bus_base,
                                 sysbus_mmio_get_region(s, 0));
+
+    /* setup VFIO signaling/IRQFD for all VFIO platform sysbus devices */
+    qemu_register_reset(vfio_kick_irqs, gic);
 }
 
 static void *machvirt_dtb(const struct arm_boot_info *binfo, int *fdt_size)
@@ -589,6 +595,7 @@ static void machvirt_init(MachineState *machine)
     MemoryRegion *ram = g_new(MemoryRegion, 1);
     const char *cpu_model = machine->cpu_model;
     VirtBoardInfo *vbi;
+    DeviceState *gic;
 
     if (!cpu_model) {
         cpu_model = "cortex-a15";
@@ -646,7 +653,7 @@ static void machvirt_init(MachineState *machine)
 
     create_flash(vbi);
 
-    create_gic(vbi, pic);
+    gic = create_gic(vbi, pic);
 
     create_uart(vbi, pic);
 
@@ -658,7 +665,7 @@ static void machvirt_init(MachineState *machine)
      */
     create_virtio_devices(vbi, pic);
 
-    create_platform_bus(vbi, pic, &platform_bus_params);
+    create_platform_bus(vbi, pic, &platform_bus_params, gic);
 
     vbi->bootinfo.ram_size = machine->ram_size;
     vbi->bootinfo.kernel_filename = machine->kernel_filename;
-- 
1.8.3.2

  parent reply	other threads:[~2014-11-30 18:36 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-30 18:35 [Qemu-devel] [PATCH v8 00/19] KVM platform device passthrough Eric Auger
2014-11-30 18:35 ` [Qemu-devel] [PATCH v8 01/19] vfio: move hw/misc/vfio.c to hw/vfio/pci.c Move vfio.h into include/hw/vfio Eric Auger
2014-11-30 18:35 ` [Qemu-devel] [PATCH v8 02/19] hw/vfio/pci: Rename VFIODevice into VFIOPCIDevice Eric Auger
2014-11-30 18:35 ` [Qemu-devel] [PATCH v8 03/19] hw/vfio/pci: generalize mask/unmask to any IRQ index Eric Auger
2014-11-30 18:35 ` [Qemu-devel] [PATCH v8 04/19] hw/vfio/pci: introduce minimalist VFIODevice with fd Eric Auger
2014-11-30 18:35 ` [Qemu-devel] [PATCH v8 05/19] hw/vfio/pci: add type, name and group fields in VFIODevice Eric Auger
2014-11-30 18:35 ` [Qemu-devel] [PATCH v8 06/19] hw/vfio/pci: handle reset at VFIODevice Eric Auger
2014-11-30 18:35 ` [Qemu-devel] [PATCH v8 07/19] hw/vfio/pci: Introduce VFIORegion Eric Auger
2014-11-30 18:35 ` [Qemu-devel] [PATCH v8 08/19] hw/vfio/pci: split vfio_get_device Eric Auger
2014-11-30 18:35 ` [Qemu-devel] [PATCH v8 09/19] hw/vfio/pci: rename group_list into vfio_group_list Eric Auger
2014-11-30 18:35 ` [Qemu-devel] [PATCH v8 10/19] hw/vfio/pci: use name field in format strings Eric Auger
2014-11-30 18:35 ` [Qemu-devel] [PATCH v8 11/19] hw/vfio: create common module Eric Auger
2014-11-30 18:35 ` [Qemu-devel] [PATCH v8 12/19] hw/vfio/platform: add vfio-platform support Eric Auger
2014-11-30 18:35 ` [Qemu-devel] [PATCH v8 13/19] hw/vfio: calxeda xgmac device Eric Auger
2014-11-30 18:35 ` Eric Auger [this message]
2014-11-30 18:35 ` [Qemu-devel] [PATCH v8 15/19] hw/arm/sysbus-fdt: enable vfio-calxeda-xgmac dynamic instantiation Eric Auger
2014-11-30 18:35 ` [Qemu-devel] [PATCH v8 16/19] hw/vfio/platform: Add irqfd support Eric Auger
2014-11-30 18:35 ` [Qemu-devel] [PATCH v8 17/19] linux-headers: Update KVM headers from linux-next tag ToBeFilled Eric Auger
2014-11-30 18:35 ` [Qemu-devel] [PATCH v8 18/19] hw/vfio/common: vfio_kvm_device_fd moved in the common header Eric Auger
2014-11-30 18:35 ` [Qemu-devel] [PATCH v8 19/19] hw/vfio/platform: add forwarded irq support Eric Auger
2014-12-08 17:04 ` [Qemu-devel] [PATCH v8 00/19] KVM platform device passthrough Alex Williamson
2014-12-08 17:35   ` Eric Auger

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=1417372524-12936-15-git-send-email-eric.auger@linaro.org \
    --to=eric.auger@linaro.org \
    --cc=Bharat.Bhushan@freescale.com \
    --cc=a.motakis@virtualopensystems.com \
    --cc=a.rigo@virtualopensystems.com \
    --cc=agraf@suse.de \
    --cc=alex.williamson@redhat.com \
    --cc=ard.biesheuvel@linaro.org \
    --cc=christoffer.dall@linaro.org \
    --cc=eric.auger@st.com \
    --cc=joel.schopp@amd.com \
    --cc=kim.phillips@freescale.com \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=manish.jaggi@caviumnetworks.com \
    --cc=patches@linaro.org \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stuart.yoder@freescale.com \
    --cc=will.deacon@arm.com \
    --cc=zhaoshenglong@huawei.com \
    /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).