rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rust: pci: fix build failure when CONFIG_PCI_MSI is disabled
@ 2025-12-02 21:01 Danilo Krummrich
  2025-12-02 21:08 ` Joel Fernandes
  2025-12-03  8:59 ` Alice Ryhl
  0 siblings, 2 replies; 3+ messages in thread
From: Danilo Krummrich @ 2025-12-02 21:01 UTC (permalink / raw)
  To: bhelgaas, kwilczynski, ojeda, alex.gaynor, boqun.feng, gary,
	bjorn3_gh, lossin, a.hindborg, aliceryhl, tmgross, joelagnelf
  Cc: linux-pci, rust-for-linux, linux-kernel, Danilo Krummrich,
	kernel test robot

When CONFIG_PCI_MSI is disabled pci_alloc_irq_vectors() and
pci_free_irq_vectors() are defined as inline functions and hence require
a Rust helper.

	error[E0425]: cannot find function `pci_alloc_irq_vectors` in crate `bindings`
	    --> rust/kernel/pci/irq.rs:144:23
	     |
	 144 | ...s::pci_alloc_irq_vectors(dev.as_raw(), min_vecs, max_vecs, irq_types.as_raw())
	     |       ^^^^^^^^^^^^^^^^^^^^^ help: a function with a similar name exists: `pci_irq_vector`
	     |
	    ::: .../rust/bindings/bindings_helpers_generated.rs:1197:5
	     |
	1197 |     pub fn pci_irq_vector(pdev: *mut pci_dev, nvec: ffi::c_uint) -> ffi::c_int;
	     |     --------------------------------------------------------------------------- similarly named function `pci_irq_vector` defined here

	error[E0425]: cannot find function `pci_free_irq_vectors` in crate `bindings`
	    --> rust/kernel/pci/irq.rs:170:28
	     |
	 170 |         unsafe { bindings::pci_free_irq_vectors(self.dev.as_raw()) };
	     |                            ^^^^^^^^^^^^^^^^^^^^ help: a function with a similar name exists: `pci_irq_vector`
	     |
	    ::: .../rust/bindings/bindings_helpers_generated.rs:1197:5
	     |
	1197 |     pub fn pci_irq_vector(pdev: *mut pci_dev, nvec: ffi::c_uint) -> ffi::c_int;
	     |     --------------------------------------------------------------------------- similarly named function `pci_irq_vector` defined here

	error: aborting due to 2 previous errors

Fix this by adding the corresponding helpers.

Fixes: 340ccc973544 ("rust: pci: Allocate and manage PCI interrupt vectors")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202512012238.YgVvRRUx-lkp@intel.com/
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
---
 rust/helpers/pci.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/rust/helpers/pci.c b/rust/helpers/pci.c
index fb814572b236..bf8173979c5e 100644
--- a/rust/helpers/pci.c
+++ b/rust/helpers/pci.c
@@ -23,9 +23,21 @@ bool rust_helper_dev_is_pci(const struct device *dev)
 }
 
 #ifndef CONFIG_PCI_MSI
+int rust_helper_pci_alloc_irq_vectors(struct pci_dev *dev,
+				      unsigned int min_vecs,
+				      unsigned int max_vecs,
+				      unsigned int flags)
+{
+	return pci_alloc_irq_vectors(dev, min_vecs, max_vecs, flags);
+}
+
+void rust_helper_pci_free_irq_vectors(struct pci_dev *dev)
+{
+	pci_free_irq_vectors(dev);
+}
+
 int rust_helper_pci_irq_vector(struct pci_dev *pdev, unsigned int nvec)
 {
 	return pci_irq_vector(pdev, nvec);
 }
-
 #endif

base-commit: d3666c1f8a31b7ff6805effcfedfac22454c6517
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] rust: pci: fix build failure when CONFIG_PCI_MSI is disabled
  2025-12-02 21:01 [PATCH] rust: pci: fix build failure when CONFIG_PCI_MSI is disabled Danilo Krummrich
@ 2025-12-02 21:08 ` Joel Fernandes
  2025-12-03  8:59 ` Alice Ryhl
  1 sibling, 0 replies; 3+ messages in thread
From: Joel Fernandes @ 2025-12-02 21:08 UTC (permalink / raw)
  To: Danilo Krummrich, bhelgaas, kwilczynski, ojeda, alex.gaynor,
	boqun.feng, gary, bjorn3_gh, lossin, a.hindborg, aliceryhl,
	tmgross
  Cc: linux-pci, rust-for-linux, linux-kernel, kernel test robot



On 12/2/2025 4:01 PM, Danilo Krummrich wrote:
> When CONFIG_PCI_MSI is disabled pci_alloc_irq_vectors() and
> pci_free_irq_vectors() are defined as inline functions and hence require
> a Rust helper.
> 
> 	error[E0425]: cannot find function `pci_alloc_irq_vectors` in crate `bindings`
> 	    --> rust/kernel/pci/irq.rs:144:23
> 	     |
> 	 144 | ...s::pci_alloc_irq_vectors(dev.as_raw(), min_vecs, max_vecs, irq_types.as_raw())
> 	     |       ^^^^^^^^^^^^^^^^^^^^^ help: a function with a similar name exists: `pci_irq_vector`
> 	     |
> 	    ::: .../rust/bindings/bindings_helpers_generated.rs:1197:5
> 	     |
> 	1197 |     pub fn pci_irq_vector(pdev: *mut pci_dev, nvec: ffi::c_uint) -> ffi::c_int;
> 	     |     --------------------------------------------------------------------------- similarly named function `pci_irq_vector` defined here
> 
> 	error[E0425]: cannot find function `pci_free_irq_vectors` in crate `bindings`
> 	    --> rust/kernel/pci/irq.rs:170:28
> 	     |
> 	 170 |         unsafe { bindings::pci_free_irq_vectors(self.dev.as_raw()) };
> 	     |                            ^^^^^^^^^^^^^^^^^^^^ help: a function with a similar name exists: `pci_irq_vector`
> 	     |
> 	    ::: .../rust/bindings/bindings_helpers_generated.rs:1197:5
> 	     |
> 	1197 |     pub fn pci_irq_vector(pdev: *mut pci_dev, nvec: ffi::c_uint) -> ffi::c_int;
> 	     |     --------------------------------------------------------------------------- similarly named function `pci_irq_vector` defined here
> 
> 	error: aborting due to 2 previous errors
> 
> Fix this by adding the corresponding helpers.
> 

Reviewed-by: Joel Fernandes <joelagnelf@nvidia.com>

thanks,

 - Joel


> Fixes: 340ccc973544 ("rust: pci: Allocate and manage PCI interrupt vectors")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202512012238.YgVvRRUx-lkp@intel.com/
> Signed-off-by: Danilo Krummrich <dakr@kernel.org>
> ---
>  rust/helpers/pci.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/rust/helpers/pci.c b/rust/helpers/pci.c
> index fb814572b236..bf8173979c5e 100644
> --- a/rust/helpers/pci.c
> +++ b/rust/helpers/pci.c
> @@ -23,9 +23,21 @@ bool rust_helper_dev_is_pci(const struct device *dev)
>  }
>  
>  #ifndef CONFIG_PCI_MSI
> +int rust_helper_pci_alloc_irq_vectors(struct pci_dev *dev,
> +				      unsigned int min_vecs,
> +				      unsigned int max_vecs,
> +				      unsigned int flags)
> +{
> +	return pci_alloc_irq_vectors(dev, min_vecs, max_vecs, flags);
> +}
> +
> +void rust_helper_pci_free_irq_vectors(struct pci_dev *dev)
> +{
> +	pci_free_irq_vectors(dev);
> +}
> +
>  int rust_helper_pci_irq_vector(struct pci_dev *pdev, unsigned int nvec)
>  {
>  	return pci_irq_vector(pdev, nvec);
>  }
> -
>  #endif
> 
> base-commit: d3666c1f8a31b7ff6805effcfedfac22454c6517


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] rust: pci: fix build failure when CONFIG_PCI_MSI is disabled
  2025-12-02 21:01 [PATCH] rust: pci: fix build failure when CONFIG_PCI_MSI is disabled Danilo Krummrich
  2025-12-02 21:08 ` Joel Fernandes
@ 2025-12-03  8:59 ` Alice Ryhl
  1 sibling, 0 replies; 3+ messages in thread
From: Alice Ryhl @ 2025-12-03  8:59 UTC (permalink / raw)
  To: Danilo Krummrich
  Cc: bhelgaas, kwilczynski, ojeda, alex.gaynor, boqun.feng, gary,
	bjorn3_gh, lossin, a.hindborg, tmgross, joelagnelf, linux-pci,
	rust-for-linux, linux-kernel, kernel test robot

On Wed, Dec 03, 2025 at 10:01:50AM +1300, Danilo Krummrich wrote:
> When CONFIG_PCI_MSI is disabled pci_alloc_irq_vectors() and
> pci_free_irq_vectors() are defined as inline functions and hence require
> a Rust helper.
> 
> 	error[E0425]: cannot find function `pci_alloc_irq_vectors` in crate `bindings`
> 	    --> rust/kernel/pci/irq.rs:144:23
> 	     |
> 	 144 | ...s::pci_alloc_irq_vectors(dev.as_raw(), min_vecs, max_vecs, irq_types.as_raw())
> 	     |       ^^^^^^^^^^^^^^^^^^^^^ help: a function with a similar name exists: `pci_irq_vector`
> 	     |
> 	    ::: .../rust/bindings/bindings_helpers_generated.rs:1197:5
> 	     |
> 	1197 |     pub fn pci_irq_vector(pdev: *mut pci_dev, nvec: ffi::c_uint) -> ffi::c_int;
> 	     |     --------------------------------------------------------------------------- similarly named function `pci_irq_vector` defined here
> 
> 	error[E0425]: cannot find function `pci_free_irq_vectors` in crate `bindings`
> 	    --> rust/kernel/pci/irq.rs:170:28
> 	     |
> 	 170 |         unsafe { bindings::pci_free_irq_vectors(self.dev.as_raw()) };
> 	     |                            ^^^^^^^^^^^^^^^^^^^^ help: a function with a similar name exists: `pci_irq_vector`
> 	     |
> 	    ::: .../rust/bindings/bindings_helpers_generated.rs:1197:5
> 	     |
> 	1197 |     pub fn pci_irq_vector(pdev: *mut pci_dev, nvec: ffi::c_uint) -> ffi::c_int;
> 	     |     --------------------------------------------------------------------------- similarly named function `pci_irq_vector` defined here
> 
> 	error: aborting due to 2 previous errors
> 
> Fix this by adding the corresponding helpers.
> 
> Fixes: 340ccc973544 ("rust: pci: Allocate and manage PCI interrupt vectors")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202512012238.YgVvRRUx-lkp@intel.com/
> Signed-off-by: Danilo Krummrich <dakr@kernel.org>

It may make sense to add __rust_helper to these helpers right away.

otherwise:
Reviewed-by: Alice Ryhl <aliceryhl@google.com>

Alice

For context:
https://lore.kernel.org/all/20251202-define-rust-helper-v1-0-a2e13cbc17a6@google.com/


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-12-03  8:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-02 21:01 [PATCH] rust: pci: fix build failure when CONFIG_PCI_MSI is disabled Danilo Krummrich
2025-12-02 21:08 ` Joel Fernandes
2025-12-03  8:59 ` Alice Ryhl

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).