[PATCH v3 00/10] Add Rust PCI SR-IOV support

From: Zhi Wang

Date: Wed Sep 30 2026 - 06:21:37 EST


Rust PCI drivers need to configure SR-IOV and let VF drivers borrow
selected PF-owned data. This series provides those operations and a
registration that keeps the shared data available until VF removal
completes.

This builds on Peter Colberg's Rust PCI SR-IOV series [1] and Danilo
Krummrich's typed PF registration design [2]. The PF/VF sample demonstrates
the interface using QEMU's 82576 emulation.

Following Danilo's review, drivers now implement separate sriov_enable()
and sriov_disable() callbacks. Each receives pinned driver data and a
token for the requested operation. Enabling VFs returns a guard that
disables them if later setup fails. Returning the guard successfully
leaves the VFs enabled, with VfRegistration owning their final teardown.
Drivers that do not share data with VFs can register ().

The series is based on driver-core-testing.

Changes since v2 [3]:
- Keep enable_sriov() and disable_sriov() internal to Device<CoreInternal>.
Add the callback tokens and rollback guard in a separate patch.
- Replace sriov_configure() in the Rust Driver trait with paired enable
and disable callbacks.
- Remove explicit SR-IOV cleanup from the PCI remove adapter and leave
it to VfRegistration.
- Move the SR-IOV implementation into CONFIG_PCI_IOV-gated pci/iov.rs.
- Remove the registration's published flag and raw-pointer accessors;
- Restrict num_vf() to the PCI core callback context to serialize it
with VF configuration.
- Remove the separate PF device accessor and match the auxiliary bus's
model.
- Update the sample for the split callbacks and Peter's email address
throughout the series.

[1] https://lore.kernel.org/rust-for-linux/20260303-rust-pci-sriov-v3-0-4443c35f0c88@xxxxxxxxxx/
[2] https://lore.kernel.org/nova-gpu/DLCRZLO06SIO.LS7TWQXIPZSQ@xxxxxxxxxx/
[3] https://lore.kernel.org/rust-for-linux/20260924190556.1620886-1-zhiw@xxxxxxxxxx/

John Hubbard (1):
rust: pci: add is_virtfn(), to check for VFs

Peter Colberg (6):
rust: pci: add internal SR-IOV enable and disable helpers
rust: pci: add vtable attribute to pci::Driver trait
rust: pci: add is_physfn(), to check for PFs
rust: pci: add num_vf(), to return number of VFs
rust: pci: add SR-IOV enable and disable callbacks
samples: rust: add Rust SR-IOV VF driver sample

Zhi Wang (3):
rust: pci: drop driver data before remove returns
rust: pci: add typed SR-IOV PF registration data
rust: pci: add SR-IOV enable and disable tokens

MAINTAINERS | 1 +
drivers/gpu/nova-core/driver.rs | 1 +
include/linux/pci.h | 7 +
rust/kernel/device.rs | 4 +-
rust/kernel/pci.rs | 103 +++++++
rust/kernel/pci/iov.rs | 413 ++++++++++++++++++++++++++
samples/rust/Kconfig | 11 +
samples/rust/Makefile | 1 +
samples/rust/rust_dma.rs | 1 +
samples/rust/rust_driver_auxiliary.rs | 1 +
samples/rust/rust_driver_pci.rs | 1 +
samples/rust/rust_driver_sriov.rs | 249 ++++++++++++++++
12 files changed, 791 insertions(+), 2 deletions(-)
create mode 100644 rust/kernel/pci/iov.rs
create mode 100644 samples/rust/rust_driver_sriov.rs


base-commit: c15c5befd6d6150e92ab7c6c7fde1088e0f543e6
--
2.53.0