]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
RISC-V: KVM: Don't setup SGEI for zero guest external interrupts
authorAnup Patel <apatel@ventanamicro.com>
Sun, 20 Oct 2024 19:47:27 +0000 (01:17 +0530)
committerAnup Patel <anup@brainfault.org>
Mon, 28 Oct 2024 11:13:53 +0000 (16:43 +0530)
No need to setup SGEI local interrupt when there are zero guest
external interrupts (i.e. zero HW IMSIC guest files).

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Reviewed-by: Atish Patra <atishp@rivosinc.com>
Link: https://lore.kernel.org/r/20241020194734.58686-7-apatel@ventanamicro.com
Signed-off-by: Anup Patel <anup@brainfault.org>
arch/riscv/kvm/aia.c

index 17ae4a7c0e948e544cc2884b19e38c80040f8df2..8ffae0330c89a4e8ffaf71bd03421f2aed6d0926 100644 (file)
@@ -499,6 +499,10 @@ static int aia_hgei_init(void)
                        hgctrl->free_bitmap = 0;
        }
 
+       /* Skip SGEI interrupt setup for zero guest external interrupts */
+       if (!kvm_riscv_aia_nr_hgei)
+               goto skip_sgei_interrupt;
+
        /* Find INTC irq domain */
        domain = irq_find_matching_fwnode(riscv_get_intc_hwnode(),
                                          DOMAIN_BUS_ANY);
@@ -522,11 +526,16 @@ static int aia_hgei_init(void)
                return rc;
        }
 
+skip_sgei_interrupt:
        return 0;
 }
 
 static void aia_hgei_exit(void)
 {
+       /* Do nothing for zero guest external interrupts */
+       if (!kvm_riscv_aia_nr_hgei)
+               return;
+
        /* Free per-CPU SGEI interrupt */
        free_percpu_irq(hgei_parent_irq, &aia_hgei);
 }