* [PATCH RESEND v2] irqdomain: Restore block-wise Multi-MSI free semantics
[not found] <8cb676da416dc4dd3cdf4c6ee1a87db887e70886.adc02e38.fb00.4c86.a424.c9153ba82907@feishu.cn>
@ 2026-11-27 7:59 ` Chaoyong Zhou
2026-11-30 9:49 ` Thomas Gleixner
0 siblings, 1 reply; 2+ messages in thread
From: Chaoyong Zhou @ 2026-11-27 7:59 UTC (permalink / raw)
To: tglx, maz, linux-arm-kernel; +Cc: stable
From: Chaoyong Zhou <zhouchaoyong@ruijie.com.cn>
Please note: this is a resend from my personal mailbox
(zhoucyfx@foxmail.com). The initial copy on 2026-11-25 was sent from my
work address (zhouchaoyong@ruijie.com.cn) and reached you both, but our
corporate mail gateway mangles outgoing mail into multipart/alternative
(HTML), which the infradead list rejects with "550 Mailing lists do not
accept HTML mail", so the list copies bounced twice. Sending via git
send-email over this mailbox keeps the mail text/plain only.
The interrupts of a Multi-MSI descriptor are allocated from the MSI
controllers as a single aligned block: the ITS (GICv3 and GICv5) and
the Armada 370/XP drivers, amongst others, round the vector count up
to a power of two and carve the region out of their per-device event
bitmap with bitmap_find_free_region().
Commit 4615fbc3788d ("genirq/irqdomain: Don't try to free an
interrupt that has no mapping") changed irq_domain_free_irqs_hierarchy()
to free the interrupts of a range one at a time, to protect against
error paths trying to free interrupts that were never allocated.
That changed the contract with the underlying domains: a Multi-MSI
block is now released one interrupt at a time with nr_irqs == 1,
which cannot unwind the aligned region the allocation created. The
unused tail of the block is never released, leaving stale bits in the
event bitmap. As a result the MSI device is never fully reclaimed
(its_irq_domain_free() only mops up the device once its bitmap is
empty), and re-probing the device fails to allocate the same number
of vectors, silently degrading to a single MSI.
This has been reported for GICv3 ITS:
https://lore.kernel.org/all/20240708153933.GC5745@thinkpad/
Restore the pre-existing block-wise free semantics: when the whole
range is consistently mapped, hand it down to the domains as a single
block, exactly mirroring the allocation. Keep the per-interrupt
fallback for inconsistent ranges, preserving the protection introduced
by commit 4615fbc3788d ("genirq/irqdomain: Don't try to free an interrupt
that has no mapping") for unwinding partially allocated ranges.
Fixes: 4615fbc3788d ("genirq/irqdomain: Don't try to free an interrupt that has no mapping")
Reported-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Closes: https://lore.kernel.org/all/20240708153933.GC5745@thinkpad/
Cc: stable@vger.kernel.org
Signed-off-by: Chaoyong Zhou <zhouchaoyong@ruijie.com.cn>
---
kernel/irq/irqdomain.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index 57c819da30c2..4b67f1e9200f 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -1610,6 +1610,29 @@ static void irq_domain_free_irqs_hierarchy(struct irq_domain *domain,
if (!domain->ops->free)
return;
+ /*
+ * The interrupts of a Multi-MSI descriptor are handed down to
+ * the underlying domains as a single block, mirroring the way
+ * they were allocated. Most MSI controllers round a Multi-MSI
+ * allocation up to a power of two and track it as an aligned
+ * region (bitmap_find_free_region() and friends), which cannot
+ * be piecemeal unwound one interrupt at a time: doing so leaks
+ * the unused tail of the region and eventually prevents the
+ * device from being fully reclaimed.
+ *
+ * Only fall back to freeing one interrupt at a time if the
+ * block is inconsistent, e.g. when unwinding a partially
+ * successful allocation.
+ */
+ for (i = 0; i < nr_irqs; i++) {
+ if (!irq_domain_get_irq_data(domain, irq_base + i))
+ goto unwind_partial;
+ }
+
+ domain->ops->free(domain, irq_base, nr_irqs);
+ return;
+
+unwind_partial:
for (i = 0; i < nr_irqs; i++) {
if (irq_domain_get_irq_data(domain, irq_base + i))
domain->ops->free(domain, irq_base + i, 1);
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH RESEND v2] irqdomain: Restore block-wise Multi-MSI free semantics
2026-11-27 7:59 ` [PATCH RESEND v2] irqdomain: Restore block-wise Multi-MSI free semantics Chaoyong Zhou
@ 2026-11-30 9:49 ` Thomas Gleixner
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Gleixner @ 2026-11-30 9:49 UTC (permalink / raw)
To: Chaoyong Zhou, maz, linux-arm-kernel; +Cc: stable
On Fri, Nov 27 2026 at 15:59, Chaoyong Zhou wrote:
> From: Chaoyong Zhou <zhouchaoyong@ruijie.com.cn>
>
> Please note: this is a resend from my personal mailbox
> (zhoucyfx@foxmail.com). The initial copy on 2026-11-25 was sent from my
> work address (zhouchaoyong@ruijie.com.cn) and reached you both, but our
> corporate mail gateway mangles outgoing mail into multipart/alternative
> (HTML), which the infradead list rejects with "550 Mailing lists do not
> accept HTML mail", so the list copies bounced twice. Sending via git
> send-email over this mailbox keeps the mail text/plain only.
How is that relevant for the change log? Put such information under the
"---" cutoff if at all. Nobody cares how about your email problems.
> Restore the pre-existing block-wise free semantics: when the whole
> range is consistently mapped, hand it down to the domains as a single
> block, exactly mirroring the allocation. Keep the per-interrupt
> fallback for inconsistent ranges, preserving the protection introduced
> by commit 4615fbc3788d ("genirq/irqdomain: Don't try to free an interrupt
> that has no mapping") for unwinding partially allocated ranges.
>
> Fixes: 4615fbc3788d ("genirq/irqdomain: Don't try to free an interrupt that has no mapping")
> The interrupts of a Multi-MSI descriptor are allocated from the MSI
> controllers as a single aligned block: the ITS (GICv3 and GICv5) and
> the Armada 370/XP drivers, amongst others, round the vector count up
> to a power of two and carve the region out of their per-device event
> bitmap with bitmap_find_free_region().
>
> Commit 4615fbc3788d ("genirq/irqdomain: Don't try to free an
> interrupt that has no mapping") changed irq_domain_free_irqs_hierarchy()
> to free the interrupts of a range one at a time, to protect against
> error paths trying to free interrupts that were never allocated.
>
> That changed the contract with the underlying domains: a Multi-MSI
> block is now released one interrupt at a time with nr_irqs == 1,
> which cannot unwind the aligned region the allocation created. The
> unused tail of the block is never released, leaving stale bits in the
> event bitmap. As a result the MSI device is never fully reclaimed
> (its_irq_domain_free() only mops up the device once its bitmap is
> empty), and re-probing the device fails to allocate the same number
> of vectors, silently degrading to a single MSI.
>
> This has been reported for GICv3 ITS:
>
> https://lore.kernel.org/all/20240708153933.GC5745@thinkpad/
>
Can you try:
https://lore.kernel.org/87fqxbwla2.ffs@fw13
That should solve your problem along with some others which have been
reported.
Thanks,
tglx
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-30 9:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <8cb676da416dc4dd3cdf4c6ee1a87db887e70886.adc02e38.fb00.4c86.a424.c9153ba82907@feishu.cn>
2026-11-27 7:59 ` [PATCH RESEND v2] irqdomain: Restore block-wise Multi-MSI free semantics Chaoyong Zhou
2026-11-30 9:49 ` Thomas Gleixner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox