[PATCH v6 22/31] irqchip/gic-v5: Add GICv5 LPI/IPI support
Jonathan Cameron
Jonathan.Cameron at huawei.com
Wed Jul 2 06:26:27 PDT 2025
On Thu, 26 Jun 2025 12:26:13 +0200
Lorenzo Pieralisi <lpieralisi at kernel.org> wrote:
> An IRS supports Logical Peripheral Interrupts (LPIs) and implement
> Linux IPIs on top of it.
>
> LPIs are used for interrupt signals that are translated by a
> GICv5 ITS (Interrupt Translation Service) but also for software
> generated IRQs - namely interrupts that are not driven by a HW
> signal, ie IPIs.
>
> LPIs rely on memory storage for interrupt routing and state.
>
> LPIs state and routing information is kept in the Interrupt
> State Table (IST).
>
> IRSes provide support for 1- or 2-level IST tables configured
> to support a maximum number of interrupts that depend on the
> OS configuration and the HW capabilities.
>
> On systems that provide 2-level IST support, always allow
> the maximum number of LPIs; On systems with only 1-level
> support, limit the number of LPIs to 2^12 to prevent
> wasting memory (presumably a system that supports a 1-level
> only IST is not expecting a large number of interrupts).
>
> On a 2-level IST system, L2 entries are allocated on
> demand.
>
> The IST table memory is allocated using the kmalloc() interface;
> the allocation required may be smaller than a page and must be
> made up of contiguous physical pages if larger than a page.
>
> On systems where the IRS is not cache-coherent with the CPUs,
> cache mainteinance operations are executed to clean and
> invalidate the allocated memory to the point of coherency
> making it visible to the IRS components.
>
> On GICv5 systems, IPIs are implemented using LPIs.
>
> Add an LPI IRQ domain and implement an IPI-specific IRQ domain created
> as a child/subdomain of the LPI domain to allocate the required number
> of LPIs needed to implement the IPIs.
>
> IPIs are backed by LPIs, add LPIs allocation/de-allocation
> functions.
>
> The LPI INTID namespace is managed using an IDA to alloc/free LPI INTIDs.
>
> Associate an IPI irqchip with IPI IRQ descriptors to provide
> core code with the irqchip.ipi_send_single() method required
> to raise an IPI.
>
> Co-developed-by: Sascha Bischoff <sascha.bischoff at arm.com>
> Signed-off-by: Sascha Bischoff <sascha.bischoff at arm.com>
> Co-developed-by: Timothy Hayes <timothy.hayes at arm.com>
> Signed-off-by: Timothy Hayes <timothy.hayes at arm.com>
> Signed-off-by: Lorenzo Pieralisi <lpieralisi at kernel.org>
> Cc: Will Deacon <will at kernel.org>
> Cc: Thomas Gleixner <tglx at linutronix.de>
> Cc: Catalin Marinas <catalin.marinas at arm.com>
> Cc: Marc Zyngier <maz at kernel.org>
Hi Lorenzo,
The code in here looks fine to me, but one of the comments
doesn't seem to match with what the code is doing. Perhaps it's stale and needs
an update?
Jonathan
> diff --git a/drivers/irqchip/irq-gic-v5-irs.c b/drivers/irqchip/irq-gic-v5-irs.c
> index fba8efceb26e..e161acd05bf5 100644
> --- a/drivers/irqchip/irq-gic-v5-irs.c
> +++ b/drivers/irqchip/irq-gic-v5-irs.c
> +/*
> + * Try to match the L2 IST size to the pagesize, and if this is not possible
> + * pick the smallest supported L2 size in order to minimise the requirement for
> + * physically contiguous blocks of memory as page-sized allocations are
> + * guaranteed to be physically contiguous, and are by definition the easiest to
> + * find.
This comment is not matching up with the code. Seems that if a page size match
is not possible it first tries to pick the largest L2 size below the page size.
If there are none of those it then falls back to trying steadily larger sizes.
> + *
> + * Fall back to the smallest supported size (in the event that the pagesize
> + * itself is not supported) again serves to make it easier to find physically
> + * contiguous blocks of memory.
> + */
> +static unsigned int gicv5_irs_l2_sz(u32 idr2)
> +{
> + switch (PAGE_SIZE) {
> + case SZ_64K:
> + if (GICV5_IRS_IST_L2SZ_SUPPORT_64KB(idr2))
> + return GICV5_IRS_IST_CFGR_L2SZ_64K;
> + fallthrough;
> + case SZ_16K:
> + if (GICV5_IRS_IST_L2SZ_SUPPORT_16KB(idr2))
> + return GICV5_IRS_IST_CFGR_L2SZ_16K;
> + fallthrough;
> + case SZ_4K:
> + if (GICV5_IRS_IST_L2SZ_SUPPORT_4KB(idr2))
> + return GICV5_IRS_IST_CFGR_L2SZ_4K;
> + break;
> + }
> +
> + if (GICV5_IRS_IST_L2SZ_SUPPORT_16KB(idr2))
> + return GICV5_IRS_IST_CFGR_L2SZ_16K;
> +
> + return GICV5_IRS_IST_CFGR_L2SZ_64K;
> +}
More information about the linux-arm-kernel
mailing list