Re: [PATCH v7 3/5] irqchip/riscv-imsic: Add MSI address list
From: Jason Gunthorpe
Date: Wed Dec 02 2026 - 13:00:20 EST
> Upcoming RISC-V IOMMU interrupt remapping needs to map every possible
> host IMSIC target into one contiguous MSI IOVA range. MSI message
> composition then uses the target CPU's position within that range.
>
> Build an IMSIC physical address array indexed by logical CPU.
> Require every possible CPU to have an initialized IMSIC page before
> publishing the array. This preserves physical address zero as a valid
> target and guarantees the array has num_possible_cpus() entries.
>
> The array size and each target's index can therefore be derived
> directly, without storing duplicate count or per-CPU index metadata.
>
> Signed-off-by: Andrew Jones <andrew.jones@xxxxxxxxxxxxxxxx>
> Signed-off-by: Andrew Jones <andrew.jones@xxxxxxxxx>
> Tested-by: Fangyu Yu <fangyu.yu@xxxxxxxxxxxxxxxxx>
> Acked-by: Thomas Gleixner <tglx@xxxxxxxxxx>
> Reviewed-by: Nutty Liu <nutty.liu@xxxxxxxxxxx>
> Reviewed-by: Anup Patel <anup@xxxxxxxxxxxxxx>
> Acked-by: Anup Patel <anup@xxxxxxxxxxxxxx>
> ---
> drivers/irqchip/irq-riscv-imsic-state.c | 32 +++++++++++++++++++++++++
> drivers/irqchip/irq-riscv-imsic-state.h | 3 +++
> 2 files changed, 35 insertions(+)
Not sure what to make of the Sashiko comments, but the overall notion
seems OK
Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxx>
> diff --git a/drivers/irqchip/irq-riscv-imsic-state.c b/drivers/irqchip/irq-riscv-imsic-state.c
> index 960c71d6295ba8..e12392c170e6d7 100644
> --- a/drivers/irqchip/irq-riscv-imsic-state.c
> +++ b/drivers/irqchip/irq-riscv-imsic-state.c
> @@ -688,6 +688,31 @@ static int __init imsic_get_mmio_resource(struct fwnode_handle *fwnode,
> return of_address_to_resource(to_of_node(fwnode), index, res);
> }
>
> +static int __init imsic_init_msi_pa_list(void)
> +{
> + struct imsic_global_config *global = &imsic->global;
> + phys_addr_t *msi_pa_list;
> + unsigned int cpu;
> +
> + msi_pa_list = kcalloc(num_possible_cpus(), sizeof(*msi_pa_list), GFP_KERNEL);
> + if (!msi_pa_list)
> + return -ENOMEM;
This is kzalloc_objs() these days right?
--
Jason