[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH 01/10] xen/arm: gicv3: refactor obtaining GIC addresses for common operations
Hi Leonid, On 24/07/2025 15:57, Leonid Komarianskyi wrote: Currently, many common functions perform the same operations to calculate GIC register addresses. This patch consolidates the similar code into a separate helper function to improve maintainability and reduce duplication. This refactoring also simplifies the implementation of eSPI support in future changes. > > Signed-off-by: Leonid Komarianskyi <leonid_komarianskyi@xxxxxxxx> --- xen/arch/arm/gic-v3.c | 99 ++++++++++++++++++++++------------ xen/arch/arm/include/asm/irq.h | 1 + 2 files changed, 67 insertions(+), 33 deletions(-) diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c index cd3e1acf79..8fd78aba44 100644 --- a/xen/arch/arm/gic-v3.c +++ b/xen/arch/arm/gic-v3.c @@ -445,17 +445,62 @@ static void gicv3_dump_state(const struct vcpu *v) } }+static void __iomem *get_addr_by_offset(struct irq_desc *irqd, u32 offset)+{ + switch ( irqd->irq ) + { + case 0 ... (NR_GIC_LOCAL_IRQS - 1): + switch ( offset ) + { + case GICD_ISENABLER: + case GICD_ICENABLER: + case GICD_ISPENDR: + case GICD_ICPENDR: + case GICD_ISACTIVER: + case GICD_ICACTIVER: + return (GICD_RDIST_SGI_BASE + offset); + case GICD_ICFGR: + return (GICD_RDIST_SGI_BASE + GICR_ICFGR1); + case GICD_IPRIORITYR: + return (GICD_RDIST_SGI_BASE + GICR_IPRIORITYR0 + irqd->irq); + default: + break; + } + case NR_GIC_LOCAL_IRQS ... SPI_MAX_INTID: + switch ( offset ) + { + case GICD_ISENABLER: + case GICD_ICENABLER: + case GICD_ISPENDR: + case GICD_ICPENDR: + case GICD_ISACTIVER: + case GICD_ICACTIVER: + return (GICD + offset + (irqd->irq / 32) * 4); + case GICD_ICFGR: + return (GICD + GICD_ICFGR + (irqd->irq / 16) * 4); + case GICD_IROUTER: + return (GICD + GICD_IROUTER + irqd->irq * 8); + case GICD_IPRIORITYR: + return (GICD + GICD_IPRIORITYR + irqd->irq); + default: + break; + } + default: + break; + } + + /* Something went wrong, we shouldn't be able to reach here */ + panic("Invalid offset 0x%x for IRQ#%d", offset, irqd->irq); This panic is worrying me because we have multiple switch above and it is difficult to figure out whether everything was covered. Looking at the code, it seems the main advantage would be for ISENABLER/ICENABLER & co because they are using the same logic. Therefore if you want to consolidate some code, then I would prefer if we introduce an helper just to deal with that logic. The rest (i.e. ICFGR, IROUTER, IPRIORITY) should stay inlined. Cheers, -- Julien Grall
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |