From: Marc Zyngier <maz@kernel.org>
To: Lorenzo Pieralisi <lpieralisi@kernel.org>
Cc: Zenghui Yu <yuzenghui@huawei.com>,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Thomas Gleixner <tglx@linutronix.de>,
Sascha Bischoff <sascha.bischoff@arm.com>,
Timothy Hayes <timothy.hayes@arm.com>
Subject: Re: [PATCH v2 3/5] genirq/msi: Move prepare() call to per-device allocation
Date: Tue, 03 Jun 2025 15:03:26 +0100 [thread overview]
Message-ID: <87h60wexch.wl-maz@kernel.org> (raw)
In-Reply-To: <aD741hI7MfTmi7Rl@lpieralisi>
On Tue, 03 Jun 2025 14:29:58 +0100,
Lorenzo Pieralisi <lpieralisi@kernel.org> wrote:
>
> On Tue, Jun 03, 2025 at 01:50:47PM +0100, Marc Zyngier wrote:
> > Hi Zenghui,
> >
> > On Tue, 03 Jun 2025 09:22:47 +0100,
> > Zenghui Yu <yuzenghui@huawei.com> wrote:
> > >
> > > > + domain->dev = dev;
> > > > + dev->msi.data->__domains[domid].domain = domain;
> > > > +
> > > > + if (msi_domain_prepare_irqs(domain, dev, hwsize, &bundle->alloc_info)) {
> > >
> > > Does it work for MSI? hwsize is 1 in the MSI case, without taking
> > > pci_msi_vec_count() into account.
> > >
> > > bool pci_setup_msi_device_domain(struct pci_dev *pdev)
> > > {
> > > [...]
> > >
> > > return pci_create_device_domain(pdev, &pci_msi_template, 1);
> >
> > Well spotted.
> >
> > This looks like a PCI bug ignoring Multi-MSI. Can you give the
> > following a go and let people know whether that fixes your issue?
> >
> > Thanks,
> >
> > M.
> >
> > diff --git a/drivers/pci/msi/irqdomain.c b/drivers/pci/msi/irqdomain.c
> > index d7ba8795d60f..89677a21d525 100644
> > --- a/drivers/pci/msi/irqdomain.c
> > +++ b/drivers/pci/msi/irqdomain.c
> > @@ -287,7 +287,7 @@ static bool pci_create_device_domain(struct pci_dev *pdev, const struct msi_doma
> > * - The device is removed
> > * - MSI is disabled and a MSI-X domain is created
> > */
> > -bool pci_setup_msi_device_domain(struct pci_dev *pdev)
> > +bool pci_setup_msi_device_domain(struct pci_dev *pdev, unsigned int hwsize)
> > {
> > if (WARN_ON_ONCE(pdev->msix_enabled))
> > return false;
> > @@ -297,7 +297,7 @@ bool pci_setup_msi_device_domain(struct pci_dev *pdev)
> > if (pci_match_device_domain(pdev, DOMAIN_BUS_PCI_DEVICE_MSIX))
> > msi_remove_device_irq_domain(&pdev->dev, MSI_DEFAULT_DOMAIN);
> >
> > - return pci_create_device_domain(pdev, &pci_msi_template, 1);
> > + return pci_create_device_domain(pdev, &pci_msi_template, hwsize);
> > }
> >
> > /**
> > diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c
> > index 8b8848788618..81891701840a 100644
> > --- a/drivers/pci/msi/msi.c
> > +++ b/drivers/pci/msi/msi.c
> > @@ -449,7 +449,7 @@ int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec,
> > if (rc)
> > return rc;
> >
> > - if (!pci_setup_msi_device_domain(dev))
> > + if (!pci_setup_msi_device_domain(dev, nvec))
>
> If pci_msi_vec_count(dev) > maxvec we would cap nvec and size the
> domain with the capped value.
>
> In __pci_enable_msix_range() we are sizing the device according to
> pci_msix_vec_count(dev) regardless of maxvec, if I read the code correctly.
>
> While fixing it it would be good to make them consistent unless there is
> a reason why they should not.
This is indeed odd, but that'd be a separate fix. Something like:
diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c
index 2090eef64b14..6ede55a7c5e6 100644
--- a/drivers/pci/msi/msi.c
+++ b/drivers/pci/msi/msi.c
@@ -439,9 +439,6 @@ int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec,
if (nvec < minvec)
return -ENOSPC;
- if (nvec > maxvec)
- nvec = maxvec;
-
rc = pci_setup_msi_context(dev);
if (rc)
return rc;
@@ -449,6 +446,9 @@ int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec,
if (!pci_setup_msi_device_domain(dev, nvec))
return -ENODEV;
+ if (nvec > maxvec)
+ nvec = maxvec;
+
for (;;) {
if (affd) {
nvec = irq_calc_affinity_vectors(minvec, nvec, affd);
--
Jazz isn't dead. It just smells funny.
next prev parent reply other threads:[~2025-06-03 14:03 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-13 16:31 [PATCH v2 0/5] genirq/msi: Fix device MSI prepare/alloc sequencing Marc Zyngier
2025-05-13 16:31 ` [PATCH v2 1/5] genirq/msi: Add .msi_teardown() callback as the reverse of .msi_prepare() Marc Zyngier
2025-05-16 10:02 ` [tip: irq/msi] " tip-bot2 for Marc Zyngier
2025-05-13 16:31 ` [PATCH v2 2/5] irqchip/gic-v3-its: Implement .msi_teardown() callback Marc Zyngier
2025-05-16 10:02 ` [tip: irq/msi] " tip-bot2 for Marc Zyngier
2025-05-13 16:31 ` [PATCH v2 3/5] genirq/msi: Move prepare() call to per-device allocation Marc Zyngier
2025-05-16 10:02 ` [tip: irq/msi] " tip-bot2 for Marc Zyngier
2025-06-03 8:22 ` [PATCH v2 3/5] " Zenghui Yu
2025-06-03 9:35 ` Lorenzo Pieralisi
2025-06-03 13:09 ` Marc Zyngier
2025-06-03 14:37 ` Lorenzo Pieralisi
2025-06-04 1:52 ` Zenghui Yu
2025-06-03 12:50 ` Marc Zyngier
2025-06-03 13:07 ` Zenghui Yu
2025-06-03 13:27 ` Marc Zyngier
2025-06-03 13:29 ` Lorenzo Pieralisi
2025-06-03 14:03 ` Marc Zyngier [this message]
2025-06-03 14:08 ` Marc Zyngier
2025-05-13 16:31 ` [PATCH v2 4/5] genirq/msi: Engage the .msi_teardown() callback on domain removal Marc Zyngier
2025-05-16 10:02 ` [tip: irq/msi] " tip-bot2 for Marc Zyngier
2025-05-13 16:31 ` [PATCH v2 5/5] irqchip/gic-v3-its: Use allocation size from the prepare call Marc Zyngier
2025-05-16 10:02 ` [tip: irq/msi] " tip-bot2 for Marc Zyngier
2025-05-18 18:53 ` [PATCH v2 5/5] " Thomas Gleixner
2025-05-19 10:15 ` Marc Zyngier
2025-05-19 12:16 ` Thomas Gleixner
2025-05-19 14:28 ` Marc Zyngier
2025-05-21 15:29 ` 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=87h60wexch.wl-maz@kernel.org \
--to=maz@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=sascha.bischoff@arm.com \
--cc=tglx@linutronix.de \
--cc=timothy.hayes@arm.com \
--cc=yuzenghui@huawei.com \
/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®