Skip to content

Commit a33d16d

Browse files
avpatelThomas Gleixner
authored andcommitted
Revert "irqchip/riscv-imsic: Embed the vector array in lpriv"
The __alloc_percpu() fails when the number of IDs are greater than 959 because size parameter of __alloc_percpu() must be less than 32768 (aka PCPU_MIN_UNIT_SIZE). This failure is observed with KVMTOOL when AIA is trap-n-emulated by in-kernel KVM because in this case KVM guest has 2047 interrupt IDs. To address this issue, don't embed vector array in struct imsic_local_priv until __alloc_percpu() support size parameter greater than 32768. This reverts commit 79eaabc ("irqchip/riscv-imsic: Embed the vector array in lpriv"). Signed-off-by: Anup Patel <anup.patel@oss.qualcomm.com> Signed-off-by: Thomas Gleixner <tglx@kernel.org> Link: https://patch.msgid.link/20251223143544.1504217-1-anup.patel@oss.qualcomm.com
1 parent 1690eeb commit a33d16d

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

drivers/irqchip/irq-riscv-imsic-state.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ static void __init imsic_local_cleanup(void)
477477
lpriv = per_cpu_ptr(imsic->lpriv, cpu);
478478

479479
bitmap_free(lpriv->dirty_bitmap);
480+
kfree(lpriv->vectors);
480481
}
481482

482483
free_percpu(imsic->lpriv);
@@ -490,8 +491,7 @@ static int __init imsic_local_init(void)
490491
int cpu, i;
491492

492493
/* Allocate per-CPU private state */
493-
imsic->lpriv = __alloc_percpu(struct_size(imsic->lpriv, vectors, global->nr_ids + 1),
494-
__alignof__(*imsic->lpriv));
494+
imsic->lpriv = alloc_percpu(typeof(*imsic->lpriv));
495495
if (!imsic->lpriv)
496496
return -ENOMEM;
497497

@@ -511,6 +511,12 @@ static int __init imsic_local_init(void)
511511
timer_setup(&lpriv->timer, imsic_local_timer_callback, TIMER_PINNED);
512512
#endif
513513

514+
/* Allocate vector array */
515+
lpriv->vectors = kcalloc(global->nr_ids + 1, sizeof(*lpriv->vectors),
516+
GFP_KERNEL);
517+
if (!lpriv->vectors)
518+
goto fail_local_cleanup;
519+
514520
/* Setup vector array */
515521
for (i = 0; i <= global->nr_ids; i++) {
516522
vec = &lpriv->vectors[i];

drivers/irqchip/irq-riscv-imsic-state.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ struct imsic_local_priv {
4040
#endif
4141

4242
/* Local vector table */
43-
struct imsic_vector vectors[];
43+
struct imsic_vector *vectors;
4444
};
4545

4646
struct imsic_priv {

0 commit comments

Comments
 (0)