From: Shawn Lin <shawn.lin@rock-chips.com>
To: Frank Li <Frank.li@nxp.com>
Cc: shawn.lin@rock-chips.com, Bjorn Helgaas <bhelgaas@google.com>,
Nirmal Patel <nirmal.patel@linux.intel.com>,
Jonathan Derrick <jonathan.derrick@linux.dev>,
Kurt Schwemmer <kurt.schwemmer@microsemi.com>,
Logan Gunthorpe <logang@deltatee.com>,
Philipp Stanner <phasta@kernel.org>,
linux-pci@vger.kernel.org
Subject: Re: [PATCH v2 1/3] PCI/MSI: Add Devres managed IRQ vectors allocation
Date: Fri, 17 Apr 2026 14:32:15 +0800 [thread overview]
Message-ID: <9cafe1d5-1105-cfbe-2ef4-3f018ef7025d@rock-chips.com> (raw)
In-Reply-To: <aeHOyYJR2GRRP4fY@lizhi-Precision-Tower-5810>
Hi Frank
在 2026/04/17 星期五 14:10, Frank Li 写道:
> On Fri, Apr 17, 2026 at 10:26:05AM +0800, Shawn Lin wrote:
>> pcim_alloc_irq_vectors() and pcim_alloc_irq_vectors_affinity() are created for
>> pci device drivers which rely on the devres machinery to help cleanup the IRQ
>> vectors.
>>
>> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
>>
>> ---
>>
>> Changes in v2: None
>>
>> drivers/pci/msi/api.c | 26 ++++++++++++++++++++++++++
>> include/linux/pci.h | 22 ++++++++++++++++++++++
>> 2 files changed, 48 insertions(+)
>>
> ...
>> +/**
>> + * pcim_alloc_irq_vectors_affinity() - devres managed pci_alloc_irq_vectors_affinity()
>> + * Interrupt vectors are automatically freed by the devres machinery
>> + */
>> +int pcim_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs,
>> + unsigned int max_vecs, unsigned int flags,
>> + struct irq_affinity *affd)
>> +{
>> + dev->is_msi_managed = true;
>> + return pci_alloc_irq_vectors_affinity(dev, min_vecs, max_vecs,
>> + flags, affd);
>
> any side effect if pci_alloc_irq_vectors_affinity() return fail and
> is_msi_managed keep true.
Thanks for the review! This is a good point.
You're absolutely right that in the current implementation, if
pci_alloc_irq_vectors_affinity() fails, is_msi_managed remains true
while no vectors are actually allocated.
This replicates the behavior of pcim_enable_device() +
pci_alloc_irq_vectors_affinity() , which also sets
is_msi_managed unconditionally, but that doesn't make it ideal.
I think we should fix this for better self-contained behavior. The
pcim_* APIs should be robust on their own.
I'll move the is_msi_managed assignment to after successful allocation
in v3, if the general apporach looks feasible.
>
> Frank
>>
>
>
next prev parent reply other threads:[~2026-04-17 7:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-17 2:26 [PATCH v2 0/3] Add Devres managed IRQ vectors allocation Shawn Lin
2026-04-17 2:26 ` [PATCH v2 1/3] PCI/MSI: " Shawn Lin
2026-04-17 6:10 ` Frank Li
2026-04-17 6:32 ` Shawn Lin [this message]
2026-04-17 8:44 ` Philipp Stanner
2026-04-17 9:33 ` Shawn Lin
2026-04-20 9:28 ` Philipp Stanner
2026-04-20 9:52 ` Shawn Lin
2026-04-17 2:26 ` [PATCH v2 2/3] PCI: switchtec: Replace pci_alloc_irq_vectors() with pcim_alloc_irq_vectors() Shawn Lin
2026-04-17 15:16 ` Logan Gunthorpe
2026-04-17 2:26 ` [PATCH v2 3/3] PCI: vmd: " Shawn Lin
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=9cafe1d5-1105-cfbe-2ef4-3f018ef7025d@rock-chips.com \
--to=shawn.lin@rock-chips.com \
--cc=Frank.li@nxp.com \
--cc=bhelgaas@google.com \
--cc=jonathan.derrick@linux.dev \
--cc=kurt.schwemmer@microsemi.com \
--cc=linux-pci@vger.kernel.org \
--cc=logang@deltatee.com \
--cc=nirmal.patel@linux.intel.com \
--cc=phasta@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