All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Auger <eric.auger@linaro.org>
To: eric.auger@st.com, eric.auger@linaro.org,
	christoffer.dall@linaro.org, qemu-devel@nongnu.org,
	alex.williamson@redhat.com, peter.maydell@linaro.org,
	agraf@suse.de, b.reynal@virtualopensystems.com,
	feng.wu@intel.com
Cc: kim.phillips@freescale.com, patches@linaro.org,
	a.rigo@virtualopensystems.com, afaerber@suse.de,
	Bharat.Bhushan@freescale.com, a.motakis@virtualopensystems.com,
	pbonzini@redhat.com, kvmarm@lists.cs.columbia.edu
Subject: [Qemu-devel] [PATCH v10 4/7] hw/vfio/platform: add capability to start IRQ propagation
Date: Fri, 13 Feb 2015 03:47:09 +0000	[thread overview]
Message-ID: <1423799232-10816-5-git-send-email-eric.auger@linaro.org> (raw)
In-Reply-To: <1423799232-10816-1-git-send-email-eric.auger@linaro.org>

Add a reset notify function that enables to start the propagation of
interrupts to the guest.

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

---

v8 -> v9:
- handle failure in vfio_irq_starter
---
 hw/vfio/platform.c              | 52 +++++++++++++++++++++++++++++++++++++++++
 include/hw/vfio/vfio-platform.h |  8 +++++++
 2 files changed, 60 insertions(+)

diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c
index b85ad6c..30798d8 100644
--- a/hw/vfio/platform.c
+++ b/hw/vfio/platform.c
@@ -553,6 +553,58 @@ static void vfio_platform_realize(DeviceState *dev, Error **errp)
     }
 }
 
+/*
+ * Binding to the platform bus IRQ happens on a machine init done
+ * notifier registered by the platform bus. Only at that time the
+ * absolute virtual IRQ = GSI is known and allows to setup IRQFD.
+ * vfio_kick_irqs can typically be used as a reset notifier function.
+ */
+
+/* Start injection of IRQ for a specific VFIO device */
+static int vfio_irq_starter(SysBusDevice *sbdev, void *opaque)
+{
+    DeviceState *intc = (DeviceState *)opaque;
+    VFIOPlatformDevice *vdev;
+    VFIOINTp *intp;
+    qemu_irq irq;
+    int gsi, ret;
+
+    if (object_dynamic_cast(OBJECT(sbdev), TYPE_VFIO_PLATFORM)) {
+        vdev = VFIO_PLATFORM_DEVICE(sbdev);
+
+        QLIST_FOREACH(intp, &vdev->intp_list, next) {
+            gsi = 0;
+            while (1) {
+                irq = qdev_get_gpio_in(intc, gsi);
+                if (irq == intp->qemuirq) {
+                    break;
+                }
+                gsi++;
+            }
+            intp->virtualID = gsi;
+            ret = vdev->start_irq_fn(intp);
+            if (ret) {
+                error_report("%s unable to start propagation of IRQ index %d",
+                             vdev->vbasedev.name, intp->pin);
+                exit(1);
+            }
+        }
+    }
+    return 0;
+}
+
+/* loop on all VFIO platform devices and start their IRQ injection */
+void vfio_kick_irqs(void *data)
+{
+    DeviceState *intc = (DeviceState *)data;
+    DeviceState *dev =
+        qdev_find_recursive(sysbus_get_default(), TYPE_PLATFORM_BUS_DEVICE);
+    PlatformBusDevice *pbus = PLATFORM_BUS_DEVICE(dev);
+
+    assert(pbus->done_gathering);
+    foreach_dynamic_sysbus_device(vfio_irq_starter, intc);
+}
+
 static const VMStateDescription vfio_platform_vmstate = {
     .name = TYPE_VFIO_PLATFORM,
     .unmigratable = 1,
diff --git a/include/hw/vfio/vfio-platform.h b/include/hw/vfio/vfio-platform.h
index e55b711..bd1206e 100644
--- a/include/hw/vfio/vfio-platform.h
+++ b/include/hw/vfio/vfio-platform.h
@@ -74,4 +74,12 @@ typedef struct VFIOPlatformDeviceClass {
 #define VFIO_PLATFORM_DEVICE_GET_CLASS(obj) \
      OBJECT_GET_CLASS(VFIOPlatformDeviceClass, (obj), TYPE_VFIO_PLATFORM)
 
+/**
+ * vfio_kick_irqs - reset notifier that starts IRQ injection
+ * for all VFIO dynamic sysbus devices attached to the platform bus.
+ *
+ * @opaque: handle to the interrupt controller DeviceState*
+ */
+void vfio_kick_irqs(void *opaque);
+
 #endif /*HW_VFIO_VFIO_PLATFORM_H*/
-- 
1.8.3.2

  parent reply	other threads:[~2015-02-13  3:47 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-13  3:47 [Qemu-devel] [PATCH v10 0/7] KVM platform device passthrough Eric Auger
2015-02-13  3:47 ` [Qemu-devel] [PATCH v10 1/7] linux-headers: update VFIO header for VFIO platform drivers Eric Auger
2015-02-13  3:47 ` [Qemu-devel] [PATCH v10 2/7] hw/vfio/platform: vfio-platform skeleton Eric Auger
2015-02-17 10:56   ` Alex Bennée
2015-02-17 10:56     ` Alex Bennée
2015-03-13  9:28     ` [Qemu-devel] " Eric Auger
2015-03-13  9:28       ` Eric Auger
2015-02-13  3:47 ` [Qemu-devel] [PATCH v10 3/7] hw/vfio/platform: add irq assignment Eric Auger
2015-02-17 11:24   ` Alex Bennée
2015-02-17 11:24     ` Alex Bennée
2015-03-19 10:18     ` [Qemu-devel] " Eric Auger
2015-03-19 10:18       ` Eric Auger
2015-02-13  3:47 ` Eric Auger [this message]
2015-02-13  3:47 ` [Qemu-devel] [PATCH v10 5/7] hw/vfio: calxeda xgmac device Eric Auger
2015-02-17 11:29   ` Alex Bennée
2015-02-17 11:29     ` Alex Bennée
2015-02-13  3:47 ` [Qemu-devel] [PATCH v10 6/7] hw/arm/sysbus-fdt: enable vfio-calxeda-xgmac dynamic instantiation Eric Auger
2015-02-17 11:36   ` Alex Bennée
2015-02-17 11:36     ` Alex Bennée
2015-03-13  9:33     ` [Qemu-devel] " Eric Auger
2015-03-13  9:33       ` Eric Auger
2015-02-13  3:47 ` [Qemu-devel] [PATCH v10 7/7] hw/vfio/platform: add irqfd support Eric Auger
2015-02-17 11:41   ` Alex Bennée
2015-02-17 11:41     ` Alex Bennée

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=1423799232-10816-5-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=afaerber@suse.de \
    --cc=agraf@suse.de \
    --cc=alex.williamson@redhat.com \
    --cc=b.reynal@virtualopensystems.com \
    --cc=christoffer.dall@linaro.org \
    --cc=eric.auger@st.com \
    --cc=feng.wu@intel.com \
    --cc=kim.phillips@freescale.com \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=patches@linaro.org \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /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.