Skip to content

Commit f2d8340

Browse files
author
Marc Zyngier
committed
irqchip/gic-v3: Add GICv4.1 VPEID size discovery
While GICv4.0 mandates 16 bit worth of VPEIDs, GICv4.1 allows smaller implementations to be built. Add the required glue to dynamically compute the limit. Signed-off-by: Marc Zyngier <[email protected]> Reviewed-by: Zenghui Yu <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent b25319d commit f2d8340

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

drivers/irqchip/irq-gic-v3-its.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,16 @@ struct its_node {
121121
#define ITS_ITT_ALIGN SZ_256
122122

123123
/* The maximum number of VPEID bits supported by VLPI commands */
124-
#define ITS_MAX_VPEID_BITS (16)
124+
#define ITS_MAX_VPEID_BITS \
125+
({ \
126+
int nvpeid = 16; \
127+
if (gic_rdists->has_rvpeid && \
128+
gic_rdists->gicd_typer2 & GICD_TYPER2_VIL) \
129+
nvpeid = 1 + (gic_rdists->gicd_typer2 & \
130+
GICD_TYPER2_VID); \
131+
\
132+
nvpeid; \
133+
})
125134
#define ITS_MAX_VPEID (1 << (ITS_MAX_VPEID_BITS))
126135

127136
/* Convert page order to size in bytes */

drivers/irqchip/irq-gic-v3.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,6 +1576,9 @@ static int __init gic_init_bases(void __iomem *dist_base,
15761576

15771577
pr_info("%d SPIs implemented\n", GIC_LINE_NR - 32);
15781578
pr_info("%d Extended SPIs implemented\n", GIC_ESPI_NR);
1579+
1580+
gic_data.rdists.gicd_typer2 = readl_relaxed(gic_data.dist_base + GICD_TYPER2);
1581+
15791582
gic_data.domain = irq_domain_create_tree(handle, &gic_irq_domain_ops,
15801583
&gic_data);
15811584
irq_domain_update_bus_token(gic_data.domain, DOMAIN_BUS_WIRED);

include/linux/irqchip/arm-gic-v3.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#define GICD_CTLR 0x0000
1414
#define GICD_TYPER 0x0004
1515
#define GICD_IIDR 0x0008
16+
#define GICD_TYPER2 0x000C
1617
#define GICD_STATUSR 0x0010
1718
#define GICD_SETSPI_NSR 0x0040
1819
#define GICD_CLRSPI_NSR 0x0048
@@ -89,6 +90,9 @@
8990
#define GICD_TYPER_ESPIS(typer) \
9091
(((typer) & GICD_TYPER_ESPI) ? GICD_TYPER_SPIS((typer) >> 27) : 0)
9192

93+
#define GICD_TYPER2_VIL (1U << 7)
94+
#define GICD_TYPER2_VID GENMASK(4, 0)
95+
9296
#define GICD_IROUTER_SPI_MODE_ONE (0U << 31)
9397
#define GICD_IROUTER_SPI_MODE_ANY (1U << 31)
9498

@@ -615,6 +619,7 @@ struct rdists {
615619
void *prop_table_va;
616620
u64 flags;
617621
u32 gicd_typer;
622+
u32 gicd_typer2;
618623
bool has_vlpis;
619624
bool has_rvpeid;
620625
bool has_direct_lpi;

0 commit comments

Comments
 (0)