public inbox for rust-for-linux@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] rust: pci: add capability lookup helpers
@ 2026-01-31  4:01 Zijing Zhang
  2026-01-31  4:01 ` [PATCH 1/2] " Zijing Zhang
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Zijing Zhang @ 2026-01-31  4:01 UTC (permalink / raw)
  To: dakr, linux-pci, rust-for-linux
  Cc: bhelgaas, kwilczynski, ojeda, gary, Zijing Zhang

This series adds small helpers to locate PCI capabilities from Rust.

It introduces `pci::Device::{find_capability, find_ext_capability}`, thin
wrappers around the PCI core helpers (`pci_find_capability()` and
`pci_find_ext_capability()`), returning the config-space offset when
present.

An in-tree user is added to the Rust PCI sample driver to exercise the
new API.
The sample attempts to locate a few common capabilities (standard and
extended) and prints whether they are present. It also includes best-effort
self-checks to
try to hit the `Some(offset)` path when the device advertises a standard
capability list or has PCIe extended configuration space.

This patchset intentionally stays policy-free: no Rust-only
range/alignment checks, and no capability parsing.

Testing

Build:
  - x86_64 defconfig-based kernel with Rust enabled
    (out-of-tree build: `make O=...`).
  - `CONFIG_SAMPLES_RUST=y`
  - `CONFIG_SAMPLE_RUST_DRIVER_PCI=y`

Runtime:
  - QEMU x86_64 with `-device pci-testdev`
    (capability lists are not advertised in this configuration).
  - QEMU x86_64 (q35) with an NVMe device
    (exercised the `Some(offset)` path via
     `find_capability(PCI_CAP_ID_EXP)` returning `Some(0x80)`).


Zijing Zhang (2):
  rust: pci: add capability lookup helpers
  samples: rust: pci: exercise capability lookup

 rust/kernel/pci.rs              | 36 +++++++++++++
 samples/rust/rust_driver_pci.rs | 90 +++++++++++++++++++++++++++++++++
 2 files changed, 126 insertions(+)

-- 
2.52.0


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

end of thread, other threads:[~2026-02-01  6:24 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-31  4:01 [PATCH 0/2] rust: pci: add capability lookup helpers Zijing Zhang
2026-01-31  4:01 ` [PATCH 1/2] " Zijing Zhang
2026-01-31  4:02 ` [PATCH 2/2] samples: rust: pci: exercise capability lookup Zijing Zhang
2026-01-31  9:17   ` kernel test robot
2026-01-31 13:34   ` Dirk Behme
2026-01-31 14:22     ` Zijing Zhang
2026-01-31  9:51 ` [PATCH v2 0/2] rust: pci: add capability lookup helpers Zijing Zhang
2026-01-31  9:51   ` [PATCH v2 1/2] " Zijing Zhang
2026-01-31  9:51   ` [PATCH v2 2/2] samples: rust: pci: exercise capability lookup Zijing Zhang
2026-01-31 15:17 ` [PATCH v3 0/2] rust: pci: add capability lookup helpers Zijing Zhang
2026-01-31 15:17   ` [PATCH v3 1/2] " Zijing Zhang
2026-02-01  6:24     ` Dirk Behme
2026-01-31 15:17   ` [PATCH v3 2/2] samples: rust: pci: exercise capability lookup Zijing Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox