[PATCH] hw/intc/arm_gicv3_kvm.c: Set the qemu_irq/gsi mapping for VFIO platform

Luca Wei posted 1 patch 7 months, 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/2FDAC4096138FA4DB2F2BDCE0F9521C00182151E@SHASXM06.verisilicon.com
Maintainers: Peter Maydell <peter.maydell@linaro.org>
hw/intc/arm_gicv3_kvm.c | 5 +++++
1 file changed, 5 insertions(+)
[PATCH] hw/intc/arm_gicv3_kvm.c: Set the qemu_irq/gsi mapping for VFIO platform
Posted by Luca Wei 7 months, 2 weeks ago
Eric added the qemu_irq/gsi hash table to let VFIO platform device
setup irqfd when kvm enabled [1]. And he setup the qemu_irq/gsi
mapping in arm_gic_kvm.c [2]. But this mapping is not setting up in
arm_gicv3_kvm.c. When VM use VFIO platform device with gicv3,
the irqfd setup will fail and fallback to userspace handled eventfd
in `vfio_start_irqfd_injection`.

This patch will setup the qemu_irq/gsi mapping for gicv3, so that
VFIO platform device with gicv3 can use kvm irqfd to accelerate.

[1] https://lore.kernel.org/qemu-devel/20150706183506.15635.61812.stgit@gimli.home/
[2] https://lore.kernel.org/qemu-devel/20150706183512.15635.915.stgit@gimli.home/

Signed-off-by: Luca Wei <Luca.Wei@verisilicon.com>
---
 hw/intc/arm_gicv3_kvm.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c
index 72ad916d3d..7e90f8b723 100644
--- a/hw/intc/arm_gicv3_kvm.c
+++ b/hw/intc/arm_gicv3_kvm.c
@@ -807,6 +807,11 @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp)

     gicv3_init_irqs_and_mmio(s, kvm_arm_gicv3_set_irq, NULL);

+    for (i = 0; i < s->num_irq - GIC_INTERNAL; i++) {
+        qemu_irq irq = qdev_get_gpio_in(dev, i);
+        kvm_irqchip_set_qemuirq_gsi(kvm_state, irq, i);
+    }
+
     for (i = 0; i < s->num_cpu; i++) {
         ARMCPU *cpu = ARM_CPU(qemu_get_cpu(i));

--
2.41.0.windows.3
Re: [PATCH] hw/intc/arm_gicv3_kvm.c: Set the qemu_irq/gsi mapping for VFIO platform
Posted by Eric Auger 6 months, 4 weeks ago
Hi Luca,
On 9/19/23 08:56, Luca Wei wrote:
> Eric added the qemu_irq/gsi hash table to let VFIO platform device
> setup irqfd when kvm enabled [1]. And he setup the qemu_irq/gsi
> mapping in arm_gic_kvm.c [2]. But this mapping is not setting up in
> arm_gicv3_kvm.c. When VM use VFIO platform device with gicv3,
> the irqfd setup will fail and fallback to userspace handled eventfd
> in `vfio_start_irqfd_injection`.

sorry your patch fell through the cracks :-(

I would drop "for VFIO platform" in the commit title and any mention to
"platform" in the message as I think this is likely to be used in PCI no
MSI mode. I am surprised we haven't noticed before tbh.

Also please directly mention the GICv2 patch instead of the email refs
below:
6a1a9cfa1c4a ("ntc: arm_gic_kvm: set the qemu_irq/gsi mapping")

Also this does not sound a Stable patch to me.

Thanks

Eric


> 
> This patch will setup the qemu_irq/gsi mapping for gicv3, so that
> VFIO platform device with gicv3 can use kvm irqfd to accelerate.
> 
> [1] https://lore.kernel.org/qemu-devel/20150706183506.15635.61812.stgit@gimli.home/
> [2] https://lore.kernel.org/qemu-devel/20150706183512.15635.915.stgit@gimli.home/


> 
> Signed-off-by: Luca Wei <Luca.Wei@verisilicon.com>
> ---
>  hw/intc/arm_gicv3_kvm.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c
> index 72ad916d3d..7e90f8b723 100644
> --- a/hw/intc/arm_gicv3_kvm.c
> +++ b/hw/intc/arm_gicv3_kvm.c
> @@ -807,6 +807,11 @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp)
> 
>      gicv3_init_irqs_and_mmio(s, kvm_arm_gicv3_set_irq, NULL);
> 
> +    for (i = 0; i < s->num_irq - GIC_INTERNAL; i++) {
> +        qemu_irq irq = qdev_get_gpio_in(dev, i);
> +        kvm_irqchip_set_qemuirq_gsi(kvm_state, irq, i);
> +    }
> +
>      for (i = 0; i < s->num_cpu; i++) {
>          ARMCPU *cpu = ARM_CPU(qemu_get_cpu(i));
> 
> --
> 2.41.0.windows.3
>