From: Marc Zyngier <maz@kernel.org>
To: Christian Bruel <christian.bruel@foss.st.com>
Cc: <tglx@linutronix.de>, <linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <fabrice.gasnier@foss.st.com>,
<mani@kernel.org>
Subject: Re: [PATCH v2] irqchip: gic-v2m: Handle Multiple MSI base IRQ Alignment
Date: Thu, 04 Sep 2025 10:35:02 +0100 [thread overview]
Message-ID: <87tt1izhkp.wl-maz@kernel.org> (raw)
In-Reply-To: <20250902091045.220847-1-christian.bruel@foss.st.com>
This is actually v3, right?
On Tue, 02 Sep 2025 10:10:45 +0100,
Christian Bruel <christian.bruel@foss.st.com> wrote:
>
> The PCI Local Bus Specification 3.0 (section 6.8.1.6) allows modifying the
> low-order bits of the MSI Message DATA register to encode nr_irqs interrupt
> numbers in the log2(nr_irqs) bits for the domain.
>
> The problem arises if the base vector (GICV2m base spi) is not aligned with
> nr_irqs; in this case, the low-order log2(nr_irqs) bits from the base
> vector conflict with the nr_irqs masking, causing the wrong MSI interrupt
> to be identified.
>
> To fix this, use bitmap_find_next_zero_area_off() instead of
> bitmap_find_free_region() to align the initial base vector with nr_irqs.
>
> Signed-off-by: Christian Bruel <christian.bruel@foss.st.com>
> ---
> Changes in v2:
> (Marc Zyngier)
> - Move align_off definition inside the loop
> - Reworked Commit Message
>
> Changes in v1:
> (Marc Zyngier)
> - Replace the incorrect usage of msi_attrib.multiple with nr_irqs
> - Reworked changelog
> ---
> drivers/irqchip/irq-gic-v2m.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c
> index 24ef5af569fe..8a3410c2b7b5 100644
> --- a/drivers/irqchip/irq-gic-v2m.c
> +++ b/drivers/irqchip/irq-gic-v2m.c
> @@ -153,14 +153,19 @@ static int gicv2m_irq_domain_alloc(struct irq_domain *domain, unsigned int virq,
> {
> msi_alloc_info_t *info = args;
> struct v2m_data *v2m = NULL, *tmp;
> - int hwirq, offset, i, err = 0;
> + int hwirq, i, err = 0;
> + unsigned long offset;
> + unsigned long align_mask = nr_irqs - 1;
>
> spin_lock(&v2m_lock);
> list_for_each_entry(tmp, &v2m_nodes, entry) {
> - offset = bitmap_find_free_region(tmp->bm, tmp->nr_spis,
> - get_count_order(nr_irqs));
> - if (offset >= 0) {
> + unsigned long align_off = tmp->spi_start - (tmp->spi_start & ~align_mask);
> +
> + offset = bitmap_find_next_zero_area_off(tmp->bm, tmp->nr_spis, 0,
> + nr_irqs, align_mask, align_off);
> + if (offset < tmp->nr_spis) {
> v2m = tmp;
> + bitmap_set(v2m->bm, offset, nr_irqs);
> break;
> }
> }
Reviewed-by: Marc Zyngier <maz@kernel.org>
M.
--
Jazz isn't dead. It just smells funny.
prev parent reply other threads:[~2025-09-04 10:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-02 9:10 [PATCH v2] irqchip: gic-v2m: Handle Multiple MSI base IRQ Alignment Christian Bruel
2025-09-04 9:35 ` Marc Zyngier [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=87tt1izhkp.wl-maz@kernel.org \
--to=maz@kernel.org \
--cc=christian.bruel@foss.st.com \
--cc=fabrice.gasnier@foss.st.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mani@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;
as well as URLs for NNTP newsgroup(s).