qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: Eric Auger <eric.auger@linaro.org>
Cc: b.reynal@virtualopensystems.com, peter.maydell@linaro.org,
	kim.phillips@freescale.com, eric.auger@st.com,
	patches@linaro.org, qemu-devel@nongnu.org, agraf@suse.de,
	pbonzini@redhat.com, alex.bennee@linaro.org,
	kvmarm@lists.cs.columbia.edu, christoffer.dall@linaro.org,
	a.rigo@virtualopensystems.com
Subject: Re: [Qemu-devel] [PATCH v12 5/9] hw/arm/virt: start VFIO IRQ propagation
Date: Thu, 16 Apr 2015 16:05:35 -0600	[thread overview]
Message-ID: <1429221935.10086.39.camel@redhat.com> (raw)
In-Reply-To: <1426785402-2091-6-git-send-email-eric.auger@linaro.org>

On Thu, 2015-03-19 at 17:16 +0000, Eric Auger wrote:
> Although the dynamic instantiation of VFIO QEMU devices already is
> possible, VFIO IRQ signaling is not yet started. This patch enables
> IRQ forwarding by registering a reset notifier that kick off VFIO
> signaling for all VFIO devices.
> 
> Such mechanism is requested because the VFIO IRQ binding
> is handled in a machine init done notifier and only at that time the
> aboslute GSI number the physical IRQ is forwarded to is known.
> 
> Signed-off-by: Eric Auger <eric.auger@linaro.org>
> 
> v10 - v11:
> - becomes a separate patch
> ---
>  hw/arm/virt.c | 34 ++++++++++++++++++++--------------
>  1 file changed, 20 insertions(+), 14 deletions(-)


I would strongly discourage pushing vfio specific setup out to other
code.  If you look at existing vfio (and ignore the spapr mess), there's
not a single place where anybody else knows or cares about vfio.  It
seems like what you're looking for here is what we do on x86 with the
PCI INTx routing notifier.  vfio-pci and legacy KVM device assignment
may be the only users of that interface, but we've abstracted the
callback we're looking for rather than taking the quirk and dirty path
of dropping a vfio specific callback out in non-vfio code.


> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index 439739d..820b09d 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -45,6 +45,7 @@
>  #include "hw/pci-host/gpex.h"
>  #include "hw/arm/sysbus-fdt.h"
>  #include "hw/platform-bus.h"
> +#include "hw/vfio/vfio-platform.h"
>  
>  #define NUM_VIRTIO_TRANSPORTS 32
>  
> @@ -354,10 +355,10 @@ static uint32_t fdt_add_gic_node(const VirtBoardInfo *vbi)
>      return gic_phandle;
>  }
>  
> -static uint32_t create_gic(const VirtBoardInfo *vbi, qemu_irq *pic)
> +static uint32_t create_gic(const VirtBoardInfo *vbi, qemu_irq *pic,
> +                           DeviceState **gicdev)
>  {
>      /* We create a standalone GIC v2 */
> -    DeviceState *gicdev;
>      SysBusDevice *gicbusdev;
>      const char *gictype = "arm_gic";
>      int i;
> @@ -366,15 +367,15 @@ static uint32_t create_gic(const VirtBoardInfo *vbi, qemu_irq *pic)
>          gictype = "kvm-arm-gic";
>      }
>  
> -    gicdev = qdev_create(NULL, gictype);
> -    qdev_prop_set_uint32(gicdev, "revision", 2);
> -    qdev_prop_set_uint32(gicdev, "num-cpu", smp_cpus);
> +    *gicdev = qdev_create(NULL, gictype);
> +    qdev_prop_set_uint32(*gicdev, "revision", 2);
> +    qdev_prop_set_uint32(*gicdev, "num-cpu", smp_cpus);
>      /* Note that the num-irq property counts both internal and external
>       * interrupts; there are always 32 of the former (mandated by GIC spec).
>       */
> -    qdev_prop_set_uint32(gicdev, "num-irq", NUM_IRQS + 32);
> -    qdev_init_nofail(gicdev);
> -    gicbusdev = SYS_BUS_DEVICE(gicdev);
> +    qdev_prop_set_uint32(*gicdev, "num-irq", NUM_IRQS + 32);
> +    qdev_init_nofail(*gicdev);
> +    gicbusdev = SYS_BUS_DEVICE(*gicdev);
>      sysbus_mmio_map(gicbusdev, 0, vbi->memmap[VIRT_GIC_DIST].base);
>      sysbus_mmio_map(gicbusdev, 1, vbi->memmap[VIRT_GIC_CPU].base);
>  
> @@ -389,16 +390,16 @@ static uint32_t create_gic(const VirtBoardInfo *vbi, qemu_irq *pic)
>           * since a real A15 always has TrustZone but QEMU doesn't.
>           */
>          qdev_connect_gpio_out(cpudev, 0,
> -                              qdev_get_gpio_in(gicdev, ppibase + 30));
> +                              qdev_get_gpio_in(*gicdev, ppibase + 30));
>          /* virtual timer */
>          qdev_connect_gpio_out(cpudev, 1,
> -                              qdev_get_gpio_in(gicdev, ppibase + 27));
> +                              qdev_get_gpio_in(*gicdev, ppibase + 27));
>  
>          sysbus_connect_irq(gicbusdev, i, qdev_get_gpio_in(cpudev, ARM_CPU_IRQ));
>      }
>  
>      for (i = 0; i < NUM_IRQS; i++) {
> -        pic[i] = qdev_get_gpio_in(gicdev, i);
> +        pic[i] = qdev_get_gpio_in(*gicdev, i);
>      }
>  
>      return fdt_add_gic_node(vbi);
> @@ -719,7 +720,8 @@ static void create_pcie(const VirtBoardInfo *vbi, qemu_irq *pic,
>      g_free(nodename);
>  }
>  
> -static void create_platform_bus(VirtBoardInfo *vbi, qemu_irq *pic)
> +static void create_platform_bus(VirtBoardInfo *vbi, qemu_irq *pic,
> +                                DeviceState *gic)
>  {
>      DeviceState *dev;
>      SysBusDevice *s;
> @@ -758,6 +760,9 @@ static void create_platform_bus(VirtBoardInfo *vbi, qemu_irq *pic)
>      memory_region_add_subregion(sysmem,
>                                  platform_bus_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)
> @@ -779,6 +784,7 @@ static void machvirt_init(MachineState *machine)
>      VirtBoardInfo *vbi;
>      uint32_t gic_phandle;
>      char **cpustr;
> +    DeviceState *gicdev;
>  
>      if (!cpu_model) {
>          cpu_model = "cortex-a15";
> @@ -855,7 +861,7 @@ static void machvirt_init(MachineState *machine)
>  
>      create_flash(vbi);
>  
> -    gic_phandle = create_gic(vbi, pic);
> +    gic_phandle = create_gic(vbi, pic, &gicdev);
>  
>      create_uart(vbi, pic);
>  
> @@ -888,7 +894,7 @@ static void machvirt_init(MachineState *machine)
>       * another notifier is registered which adds platform bus nodes.
>       * Notifiers are executed in registration reverse order.
>       */
> -    create_platform_bus(vbi, pic);
> +    create_platform_bus(vbi, pic, gicdev);
>  }
>  
>  static bool virt_get_secure(Object *obj, Error **errp)

  reply	other threads:[~2015-04-16 22:05 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-19 17:16 [Qemu-devel] [PATCH v12 0/9] KVM platform device passthrough Eric Auger
2015-03-19 17:16 ` [Qemu-devel] [PATCH v12 1/9] linux-headers: update VFIO header for VFIO platform/amba drivers Eric Auger
2015-04-16 22:03   ` Alex Williamson
2015-03-19 17:16 ` [Qemu-devel] [PATCH v12 2/9] hw/vfio/platform: vfio-platform skeleton Eric Auger
2015-04-16 22:04   ` Alex Williamson
2015-03-19 17:16 ` [Qemu-devel] [PATCH v12 3/9] hw/vfio/platform: add irq assignment Eric Auger
2015-03-19 17:16 ` [Qemu-devel] [PATCH v12 4/9] hw/vfio/platform: add capability to start IRQ propagation Eric Auger
2015-04-16 22:04   ` Alex Williamson
2015-04-17 15:31     ` Eric Auger
2015-04-17 19:41       ` Alex Williamson
2015-04-21  8:42         ` [Qemu-devel] [question] Clean way to retrieve the gsi of a sysbus device qemu_irq? Eric Auger
2015-04-21 11:54         ` [Qemu-devel] [PATCH v12 4/9] hw/vfio/platform: add capability to start IRQ propagation Eric Auger
2015-03-19 17:16 ` [Qemu-devel] [PATCH v12 5/9] hw/arm/virt: start VFIO " Eric Auger
2015-04-16 22:05   ` Alex Williamson [this message]
2015-03-19 17:16 ` [Qemu-devel] [PATCH v12 6/9] hw/vfio/platform: calxeda xgmac device Eric Auger
2015-03-19 17:16 ` [Qemu-devel] [PATCH v12 7/9] hw/arm/sysbus-fdt: enable vfio-calxeda-xgmac dynamic instantiation Eric Auger
2015-04-24 22:35   ` Vikram Sethi
2015-04-27  9:19     ` Eric Auger
2015-03-19 17:16 ` [Qemu-devel] [PATCH v12 8/9] linux-headers: update arm/arm64 KVM headers for irqfd Eric Auger
2015-03-19 17:16 ` [Qemu-devel] [PATCH v12 9/9] hw/vfio/platform: add irqfd support 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=1429221935.10086.39.camel@redhat.com \
    --to=alex.williamson@redhat.com \
    --cc=a.rigo@virtualopensystems.com \
    --cc=agraf@suse.de \
    --cc=alex.bennee@linaro.org \
    --cc=b.reynal@virtualopensystems.com \
    --cc=christoffer.dall@linaro.org \
    --cc=eric.auger@linaro.org \
    --cc=eric.auger@st.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 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).