summaryrefslogtreecommitdiff
path: root/rust/helpers/pci.c
diff options
context:
space:
mode:
authorAlistair Popple <apopple@nvidia.com>2025-07-30 11:34:17 +1000
committerDanilo Krummrich <dakr@kernel.org>2025-08-15 20:25:42 +0200
commitb6a37d1d4694111895248b771513153ccace606a (patch)
treef11fd86f14370ff09bc7b61fa71a137caa5e68a6 /rust/helpers/pci.c
parentcd58b0b11d2160b174f82b71eb3847457aedaeca (diff)
rust: Add several miscellaneous PCI helpers
Add bindings to obtain a PCI device's resource start address, bus/ device function, revision ID and subsystem device and vendor IDs. These will be used by the nova-core GPU driver which is currently in development. Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Cc: Danilo Krummrich <dakr@kernel.org> Cc: Bjorn Helgaas <bhelgaas@google.com> Cc: Krzysztof Wilczyński <kwilczynski@kernel.org> Cc: Miguel Ojeda <ojeda@kernel.org> Cc: Alex Gaynor <alex.gaynor@gmail.com> Cc: Boqun Feng <boqun.feng@gmail.com> Cc: Gary Guo <gary@garyguo.net> Cc: Björn Roy Baron <bjorn3_gh@protonmail.com> Cc: Benno Lossin <lossin@kernel.org> Cc: Andreas Hindborg <a.hindborg@kernel.org> Cc: Alice Ryhl <aliceryhl@google.com> Cc: Trevor Gross <tmgross@umich.edu> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Rafael J. Wysocki <rafael@kernel.org> Cc: John Hubbard <jhubbard@nvidia.com> Cc: Alexandre Courbot <acourbot@nvidia.com> Cc: linux-pci@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Alistair Popple <apopple@nvidia.com> Link: https://lore.kernel.org/r/20250730013417.640593-2-apopple@nvidia.com Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Diffstat (limited to 'rust/helpers/pci.c')
-rw-r--r--rust/helpers/pci.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/rust/helpers/pci.c b/rust/helpers/pci.c
index 5bf56004478c..fb814572b236 100644
--- a/rust/helpers/pci.c
+++ b/rust/helpers/pci.c
@@ -2,6 +2,16 @@
#include <linux/pci.h>
+u16 rust_helper_pci_dev_id(struct pci_dev *dev)
+{
+ return PCI_DEVID(dev->bus->number, dev->devfn);
+}
+
+resource_size_t rust_helper_pci_resource_start(struct pci_dev *pdev, int bar)
+{
+ return pci_resource_start(pdev, bar);
+}
+
resource_size_t rust_helper_pci_resource_len(struct pci_dev *pdev, int bar)
{
return pci_resource_len(pdev, bar);