Re: [PATCH v2 05/13] hw/riscv/fdt_common, virt.c: add create_fdt_imsic()

Philippe Mathieu-Daudé <[email protected]>
Newsgroups org.nongnu.qemu-riscv,org.nongnu.qemu-devel
Message-ID <[email protected]>
On 26/8/26 18:48, Daniel Henrique Barboza wrote:
> The FDT related to interrupt controllers should definitely be put into
> helpers, even if only 'virt' benefits from it, due to the amount of code
> that is relieved from the board alone.  We'll start with 'imsic'.
> 
> For this endeavor we're going to use a helper struct that will carry all
> the extra FDT arguments in a human format.  The alternative would be to
> add 8 more function arguments, on top of 4 phandle arguments that we're
> passing around in all these controllers, and that's not only a poor
> reading experience but it's quite error prone too.
> 
> We do not want to crowd the fdt-helper with non-FDT logic, hence we're
> handling the !kvm_enabled() cond in virt.c using the imsic_m_base
> argument.  This is a pattern that we'll fall back on in the next
> patches too.
> 
> No FDT changes made.
> 
> Signed-off-by: Daniel Henrique Barboza <[email protected]>
> ---
>   hw/riscv/fdt-common.c         |  94 ++++++++++++++++++++++++++++++
>   hw/riscv/virt.c               | 104 ++++------------------------------
>   include/hw/riscv/fdt-common.h |  22 +++++++
>   3 files changed, 128 insertions(+), 92 deletions(-)


> @@ -583,8 +492,19 @@ static void create_fdt_sockets(RISCVVirtState *s,
>       }
>   
>       if (s->aia_type == VIRT_AIA_TYPE_APLIC_IMSIC) {
> -        create_fdt_imsic(s, phandle, intc_phandles,
> +        IMSICFdtProps props = {
> +            .soc = &s->soc,

New line please.

> .socket_count = riscv_socket_count(ms),
> +            .smp_cpus = ms->smp.cpus,
> +            .imsic_m_base = !kvm_enabled() ? s->memmap[VIRT_IMSIC_M].base : 0,
> +            .imsic_s_base = s->memmap[VIRT_IMSIC_S].base,
> +            .imsic_group_max_size = VIRT_IMSIC_GROUP_MAX_SIZE,
> +            .irqchip_num_msis = VIRT_IRQCHIP_NUM_MSIS,
> +            .aia_guests = s->aia_guests
> +        };
> +
> +        create_fdt_imsic(ms->fdt, &props, phandle, intc_phandles,
>                            &msi_m_phandle, &msi_s_phandle);
> +
>           *msi_pcie_phandle = msi_s_phandle;
>       }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.