From: Chaoyong Zhou <zhoucyfx@foxmail.com>
To: tglx@linutronix.de, maz@kernel.org, linux-arm-kernel@lists.infradead.org
Cc: stable@vger.kernel.org
Subject: [PATCH RESEND v2] irqdomain: Restore block-wise Multi-MSI free semantics
Date: Fri, 27 Nov 2026 15:59:12 +0800 [thread overview]
Message-ID: <tencent_03CC42627A9033070327CB3A00684CCBB008@qq.com> (raw)
In-Reply-To: <8cb676da416dc4dd3cdf4c6ee1a87db887e70886.adc02e38.fb00.4c86.a424.c9153ba82907@feishu.cn>
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
next parent reply other threads:[~2026-11-27 8:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <8cb676da416dc4dd3cdf4c6ee1a87db887e70886.adc02e38.fb00.4c86.a424.c9153ba82907@feishu.cn>
2026-11-27 7:59 ` Chaoyong Zhou [this message]
2026-11-30 9:49 ` [PATCH RESEND v2] irqdomain: Restore block-wise Multi-MSI free semantics Thomas Gleixner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tencent_03CC42627A9033070327CB3A00684CCBB008@qq.com \
--to=zhoucyfx@foxmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=maz@kernel.org \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox