[PATCH 3/8] hw/riscv/virt.c: rename helper to virt_use_kvm_aia_aplic_imsic()

Daniel Henrique Barboza posted 8 patches 1 month, 2 weeks ago
There is a newer version of this series
[PATCH 3/8] hw/riscv/virt.c: rename helper to virt_use_kvm_aia_aplic_imsic()
Posted by Daniel Henrique Barboza 1 month, 2 weeks ago
Similar to the riscv_is_kvm_aia_aplic_imsic() helper from riscv_aplic.c,
the existing virt_use_kvm_aia() is testing for KVM aia=aplic-imsic with
in-kernel irqchip enabled. It is not checking for a generic AIA support.

Rename the helper to virt_use_kvm_aia_aplic_imsic() to reflect what the
helper is doing, and use the existing riscv_is_kvm_aia_aplic_imsic() to
obscure details such as the presence of the in-kernel irqchip.

Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
---
 hw/riscv/virt.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
index b5bdbb34e0..f1bdc1c535 100644
--- a/hw/riscv/virt.c
+++ b/hw/riscv/virt.c
@@ -57,9 +57,11 @@
 #include "hw/virtio/virtio-iommu.h"
 
 /* KVM AIA only supports APLIC MSI. APLIC Wired is always emulated by QEMU. */
-static bool virt_use_kvm_aia(RISCVVirtState *s)
+static bool virt_use_kvm_aia_aplic_imsic(RISCVVirtAIAType aia_type)
 {
-    return kvm_irqchip_in_kernel() && s->aia_type == VIRT_AIA_TYPE_APLIC_IMSIC;
+    bool msimode = aia_type == VIRT_AIA_TYPE_APLIC_IMSIC;
+
+    return riscv_is_kvm_aia_aplic_imsic(msimode);
 }
 
 static bool virt_aclint_allowed(void)
@@ -774,8 +776,8 @@ static void create_fdt_sockets(RISCVVirtState *s, const MemMapEntry *memmap,
         *msi_pcie_phandle = msi_s_phandle;
     }
 
-    /* KVM AIA only has one APLIC instance */
-    if (kvm_enabled() && virt_use_kvm_aia(s)) {
+    /* KVM AIA aplic-imsic only has one APLIC instance */
+    if (kvm_enabled() && virt_use_kvm_aia_aplic_imsic(s->aia_type)) {
         create_fdt_socket_aplic(s, memmap, 0,
                                 msi_m_phandle, msi_s_phandle, phandle,
                                 &intc_phandles[0], xplic_phandles,
@@ -1540,7 +1542,7 @@ static void virt_machine_init(MachineState *machine)
         }
     }
 
-    if (kvm_enabled() && virt_use_kvm_aia(s)) {
+    if (kvm_enabled() && virt_use_kvm_aia_aplic_imsic(s->aia_type)) {
         kvm_riscv_aia_create(machine, IMSIC_MMIO_GROUP_MIN_SHIFT,
                              VIRT_IRQCHIP_NUM_SOURCES, VIRT_IRQCHIP_NUM_MSIS,
                              memmap[VIRT_APLIC_S].base,
-- 
2.45.2
Re: [PATCH 3/8] hw/riscv/virt.c: rename helper to virt_use_kvm_aia_aplic_imsic()
Posted by Alistair Francis 5 days, 22 hours ago
On Fri, Oct 11, 2024 at 5:04 AM Daniel Henrique Barboza
<dbarboza@ventanamicro.com> wrote:
>
> Similar to the riscv_is_kvm_aia_aplic_imsic() helper from riscv_aplic.c,
> the existing virt_use_kvm_aia() is testing for KVM aia=aplic-imsic with
> in-kernel irqchip enabled. It is not checking for a generic AIA support.
>
> Rename the helper to virt_use_kvm_aia_aplic_imsic() to reflect what the
> helper is doing, and use the existing riscv_is_kvm_aia_aplic_imsic() to
> obscure details such as the presence of the in-kernel irqchip.
>
> Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  hw/riscv/virt.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
> index b5bdbb34e0..f1bdc1c535 100644
> --- a/hw/riscv/virt.c
> +++ b/hw/riscv/virt.c
> @@ -57,9 +57,11 @@
>  #include "hw/virtio/virtio-iommu.h"
>
>  /* KVM AIA only supports APLIC MSI. APLIC Wired is always emulated by QEMU. */
> -static bool virt_use_kvm_aia(RISCVVirtState *s)
> +static bool virt_use_kvm_aia_aplic_imsic(RISCVVirtAIAType aia_type)
>  {
> -    return kvm_irqchip_in_kernel() && s->aia_type == VIRT_AIA_TYPE_APLIC_IMSIC;
> +    bool msimode = aia_type == VIRT_AIA_TYPE_APLIC_IMSIC;
> +
> +    return riscv_is_kvm_aia_aplic_imsic(msimode);
>  }
>
>  static bool virt_aclint_allowed(void)
> @@ -774,8 +776,8 @@ static void create_fdt_sockets(RISCVVirtState *s, const MemMapEntry *memmap,
>          *msi_pcie_phandle = msi_s_phandle;
>      }
>
> -    /* KVM AIA only has one APLIC instance */
> -    if (kvm_enabled() && virt_use_kvm_aia(s)) {
> +    /* KVM AIA aplic-imsic only has one APLIC instance */
> +    if (kvm_enabled() && virt_use_kvm_aia_aplic_imsic(s->aia_type)) {
>          create_fdt_socket_aplic(s, memmap, 0,
>                                  msi_m_phandle, msi_s_phandle, phandle,
>                                  &intc_phandles[0], xplic_phandles,
> @@ -1540,7 +1542,7 @@ static void virt_machine_init(MachineState *machine)
>          }
>      }
>
> -    if (kvm_enabled() && virt_use_kvm_aia(s)) {
> +    if (kvm_enabled() && virt_use_kvm_aia_aplic_imsic(s->aia_type)) {
>          kvm_riscv_aia_create(machine, IMSIC_MMIO_GROUP_MIN_SHIFT,
>                               VIRT_IRQCHIP_NUM_SOURCES, VIRT_IRQCHIP_NUM_MSIS,
>                               memmap[VIRT_APLIC_S].base,
> --
> 2.45.2
>
>