Skip to content

Commit ce9e40a

Browse files
Marc ZyngierThomas Gleixner
authored andcommitted
irqchip/gic-v3-its: Limit number of per-device MSIs to the range the ITS supports
The ITS driver blindly assumes that EventIDs are in abundant supply, to the point where it never checks how many the hardware actually supports. It turns out that some pretty esoteric integrations make it so that only a few bits are available, all the way down to a single bit. Enforce the advertised limitation at the point of allocating the device structure, and hope that the endpoint driver can deal with such limitation. Fixes: 84a6a2e ("irqchip: GICv3: ITS: device allocation and configuration") Signed-off-by: Marc Zyngier <maz@kernel.org> Signed-off-by: Thomas Gleixner <tglx@kernel.org> Reviewed-by: Robin Murphy <robin.murphy@arm.com> Reviewed-by: Zenghui Yu <zenghui.yu@linux.dev> Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20260206154816.3582887-1-maz@kernel.org
1 parent 1072020 commit ce9e40a

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3475,6 +3475,7 @@ static struct its_device *its_create_device(struct its_node *its, u32 dev_id,
34753475
int lpi_base;
34763476
int nr_lpis;
34773477
int nr_ites;
3478+
int id_bits;
34783479
int sz;
34793480

34803481
if (!its_alloc_device_table(its, dev_id))
@@ -3486,7 +3487,10 @@ static struct its_device *its_create_device(struct its_node *its, u32 dev_id,
34863487
/*
34873488
* Even if the device wants a single LPI, the ITT must be
34883489
* sized as a power of two (and you need at least one bit...).
3490+
* Also honor the ITS's own EID limit.
34893491
*/
3492+
id_bits = FIELD_GET(GITS_TYPER_IDBITS, its->typer) + 1;
3493+
nvecs = min_t(unsigned int, nvecs, BIT(id_bits));
34903494
nr_ites = max(2, nvecs);
34913495
sz = nr_ites * (FIELD_GET(GITS_TYPER_ITT_ENTRY_SIZE, its->typer) + 1);
34923496
sz = max(sz, ITS_ITT_ALIGN);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@
394394
#define GITS_TYPER_VLPIS (1UL << 1)
395395
#define GITS_TYPER_ITT_ENTRY_SIZE_SHIFT 4
396396
#define GITS_TYPER_ITT_ENTRY_SIZE GENMASK_ULL(7, 4)
397+
#define GITS_TYPER_IDBITS GENMASK_ULL(12, 8)
397398
#define GITS_TYPER_IDBITS_SHIFT 8
398399
#define GITS_TYPER_DEVBITS_SHIFT 13
399400
#define GITS_TYPER_DEVBITS GENMASK_ULL(17, 13)

0 commit comments

Comments
 (0)