[PATCH 0/4] rust: samples: add an EDU PCI driver sample (MMIO + IRQ + DMA)

From: Maurice Hieronymus

Date: Sun Jun 14 2026 - 12:00:48 EST


The Rust sample drivers currently exercise PCI facilities in isolation:
rust_driver_pci covers MMIO and rust_dma covers DMA, but there is no
single in-tree example that combines memory-mapped I/O, interrupts and
DMA in one driver.

This series adds one. It targets QEMU's `edu` device -- a small,
well-documented educational PCI device that supports exactly these three
facilities and ships with any recent QEMU (`-device edu`), so the sample
runs without special hardware.

The sample maps BAR0 and runs a set of MMIO self-tests (identification,
liveness, factorial), allocates an MSI vector and registers an IRQ
handler, and performs a DMA round-trip -- each stage waiting on a
Completion that the IRQ handler signals.

Prerequisites, that had to be implemented:

- pci: make Vendor::from_raw() public, so a driver can match a device
whose vendor ID has no symbolic name in pci_ids.h (QEMU's 0x1234),
matching what C drivers already do.
- pci: add a managed enable_device() wrapping pcim_enable_device(), so
the enable count stays balanced across unbind/rebind.
- completion: add complete(), so a single Completion can be reused to
wait for consecutive events (e.g. back-to-back DMA transfers).

Tested with QEMU `-device edu`;

Signed-off-by: Maurice Hieronymus <mhi@xxxxxxxxxxx>
---
Maurice Hieronymus (4):
rust: pci: make Vendor::from_raw() public
rust: pci: add managed Device::enable_device()
rust: completion: add complete()
rust: samples: add EDU PCI driver sample

rust/kernel/pci.rs | 16 ++
rust/kernel/pci/id.rs | 2 +-
rust/kernel/sync/completion.rs | 14 ++
samples/rust/Kconfig | 11 ++
samples/rust/Makefile | 1 +
samples/rust/rust_driver_edu.rs | 379 ++++++++++++++++++++++++++++++++++++++++
6 files changed, 422 insertions(+), 1 deletion(-)
---
base-commit: 48b375e482027ba6566107cec40c1b21b453fa4e
change-id: 20260614-b4-rust-pci-edu-driver-3e50db2dda0f

Best regards,
--
Maurice Hieronymus <mhi@xxxxxxxxxxx>