* [PATCH] Revert "irqchip/riscv-imsic: Embed the vector array in lpriv"
@ 2025-12-23 14:35 Anup Patel
2026-01-09 15:11 ` [tip: irq/urgent] " tip-bot2 for Anup Patel
2026-01-19 14:21 ` [PATCH] " patchwork-bot+linux-riscv
0 siblings, 2 replies; 3+ messages in thread
From: Anup Patel @ 2025-12-23 14:35 UTC (permalink / raw)
To: Thomas Gleixner, Palmer Dabbelt, Paul Walmsley
Cc: Alexandre Ghiti, Sunil V L, Atish Patra, Andrew Jones,
Samuel Holland, Anup Patel, kvm-riscv, linux-riscv, linux-kernel,
Anup Patel
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 79eaabc61dfb ("irqchip/riscv-imsic: Embed the vector
array in lpriv").
Signed-off-by: Anup Patel <anup.patel@oss.qualcomm.com>
---
drivers/irqchip/irq-riscv-imsic-state.c | 10 ++++++++--
drivers/irqchip/irq-riscv-imsic-state.h | 2 +-
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/irqchip/irq-riscv-imsic-state.c b/drivers/irqchip/irq-riscv-imsic-state.c
index 385368052d5c..b6cebfee9461 100644
--- a/drivers/irqchip/irq-riscv-imsic-state.c
+++ b/drivers/irqchip/irq-riscv-imsic-state.c
@@ -477,6 +477,7 @@ static void __init imsic_local_cleanup(void)
lpriv = per_cpu_ptr(imsic->lpriv, cpu);
bitmap_free(lpriv->dirty_bitmap);
+ kfree(lpriv->vectors);
}
free_percpu(imsic->lpriv);
@@ -490,8 +491,7 @@ static int __init imsic_local_init(void)
int cpu, i;
/* Allocate per-CPU private state */
- imsic->lpriv = __alloc_percpu(struct_size(imsic->lpriv, vectors, global->nr_ids + 1),
- __alignof__(*imsic->lpriv));
+ imsic->lpriv = alloc_percpu(typeof(*imsic->lpriv));
if (!imsic->lpriv)
return -ENOMEM;
@@ -511,6 +511,12 @@ static int __init imsic_local_init(void)
timer_setup(&lpriv->timer, imsic_local_timer_callback, TIMER_PINNED);
#endif
+ /* Allocate vector array */
+ lpriv->vectors = kcalloc(global->nr_ids + 1, sizeof(*lpriv->vectors),
+ GFP_KERNEL);
+ if (!lpriv->vectors)
+ goto fail_local_cleanup;
+
/* Setup vector array */
for (i = 0; i <= global->nr_ids; i++) {
vec = &lpriv->vectors[i];
diff --git a/drivers/irqchip/irq-riscv-imsic-state.h b/drivers/irqchip/irq-riscv-imsic-state.h
index 6332501dcbd8..c42ee180b305 100644
--- a/drivers/irqchip/irq-riscv-imsic-state.h
+++ b/drivers/irqchip/irq-riscv-imsic-state.h
@@ -40,7 +40,7 @@ struct imsic_local_priv {
#endif
/* Local vector table */
- struct imsic_vector vectors[];
+ struct imsic_vector *vectors;
};
struct imsic_priv {
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* [tip: irq/urgent] Revert "irqchip/riscv-imsic: Embed the vector array in lpriv"
2025-12-23 14:35 [PATCH] Revert "irqchip/riscv-imsic: Embed the vector array in lpriv" Anup Patel
@ 2026-01-09 15:11 ` tip-bot2 for Anup Patel
2026-01-19 14:21 ` [PATCH] " patchwork-bot+linux-riscv
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Anup Patel @ 2026-01-09 15:11 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Anup Patel, Thomas Gleixner, x86, linux-kernel, maz
The following commit has been merged into the irq/urgent branch of tip:
Commit-ID: a33d16dc874a9512c02b1f1a3e08c26a82b4be5e
Gitweb: https://git.kernel.org/tip/a33d16dc874a9512c02b1f1a3e08c26a82b4be5e
Author: Anup Patel <anup.patel@oss.qualcomm.com>
AuthorDate: Tue, 23 Dec 2025 20:05:44 +05:30
Committer: Thomas Gleixner <tglx@kernel.org>
CommitterDate: Fri, 09 Jan 2026 16:10:05 +01:00
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 79eaabc61dfb ("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
---
drivers/irqchip/irq-riscv-imsic-state.c | 10 ++++++++--
drivers/irqchip/irq-riscv-imsic-state.h | 2 +-
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/irqchip/irq-riscv-imsic-state.c b/drivers/irqchip/irq-riscv-imsic-state.c
index 3853680..b6cebfe 100644
--- a/drivers/irqchip/irq-riscv-imsic-state.c
+++ b/drivers/irqchip/irq-riscv-imsic-state.c
@@ -477,6 +477,7 @@ static void __init imsic_local_cleanup(void)
lpriv = per_cpu_ptr(imsic->lpriv, cpu);
bitmap_free(lpriv->dirty_bitmap);
+ kfree(lpriv->vectors);
}
free_percpu(imsic->lpriv);
@@ -490,8 +491,7 @@ static int __init imsic_local_init(void)
int cpu, i;
/* Allocate per-CPU private state */
- imsic->lpriv = __alloc_percpu(struct_size(imsic->lpriv, vectors, global->nr_ids + 1),
- __alignof__(*imsic->lpriv));
+ imsic->lpriv = alloc_percpu(typeof(*imsic->lpriv));
if (!imsic->lpriv)
return -ENOMEM;
@@ -511,6 +511,12 @@ static int __init imsic_local_init(void)
timer_setup(&lpriv->timer, imsic_local_timer_callback, TIMER_PINNED);
#endif
+ /* Allocate vector array */
+ lpriv->vectors = kcalloc(global->nr_ids + 1, sizeof(*lpriv->vectors),
+ GFP_KERNEL);
+ if (!lpriv->vectors)
+ goto fail_local_cleanup;
+
/* Setup vector array */
for (i = 0; i <= global->nr_ids; i++) {
vec = &lpriv->vectors[i];
diff --git a/drivers/irqchip/irq-riscv-imsic-state.h b/drivers/irqchip/irq-riscv-imsic-state.h
index 6332501..c42ee18 100644
--- a/drivers/irqchip/irq-riscv-imsic-state.h
+++ b/drivers/irqchip/irq-riscv-imsic-state.h
@@ -40,7 +40,7 @@ struct imsic_local_priv {
#endif
/* Local vector table */
- struct imsic_vector vectors[];
+ struct imsic_vector *vectors;
};
struct imsic_priv {
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] Revert "irqchip/riscv-imsic: Embed the vector array in lpriv"
2025-12-23 14:35 [PATCH] Revert "irqchip/riscv-imsic: Embed the vector array in lpriv" Anup Patel
2026-01-09 15:11 ` [tip: irq/urgent] " tip-bot2 for Anup Patel
@ 2026-01-19 14:21 ` patchwork-bot+linux-riscv
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+linux-riscv @ 2026-01-19 14:21 UTC (permalink / raw)
To: Anup Patel
Cc: linux-riscv, tglx, palmer, pjw, alex, sunilvl, atish.patra,
andrew.jones, samuel.holland, anup, kvm-riscv, linux-kernel
Hello:
This patch was applied to riscv/linux.git (fixes)
by Thomas Gleixner <tglx@kernel.org>:
On Tue, 23 Dec 2025 20:05:44 +0530 you wrote:
> 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.
>
> [...]
Here is the summary with links:
- Revert "irqchip/riscv-imsic: Embed the vector array in lpriv"
https://git.kernel.org/riscv/c/a33d16dc874a
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-01-19 14:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-23 14:35 [PATCH] Revert "irqchip/riscv-imsic: Embed the vector array in lpriv" Anup Patel
2026-01-09 15:11 ` [tip: irq/urgent] " tip-bot2 for Anup Patel
2026-01-19 14:21 ` [PATCH] " patchwork-bot+linux-riscv
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox