From: Oleksandr Tyshchenko <olekstysh@gmail.com>
To: Leonid Komarianskyi <Leonid_Komarianskyi@epam.com>,
"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
Julien Grall <julien@xen.org>,
Bertrand Marquis <bertrand.marquis@arm.com>,
Michal Orzel <michal.orzel@amd.com>,
Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
Subject: Re: [PATCH v4 05/12] xen/arm: gicv3: implement handling of GICv3.1 eSPI
Date: Thu, 28 Aug 2025 17:15:46 +0300 [thread overview]
Message-ID: <a759fb03-002a-4de4-993e-ad7a7f86017a@gmail.com> (raw)
In-Reply-To: <864522724dd6058952cad8b505b0589750b7f8d7.1756317702.git.leonid_komarianskyi@epam.com>
On 27.08.25 21:24, Leonid Komarianskyi wrote:
Hello Leonid
> Introduced appropriate register definitions, helper macros,
> and initialization of required GICv3.1 distributor registers
> to support eSPI. This type of interrupt is handled in the
> same way as regular SPI interrupts, with the following
> differences:
>
> 1) eSPIs can have up to 1024 interrupts, starting from the
> beginning of the range, whereas regular SPIs use INTIDs from
> 32 to 1019, totaling 988 interrupts;
> 2) eSPIs start at INTID 4096, necessitating additional interrupt
> index conversion during register operations.
>
> In case if appropriate config is disabled, or GIC HW doesn't
> support eSPI, the existing functionality will remain the same.
>
> Signed-off-by: Leonid Komarianskyi <leonid_komarianskyi@epam.com>
> Reviewed-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
>
> ---
> Changes in V4:
> - added offsets for GICD_IGRPMODRnE and GICD_NSACRnE that are required
> for vGIC emulation
> - added a log banner with eSPI information, similar to the one for
> regular SPI
> - added newline after ifdef and before gic_is_valid_line
> - added reviewed-by from Volodymyr Babchuk
only NITs below
Reviewed-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
>
> Changes in V3:
> - add __init attribute to gicv3_dist_espi_common_init
> - change open-codded eSPI register initialization to the appropriate
> gen-mask macro
> - fixed formatting for lines with more than 80 symbols
> - introduced gicv3_dist_espi_init_aff to be able to use stubs in case of
> CONFIG_GICV3_ESPI disabled
> - renamed parameter in the GICD_TYPER_ESPI_RANGE macro to espi_range
> (name was taken from GIC specification) to avoid confusion
> - changed type for i variable to unsigned int since it cannot be
> negative
>
> Changes in V2:
> - move gic_number_espis function from
> [PATCH 08/10] xen/arm: vgic: add resource management for extended SPIs
> to use it in the newly introduced gic_is_valid_espi
> - add gic_is_valid_espi which checks if IRQ number is in supported
> by HW eSPI range
> - update gic_is_valid_irq conditions to allow operations with eSPIs
>
> Changes for V4:
>
> Changes in V4:
> - added offsets for GICD_IGRPMODRnE and GICD_NSACRnE that are required
> for vGIC emulation
> - added newline after ifdef and before gic_is_valid_line
> - added reviewed-by from Volodymyr Babchuk
> - added a log banner with eSPI information, similar to the one for
> regular SPI
> ---
> xen/arch/arm/gic-v3.c | 82 ++++++++++++++++++++++++++
> xen/arch/arm/include/asm/gic.h | 22 +++++++
> xen/arch/arm/include/asm/gic_v3_defs.h | 38 ++++++++++++
> 3 files changed, 142 insertions(+)
>
> diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
> index a959fefebe..b939a1f490 100644
> --- a/xen/arch/arm/gic-v3.c
> +++ b/xen/arch/arm/gic-v3.c
> @@ -485,6 +485,36 @@ static void __iomem *get_addr_by_offset(struct irq_desc *irqd, u32 offset)
> default:
> break;
> }
> +#ifdef CONFIG_GICV3_ESPI
> + case ESPI_BASE_INTID ... ESPI_MAX_INTID:
> + {
> + u32 irq_index = ESPI_INTID2IDX(irqd->irq);
NIT: I have heard that no uN for new code, but uintN_t (sorry for didn't
spot this before), so I would use uint32_t
> +
> + switch ( offset )
> + {
> + case GICD_ISENABLER:
> + return (GICD + GICD_ISENABLERnE + (irq_index / 32) * 4);
> + case GICD_ICENABLER:
> + return (GICD + GICD_ICENABLERnE + (irq_index / 32) * 4);
> + case GICD_ISPENDR:
> + return (GICD + GICD_ISPENDRnE + (irq_index / 32) * 4);
> + case GICD_ICPENDR:
> + return (GICD + GICD_ICPENDRnE + (irq_index / 32) * 4);
> + case GICD_ISACTIVER:
> + return (GICD + GICD_ISACTIVERnE + (irq_index / 32) * 4);
> + case GICD_ICACTIVER:
> + return (GICD + GICD_ICACTIVERnE + (irq_index / 32) * 4);
> + case GICD_ICFGR:
> + return (GICD + GICD_ICFGRnE + (irq_index / 16) * 4);
> + case GICD_IROUTER:
> + return (GICD + GICD_IROUTERnE + irq_index * 8);
> + case GICD_IPRIORITYR:
> + return (GICD + GICD_IPRIORITYRnE + irq_index);
> + default:
> + break;
> + }
> + }
> +#endif
> default:
> break;
> }
> @@ -655,6 +685,54 @@ static void gicv3_set_irq_priority(struct irq_desc *desc,
> spin_unlock(&gicv3.lock);
> }
>
> +#ifdef CONFIG_GICV3_ESPI
> +unsigned int gic_number_espis(void)
> +{
> + return gic_hw_ops->info->nr_espi;
> +}
> +
> +static void __init gicv3_dist_espi_common_init(uint32_t type)
> +{
> + unsigned int espi_nr, i;
> +
> + espi_nr = min(1024U, GICD_TYPER_ESPIS_NUM(type));
> + gicv3_info.nr_espi = espi_nr;
> + /* The GIC HW doesn't support eSPI, so we can leave from here */
> + if ( gicv3_info.nr_espi == 0 )
> + return;
> +
> + printk("GICv3: %d eSPI lines\n", gicv3_info.nr_espi);
> +
> + for ( i = 0; i < espi_nr; i += 16 )
> + writel_relaxed(0, GICD + GICD_ICFGRnE + (i / 16) * 4);
> +
> + for ( i = 0; i < espi_nr; i += 4 )
> + writel_relaxed(GIC_PRI_IRQ_ALL,
> + GICD + GICD_IPRIORITYRnE + (i / 4) * 4);
> +
> + for ( i = 0; i < espi_nr; i += 32 )
> + {
> + writel_relaxed(GENMASK(31, 0), GICD + GICD_ICENABLERnE + (i / 32) * 4);
> + writel_relaxed(GENMASK(31, 0), GICD + GICD_ICACTIVERnE + (i / 32) * 4);
> + }
> +
> + for ( i = 0; i < espi_nr; i += 32 )
> + writel_relaxed(GENMASK(31, 0), GICD + GICD_IGROUPRnE + (i / 32) * 4);
NIT: From what I see, the eSPIs are configured exactly as regular SPIs
in gicv3_dist_init() (i.e. the eSPIs are level-triggered, disabled and
deactivated, belong to the same group, etc). In gicv3_dist_init() we
have comments clarying the actions, but here we do not. I would at least
write a sentence in patch description/in-code comment saying that eSPIs
configuration is the same as for regular SPIs.
> +}
> +
> +static void __init gicv3_dist_espi_init_aff(uint64_t affinity)
> +{
> + unsigned int i;
> +
> + for ( i = 0; i < gicv3_info.nr_espi; i++ )
> + writeq_relaxed_non_atomic(affinity, GICD + GICD_IROUTERnE + i * 8);
> +}
> +#else
> +static void __init gicv3_dist_espi_common_init(uint32_t type) { }
> +
> +static void __init gicv3_dist_espi_init_aff(uint64_t affinity) { }
> +#endif
> +
> static void __init gicv3_dist_init(void)
> {
> uint32_t type;
> @@ -700,6 +778,8 @@ static void __init gicv3_dist_init(void)
> for ( i = NR_GIC_LOCAL_IRQS; i < nr_lines; i += 32 )
> writel_relaxed(GENMASK(31, 0), GICD + GICD_IGROUPR + (i / 32) * 4);
>
> + gicv3_dist_espi_common_init(type);
> +
> gicv3_dist_wait_for_rwp();
>
> /* Turn on the distributor */
> @@ -713,6 +793,8 @@ static void __init gicv3_dist_init(void)
>
> for ( i = NR_GIC_LOCAL_IRQS; i < nr_lines; i++ )
> writeq_relaxed_non_atomic(affinity, GICD + GICD_IROUTER + i * 8);
> +
> + gicv3_dist_espi_init_aff(affinity);
> }
>
> static int gicv3_enable_redist(void)
[snip]
next prev parent reply other threads:[~2025-08-28 14:16 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-27 18:23 [PATCH v4 00/12] Introduce eSPI support Leonid Komarianskyi
2025-08-27 18:24 ` [PATCH v4 01/12] xen/arm: gicv3: refactor obtaining GIC addresses for common operations Leonid Komarianskyi
2025-08-28 12:00 ` Julien Grall
2025-08-28 16:17 ` Leonid Komarianskyi
2025-09-01 15:48 ` Julien Grall
2025-08-27 18:24 ` [PATCH v4 02/12] xen/arm: gic: implement helper functions for INTID checks Leonid Komarianskyi
2025-08-28 12:10 ` Julien Grall
2025-08-28 16:20 ` Leonid Komarianskyi
2025-08-27 18:24 ` [PATCH v4 03/12] xen/arm: vgic: implement helper functions for virq checks Leonid Komarianskyi
2025-08-27 22:49 ` Volodymyr Babchuk
2025-08-28 12:14 ` Julien Grall
2025-08-28 12:26 ` Oleksandr Tyshchenko
2025-08-27 18:24 ` [PATCH v4 04/12] xen/arm/irq: add handling for IRQs in the eSPI range Leonid Komarianskyi
2025-08-28 18:39 ` Oleksandr Tyshchenko
2025-08-27 18:24 ` [PATCH v4 05/12] xen/arm: gicv3: implement handling of GICv3.1 eSPI Leonid Komarianskyi
2025-08-27 22:55 ` Volodymyr Babchuk
2025-08-28 14:15 ` Oleksandr Tyshchenko [this message]
2025-08-28 16:26 ` Leonid Komarianskyi
2025-08-27 18:24 ` [PATCH v4 06/12] xen/arm/irq: allow eSPI processing in the gic_interrupt function Leonid Komarianskyi
2025-08-27 18:24 ` [PATCH v4 07/12] xen/arm: gicv3: modify ICH_LR_PHYSICAL_MASK to allow eSPI processing Leonid Komarianskyi
2025-08-27 18:24 ` [PATCH v4 08/12] xen/arm: vgic: add resource management for extended SPIs Leonid Komarianskyi
2025-08-27 23:01 ` Volodymyr Babchuk
2025-08-28 9:16 ` Leonid Komarianskyi
2025-08-28 17:34 ` Oleksandr Tyshchenko
2025-08-28 19:09 ` Leonid Komarianskyi
2025-08-29 9:48 ` Oleksandr Tyshchenko
2025-08-29 13:58 ` Leonid Komarianskyi
2025-08-27 18:24 ` [PATCH v4 09/12] xen/arm: domain_build/dom0less-build: adjust domains config to support eSPIs Leonid Komarianskyi
2025-08-27 23:03 ` Volodymyr Babchuk
2025-08-28 13:19 ` Oleksandr Tyshchenko
2025-08-28 16:38 ` Leonid Komarianskyi
2025-08-27 18:24 ` [PATCH v4 10/12] xen/arm: vgic-v3: add emulation of GICv3.1 eSPI registers Leonid Komarianskyi
2025-08-28 11:41 ` Leonid Komarianskyi
2025-08-27 18:24 ` [PATCH v4 11/12] doc/man: update description for nr_spis with eSPI Leonid Komarianskyi
2025-08-27 23:20 ` Volodymyr Babchuk
2025-08-28 12:05 ` Leonid Komarianskyi
2025-08-27 18:24 ` [PATCH v4 12/12] CHANGELOG.md: add mention of GICv3.1 eSPI support Leonid Komarianskyi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a759fb03-002a-4de4-993e-ad7a7f86017a@gmail.com \
--to=olekstysh@gmail.com \
--cc=Leonid_Komarianskyi@epam.com \
--cc=Volodymyr_Babchuk@epam.com \
--cc=bertrand.marquis@arm.com \
--cc=julien@xen.org \
--cc=michal.orzel@amd.com \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.