Skip to contentSkip to conversation

PCI: Provide pci_free_irq_vectors() for CONFIG_PCI=n

PATCH Superseded Boqun Feng 7 participants 10 messages Dec 15, 2025 – Dec 26, 2025

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Boqun Feng

author
#0 lore raw

PATCH 1/1 PCI: Provide pci_free_irq_vectors() for CONFIG_PCI=n

Commit 473b9f331718 ("rust: pci: fix build failure when CONFIG_PCI_MSI is disabled") fixed a build error by providing rust helpers when CONFIG_PCI_MSI=n. However the rust helpers rely on the pci_alloc_irq_vectors() function is defined, which is not true when CONFIG_PCI=n. There are multiple ways to fix this, e.g. a possible fix could be just remove the calling of pci_alloc_irq_vectors() since it's empty when CONFIG_PCI_MSI=n anyway. However, since PCI irq APIs, such as pci_alloc_irq_vectors(), are already defined even when CONFIG_PCI=n, the more reasonable fix is to define pci_alloc_irq_vectors() when CONFIG_PCI=n and this aligns with the situations of other primitives as well.

Fixes 473b9f331718 ("rust: pci: fix build failure when CONFIG_PCI_MSI is disabled")

---
I hit a build error without this:

../rust/helpers/pci.c:36:2: error: call to undeclared function 'pci_free_irq_vectors'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]

   36 |         pci_free_irq_vectors(dev);
      |         ^
../rust/helpers/pci.c:36:2: note: did you mean 'pci_alloc_irq_vectors'?
../include/linux/pci.h:2208:1: note: 'pci_alloc_irq_vectors' declared here
 2208 | pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs,
      | ^

1 error generated.

when ./tools/testing/kunit/kunit.py run --make_options LLVM=1 --arch arm64 --kconfig_add CONFIG_RUST=y rust_doctests_kernel

 include/linux/pci.h | 4 ++++
 1 file changed, 4 insertions(+)
include/linux/pci.h +4 -0
index 864775651c6f..b5cc0c2b9906 100644
@@ -2210,6 +2210,10 @@ pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs,
 {
 	return -ENOSPC;
 }
+
+static inline void pci_free_irq_vectors(struct pci_dev *dev)
+{
+}
 #endif /* CONFIG_PCI */
 
 /* Include architecture-dependent settings and functions */
Signature · 1 line
2.51.0
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 12 lines · Boqun Feng

Commit 473b9f331718 ("rust: pci: fix build failure when CONFIG_PCI_MSI is disabled") fixed a build error by providing rust helpers when CONFIG_PCI_MSI=n. However the rust helpers rely on the pci_alloc_irq_vectors() function is defined, which is not true when CONFIG_PCI=n. There are multiple ways to fix this, e.g. a possible fix could be just remove the calling of pci_alloc_irq_vectors() since it's empty when CONFIG_PCI_MSI=n anyway. However, since PCI irq APIs, such as pci_alloc_irq_vectors(), are already defined even when CONFIG_PCI=n, the more reasonable fix is to define pci_alloc_irq_vectors() when CONFIG_PCI=n and this aligns with the situations of other primitives as well.

Quoted 2 lines
Fixes 473b9f331718 ("rust: pci: fix build failure when CONFIG_PCI_MSI is disabled")

Bjorn, I assume you will pick this up? Otherwise I can pick it up as well, I will likely send a -fixes PR for -rc2 anyways.

Reviewed-by on v1 1/1
#2 lore raw
In reply to Boqun Feng
Quoted 49 lines · Boqun Feng

Commit 473b9f331718 ("rust: pci: fix build failure when CONFIG_PCI_MSI is disabled") fixed a build error by providing rust helpers when CONFIG_PCI_MSI=n. However the rust helpers rely on the pci_alloc_irq_vectors() function is defined, which is not true when CONFIG_PCI=n. There are multiple ways to fix this, e.g. a possible fix could be just remove the calling of pci_alloc_irq_vectors() since it's empty when CONFIG_PCI_MSI=n anyway. However, since PCI irq APIs, such as pci_alloc_irq_vectors(), are already defined even when CONFIG_PCI=n, the more reasonable fix is to define pci_alloc_irq_vectors() when CONFIG_PCI=n and this aligns with the situations of other primitives as well.

Fixes 473b9f331718 ("rust: pci: fix build failure when CONFIG_PCI_MSI is disabled")

---
I hit a build error without this:

../rust/helpers/pci.c:36:2: error: call to undeclared function 'pci_free_irq_vectors'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]

   36 |         pci_free_irq_vectors(dev);
      |         ^
../rust/helpers/pci.c:36:2: note: did you mean 'pci_alloc_irq_vectors'?
../include/linux/pci.h:2208:1: note: 'pci_alloc_irq_vectors' declared here
 2208 | pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs,
      | ^

1 error generated.

when ./tools/testing/kunit/kunit.py run --make_options LLVM=1 --arch arm64 --kconfig_add CONFIG_RUST=y rust_doctests_kernel

 include/linux/pci.h | 4 ++++
 1 file changed, 4 insertions(+)
include/linux/pci.h +4 -0
index 864775651c6f..b5cc0c2b9906 100644
@@ -2210,6 +2210,10 @@ pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs,
 {
 	return -ENOSPC;
 }
+
+static inline void pci_free_irq_vectors(struct pci_dev *dev)
+{
+}
 #endif /* CONFIG_PCI */
 
 /* Include architecture-dependent settings and functions */
Signature · 1 line
2.51.0

Thanks for the fix. I ran into this when building next-20251217 for a machine without PCIe and was happy to find this on lore.

Drew

Reviewed-by on v1 1/1
#3 lore raw
In reply to Boqun Feng
Quoted 13 lines · Boqun Feng

Commit 473b9f331718 ("rust: pci: fix build failure when CONFIG_PCI_MSI is disabled") fixed a build error by providing rust helpers when CONFIG_PCI_MSI=n. However the rust helpers rely on the pci_alloc_irq_vectors() function is defined, which is not true when CONFIG_PCI=n. There are multiple ways to fix this, e.g. a possible fix could be just remove the calling of pci_alloc_irq_vectors() since it's empty when CONFIG_PCI_MSI=n anyway. However, since PCI irq APIs, such as pci_alloc_irq_vectors(), are already defined even when CONFIG_PCI=n, the more reasonable fix is to define pci_alloc_irq_vectors() when CONFIG_PCI=n and this aligns with the situations of other primitives as well.

Quoted 3 lines
Fixes 473b9f331718 ("rust: pci: fix build failure when CONFIG_PCI_MSI is disabled")

---

Thanks very much!

Cheers,
-- David

Reviewed-by on v1 1/1
#4 lore raw
In reply to Boqun Feng
Quoted 12 lines · Boqun Feng

Commit 473b9f331718 ("rust: pci: fix build failure when CONFIG_PCI_MSI is disabled") fixed a build error by providing rust helpers when CONFIG_PCI_MSI=n. However the rust helpers rely on the pci_alloc_irq_vectors() function is defined, which is not true when CONFIG_PCI=n. There are multiple ways to fix this, e.g. a possible fix could be just remove the calling of pci_alloc_irq_vectors() since it's empty when CONFIG_PCI_MSI=n anyway. However, since PCI irq APIs, such as pci_alloc_irq_vectors(), are already defined even when CONFIG_PCI=n, the more reasonable fix is to define pci_alloc_irq_vectors() when CONFIG_PCI=n and this aligns with the situations of other primitives as well.

Quoted 2 lines
Fixes 473b9f331718 ("rust: pci: fix build failure when CONFIG_PCI_MSI is disabled")
#5 lore raw
In reply to Boqun Feng
Quoted 13 lines · Boqun Feng

Commit 473b9f331718 ("rust: pci: fix build failure when CONFIG_PCI_MSI is disabled") fixed a build error by providing rust helpers when CONFIG_PCI_MSI=n. However the rust helpers rely on the pci_alloc_irq_vectors() function is defined, which is not true when CONFIG_PCI=n. There are multiple ways to fix this, e.g. a possible fix could be just remove the calling of pci_alloc_irq_vectors() since it's empty when CONFIG_PCI_MSI=n anyway. However, since PCI irq APIs, such as pci_alloc_irq_vectors(), are already defined even when CONFIG_PCI=n, the more reasonable fix is to define pci_alloc_irq_vectors() when CONFIG_PCI=n and this aligns with the situations of other primitives as well.

Quoted 2 lines
Fixes 473b9f331718 ("rust: pci: fix build failure when CONFIG_PCI_MSI is disabled")

Related: https://lore.kernel.org/rust-for-linux/[email protected]/

I guess it counts as a report, so we may want a Reported-by (Cc'ing Tomo).

Cheers,
Miguel

#6 lore raw
Quoted 14 lines · On Thu, 25 Dec 2025 10:10:04 +0100 Miguel Ojeda…
Quoted 13 lines · Boqun Feng

Commit 473b9f331718 ("rust: pci: fix build failure when CONFIG_PCI_MSI is disabled") fixed a build error by providing rust helpers when CONFIG_PCI_MSI=n. However the rust helpers rely on the pci_alloc_irq_vectors() function is defined, which is not true when CONFIG_PCI=n. There are multiple ways to fix this, e.g. a possible fix could be just remove the calling of pci_alloc_irq_vectors() since it's empty when CONFIG_PCI_MSI=n anyway. However, since PCI irq APIs, such as pci_alloc_irq_vectors(), are already defined even when CONFIG_PCI=n, the more reasonable fix is to define pci_alloc_irq_vectors() when CONFIG_PCI=n and this aligns with the situations of other primitives as well.

Quoted 6 lines
Quoted 2 lines
Fixes 473b9f331718 ("rust: pci: fix build failure when CONFIG_PCI_MSI is disabled")

Related: https://lore.kernel.org/rust-for-linux/[email protected]/

I guess it counts as a report, so we may want a Reported-by (Cc'ing Tomo).

Since pci.rs is only compiled when CONFIG_PCI is enabled. So it seems consistent to treat the PCI helpers the same way. That said, this approach is also fine by me: it's already inconsistent that pci_alloc_irq_vectors() has a stuf definition, while pci_free_irq_vectors does not.

author
#7 lore raw
Quoted 22 lines · FUJITA Tomonori
Quoted 19 lines · On Thu, 25 Dec 2025 10:10:04 +0100 Miguel Ojeda…
Quoted 13 lines · Boqun Feng

Commit 473b9f331718 ("rust: pci: fix build failure when CONFIG_PCI_MSI is disabled") fixed a build error by providing rust helpers when CONFIG_PCI_MSI=n. However the rust helpers rely on the pci_alloc_irq_vectors() function is defined, which is not true when CONFIG_PCI=n. There are multiple ways to fix this, e.g. a possible fix could be just remove the calling of pci_alloc_irq_vectors() since it's empty when CONFIG_PCI_MSI=n anyway. However, since PCI irq APIs, such as pci_alloc_irq_vectors(), are already defined even when CONFIG_PCI=n, the more reasonable fix is to define pci_alloc_irq_vectors() when CONFIG_PCI=n and this aligns with the situations of other primitives as well.

Quoted 2 lines
Fixes 473b9f331718 ("rust: pci: fix build failure when CONFIG_PCI_MSI is disabled")

Related: https://lore.kernel.org/rust-for-linux/[email protected]/

Quoted 7 lines
Quoted 1 line

I guess it counts as a report, so we may want a Reported-by (Cc'ing Tomo).

Since pci.rs is only compiled when CONFIG_PCI is enabled. So it seems consistent to treat the PCI helpers the same way. That said, this approach is also fine by me: it's already inconsistent that pci_alloc_irq_vectors() has a stuf definition, while pci_free_irq_vectors does not.

Yes, I think providing a stub pci_free_irq_vectors() is the way to go. If you are OK with it, I could send a v2 with your and Liang Jie's Reported-by. Alternatively, since you're the first one sending the fix, and I would have replied that with the suggestion if I didn't miss that, feel free to send a v2 (providing the stub pci_free_irq_vectors()) from you ;-)

Regards,
Boqun

#8 lore raw
Quoted 31 lines · On Thu, 25 Dec 2025 18:19:08 +0800 Boqun Feng <[email protected]> wrote:
Quoted 22 lines · FUJITA Tomonori
Quoted 19 lines · On Thu, 25 Dec 2025 10:10:04 +0100 Miguel Ojeda…
Quoted 13 lines · Boqun Feng

Commit 473b9f331718 ("rust: pci: fix build failure when CONFIG_PCI_MSI is disabled") fixed a build error by providing rust helpers when CONFIG_PCI_MSI=n. However the rust helpers rely on the pci_alloc_irq_vectors() function is defined, which is not true when CONFIG_PCI=n. There are multiple ways to fix this, e.g. a possible fix could be just remove the calling of pci_alloc_irq_vectors() since it's empty when CONFIG_PCI_MSI=n anyway. However, since PCI irq APIs, such as pci_alloc_irq_vectors(), are already defined even when CONFIG_PCI=n, the more reasonable fix is to define pci_alloc_irq_vectors() when CONFIG_PCI=n and this aligns with the situations of other primitives as well.

Quoted 2 lines
Fixes 473b9f331718 ("rust: pci: fix build failure when CONFIG_PCI_MSI is disabled")

Related: https://lore.kernel.org/rust-for-linux/[email protected]/

Quoted 7 lines
Quoted 1 line

I guess it counts as a report, so we may want a Reported-by (Cc'ing Tomo).

Since pci.rs is only compiled when CONFIG_PCI is enabled. So it seems consistent to treat the PCI helpers the same way. That said, this approach is also fine by me: it's already inconsistent that pci_alloc_irq_vectors() has a stuf definition, while pci_free_irq_vectors does not.

Quoted 3 lines

Yes, I think providing a stub pci_free_irq_vectors() is the way to go. If you are OK with it, I could send a v2 with your and Liang Jie's Reported-by.

It works for me. Please go ahead.

author
#9 lore raw
In reply to Miguel Ojeda
Quoted 14 lines · Miguel Ojeda
Quoted 13 lines · Boqun Feng

Commit 473b9f331718 ("rust: pci: fix build failure when CONFIG_PCI_MSI is disabled") fixed a build error by providing rust helpers when CONFIG_PCI_MSI=n. However the rust helpers rely on the pci_alloc_irq_vectors() function is defined, which is not true when CONFIG_PCI=n. There are multiple ways to fix this, e.g. a possible fix could be just remove the calling of pci_alloc_irq_vectors() since it's empty when CONFIG_PCI_MSI=n anyway. However, since PCI irq APIs, such as pci_alloc_irq_vectors(), are already defined even when CONFIG_PCI=n, the more reasonable fix is to define pci_alloc_irq_vectors() when CONFIG_PCI=n and this aligns with the situations of other primitives as well.

Quoted 5 lines
Quoted 2 lines
Fixes 473b9f331718 ("rust: pci: fix build failure when CONFIG_PCI_MSI is disabled")

Related: https://lore.kernel.org/rust-for-linux/[email protected]/

Thanks! I was missing that, and I should have replied Tomo's patch.

Quoted 2 lines

I guess it counts as a report, so we may want a Reported-by (Cc'ing Tomo).

Tomo, how do you feel about two fix approaches? I think providing dummy pci_free_irq_vectors() is better because it's easier and aligned with other pci_*() APIs.

Regards,
Boqun

Quoted 2 lines

Cheers,
Miguel