mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "tip-bot2 for Nicolai Buchwitz" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Nicolai Buchwitz <nb@tipi-net.de>,
	Thomas Gleixner <tglx@kernel.org>,
	Florian Fainelli <florian.fainelli@broadcom.com>,
	stable@vger.kernel.org, x86@kernel.org,
	linux-kernel@vger.kernel.org
Subject: [tip: irq/drivers] irqchip/bcm2712-mip: Fix multi-MSI allocation for non-power-of-two counts
Date: Tue, 01 Dec 2026 20:15:39 -0000	[thread overview]
Message-ID: <179615613935.1190409.12175280826487538840.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20261112-bcm2712-mip-msi-align-v1-1-68090868c979@tipi-net.de>

The following commit has been merged into the irq/drivers branch of tip:

Commit-ID:     e5cd48011ba4b5e52e7b873485eaac199f4a46cb
Gitweb:        https://git.kernel.org/tip/e5cd48011ba4b5e52e7b873485eaac199f4a46cb
Author:        Nicolai Buchwitz <nb@tipi-net.de>
AuthorDate:    Thu, 12 Nov 2026 12:58:11 +01:00
Committer:     Thomas Gleixner <tglx@kernel.org>
CommitterDate: Tue, 01 Dec 2026 21:12:22 +01:00

irqchip/bcm2712-mip: Fix multi-MSI allocation for non-power-of-two counts

ilog2() rounds down, so a request for three vectors reserves only two
slots and the third can overlap another allocation. The alignment is
also applied to the bitmap index and ignores the msi_offset that is
added to the message data.

Reserve exactly the requested number of slots and align the start of
the message data block to the vector count rounded up to a power of
two.

Fixes: 32c6c054661a ("irqchip: Add Broadcom BCM2712 MSI-X interrupt controller")
Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20261112-bcm2712-mip-msi-align-v1-1-68090868c979@tipi-net.de
---
 drivers/irqchip/irq-bcm2712-mip.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/irqchip/irq-bcm2712-mip.c b/drivers/irqchip/irq-bcm2712-mip.c
index 06a6ab6..a0f45df 100644
--- a/drivers/irqchip/irq-bcm2712-mip.c
+++ b/drivers/irqchip/irq-bcm2712-mip.c
@@ -71,15 +71,24 @@ static struct irq_chip mip_middle_irq_chip = {
 
 static int mip_alloc_hwirq(struct mip_priv *mip, unsigned int nr_irqs)
 {
+	unsigned long hwirq;
+
 	guard(spinlock)(&mip->lock);
-	return bitmap_find_free_region(mip->bitmap, mip->num_msis, ilog2(nr_irqs));
+	hwirq = bitmap_find_next_zero_area_off(mip->bitmap, mip->num_msis, 0,
+					       nr_irqs, roundup_pow_of_two(nr_irqs) - 1,
+					       mip->msi_offset);
+	if (hwirq >= mip->num_msis)
+		return -ENOSPC;
+
+	bitmap_set(mip->bitmap, hwirq, nr_irqs);
+	return hwirq;
 }
 
 static void mip_free_hwirq(struct mip_priv *mip, unsigned int hwirq,
 			   unsigned int nr_irqs)
 {
 	guard(spinlock)(&mip->lock);
-	bitmap_release_region(mip->bitmap, hwirq, ilog2(nr_irqs));
+	bitmap_clear(mip->bitmap, hwirq, nr_irqs);
 }
 
 static int mip_middle_domain_alloc(struct irq_domain *domain, unsigned int virq,

      parent reply	other threads:[~2026-12-01 20:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 11:58 [PATCH] " Nicolai Buchwitz
2026-11-12 18:09 ` Florian Fainelli
2026-12-01 20:15 ` tip-bot2 for Nicolai Buchwitz [this message]

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=179615613935.1190409.12175280826487538840.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=florian.fainelli@broadcom.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=nb@tipi-net.de \
    --cc=stable@vger.kernel.org \
    --cc=tglx@kernel.org \
    --cc=x86@kernel.org \
    /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

all inboxes | Powered by JetHome®