| 4dc0bacb | 21-Jan-2026 |
Zhi Wang <zhiw@nvidia.com> |
rust: pci: add config space read/write support
Drivers might need to access PCI config space for querying capability structures and access the registers inside the structures.
For Rust drivers need
rust: pci: add config space read/write support
Drivers might need to access PCI config space for querying capability structures and access the registers inside the structures.
For Rust drivers need to access PCI config space, the Rust PCI abstraction needs to support it in a way that upholds Rust's safety principles.
Introduce a `ConfigSpace` wrapper in Rust PCI abstraction to provide safe accessors for PCI config space. The new type implements the `Io` trait and `IoCapable<T>` for u8, u16, and u32 to share offset validation and bound-checking logic with other I/O backends.
The `ConfigSpace` type uses marker types (`Normal` and `Extended`) to represent configuration space sizes at the type level.
Cc: Alexandre Courbot <acourbot@nvidia.com> Cc: Danilo Krummrich <dakr@kernel.org> Cc: Gary Guo <gary@garyguo.net> Cc: Joel Fernandes <joelagnelf@nvidia.com> Signed-off-by: Zhi Wang <zhiw@nvidia.com> Reviewed-by: Gary Guo <gary@garyguo.net> Link: https://lore.kernel.org/all/DFV4IJDQC2J6.1Q91JOAL6CJSG@kernel.org/ [1] Link: https://patch.msgid.link/20260121202212.4438-5-zhiw@nvidia.com [ Applied the diff from [1], considering subsequent comment; remove #[expect(unused)] from define_{read,write}!(). - Danilo ] Signed-off-by: Danilo Krummrich <dakr@kernel.org>
show more ...
|
| 121d87b2 | 21-Jan-2026 |
Zhi Wang <zhiw@nvidia.com> |
rust: io: separate generic I/O helpers from MMIO implementation
The previous Io<SIZE> type combined both the generic I/O access helpers and MMIO implementation details in a single struct. This coupl
rust: io: separate generic I/O helpers from MMIO implementation
The previous Io<SIZE> type combined both the generic I/O access helpers and MMIO implementation details in a single struct. This coupling prevented reusing the I/O helpers for other backends, such as PCI configuration space.
Establish a clean separation between the I/O interface and concrete backends by separating generic I/O helpers from MMIO implementation.
Introduce a new trait hierarchy to handle different access capabilities:
- IoCapable<T>: A marker trait indicating that a backend supports I/O operations of a certain type (u8, u16, u32, or u64).
- Io trait: Defines fallible (try_read8, try_write8, etc.) and infallibile (read8, write8, etc.) I/O methods with runtime bounds checking and compile-time bounds checking.
- IoKnownSize trait: The marker trait for types support infallible I/O methods.
Move the MMIO-specific logic into a dedicated Mmio<SIZE> type that implements the Io traits. Rename IoRaw to MmioRaw and update consumers to use the new types.
Cc: Alexandre Courbot <acourbot@nvidia.com> Cc: Alice Ryhl <aliceryhl@google.com> Cc: Bjorn Helgaas <helgaas@kernel.org> Cc: Gary Guo <gary@garyguo.net> Cc: Danilo Krummrich <dakr@kernel.org> Cc: John Hubbard <jhubbard@nvidia.com> Signed-off-by: Zhi Wang <zhiw@nvidia.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Reviewed-by: Gary Guo <gary@garyguo.net> Link: https://patch.msgid.link/20260121202212.4438-3-zhiw@nvidia.com [ Add #[expect(unused)] to define_{read,write}!(). - Danilo ] Signed-off-by: Danilo Krummrich <dakr@kernel.org>
show more ...
|
| d8407396 | 05-Nov-2025 |
Danilo Krummrich <dakr@kernel.org> |
rust: pci: use "kernel vertical" style for imports
Convert all imports in the PCI Rust module to use "kernel vertical" style.
With this subsequent patches neither introduce unrelated changes nor le
rust: pci: use "kernel vertical" style for imports
Convert all imports in the PCI Rust module to use "kernel vertical" style.
With this subsequent patches neither introduce unrelated changes nor leave an inconsistent import pattern.
While at it, drop unnecessary imports covered by prelude::*.
Link: https://docs.kernel.org/rust/coding-guidelines.html#imports Reviewed-by: Zhi Wang <zhiw@nvidia.com> Link: https://patch.msgid.link/20251105120352.77603-1-dakr@kernel.org Signed-off-by: Danilo Krummrich <dakr@kernel.org>
show more ...
|
| 26c1a20b | 20-Oct-2025 |
Peter Colberg <pcolberg@redhat.com> |
rust: pci: normalise spelling of PCI BAR
Consistently refer to PCI base address register as PCI BAR. Fix spelling mistake "Mapps" -> "Maps".
Link: https://lore.kernel.org/rust-for-linux/20251015225
rust: pci: normalise spelling of PCI BAR
Consistently refer to PCI base address register as PCI BAR. Fix spelling mistake "Mapps" -> "Maps".
Link: https://lore.kernel.org/rust-for-linux/20251015225827.GA960157@bhelgaas/ Link: https://github.com/Rust-for-Linux/linux/issues/1196 Suggested-by: Bjorn Helgaas <helgaas@kernel.org> Signed-off-by: Peter Colberg <pcolberg@redhat.com> Signed-off-by: Danilo Krummrich <dakr@kernel.org>
show more ...
|
| c7f6d538 | 20-Oct-2025 |
Peter Colberg <pcolberg@redhat.com> |
rust: pci: refer to legacy as INTx interrupts
Consistently use INTx, as in the description of IrqType::Intx, to refer to the four legacy PCI interrupts, INTA#, INTB#, INTC#, and INTD#.
Link: https:
rust: pci: refer to legacy as INTx interrupts
Consistently use INTx, as in the description of IrqType::Intx, to refer to the four legacy PCI interrupts, INTA#, INTB#, INTC#, and INTD#.
Link: https://lore.kernel.org/rust-for-linux/20251015230209.GA960343@bhelgaas/ Link: https://github.com/Rust-for-Linux/linux/issues/1196 Suggested-by: Bjorn Helgaas <helgaas@kernel.org> Signed-off-by: Peter Colberg <pcolberg@redhat.com> Signed-off-by: Danilo Krummrich <dakr@kernel.org>
show more ...
|
| e6901808 | 15-Oct-2025 |
Danilo Krummrich <dakr@kernel.org> |
rust: pci: move IRQ infrastructure to separate file
Move the PCI interrupt infrastructure to a separate sub-module in order to keep things organized.
Signed-off-by: Danilo Krummrich <dakr@kernel.or
rust: pci: move IRQ infrastructure to separate file
Move the PCI interrupt infrastructure to a separate sub-module in order to keep things organized.
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
show more ...
|
| 6d97171a | 25-Sep-2025 |
John Hubbard <jhubbard@nvidia.com> |
rust: pci: display symbolic PCI vendor names
The Display implementation for Vendor was forwarding directly to Debug printing, resulting in raw hex values instead of PCI Vendor strings.
Improve thin
rust: pci: display symbolic PCI vendor names
The Display implementation for Vendor was forwarding directly to Debug printing, resulting in raw hex values instead of PCI Vendor strings.
Improve things by doing a stringify!() call for each PCI Vendor item. This now prints symbolic names such as "NVIDIA", instead of "Vendor(0x10de)". It still falls back to Debug formatting for unknown class values.
Suggested-by: Danilo Krummrich <dakr@kernel.org> Signed-off-by: John Hubbard <jhubbard@nvidia.com> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> [ Remove #[inline] for Vendor::fmt(). - Danilo ] Signed-off-by: Danilo Krummrich <dakr@kernel.org>
show more ...
|
| 1b8ac376 | 30-Aug-2025 |
John Hubbard <jhubbard@nvidia.com> |
rust: pci: use pci::Vendor instead of bindings::PCI_VENDOR_ID_*
Change Device::vendor_id() to return a Vendor type, and change DeviceId::from_id() to accept a Vendor type.
Use the new pci::Vendor i
rust: pci: use pci::Vendor instead of bindings::PCI_VENDOR_ID_*
Change Device::vendor_id() to return a Vendor type, and change DeviceId::from_id() to accept a Vendor type.
Use the new pci::Vendor in the various Rust for Linux callers who were previously using bindings::PCI_VENDOR_ID_*.
Doing so also allows removing "use kernel::bindings" entirely from most of the affected files here.
Also, mark vendor_id() as inline.
Cc: Danilo Krummrich <dakr@kernel.org> Cc: Elle Rhumsaa <elle@weathered-steel.dev> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Signed-off-by: John Hubbard <jhubbard@nvidia.com> Link: https://lore.kernel.org/r/20250829223632.144030-6-jhubbard@nvidia.com [ Replace "as a validated vendor" with "as [`Vendor`]". - Danilo ] Signed-off-by: Danilo Krummrich <dakr@kernel.org>
show more ...
|
| 5e20962a | 30-Aug-2025 |
John Hubbard <jhubbard@nvidia.com> |
rust: pci: provide access to PCI Vendor values
This allows callers to write Vendor::SOME_COMPANY instead of bindings::PCI_VENDOR_ID_SOME_COMPANY.
New APIs: Vendor::SOME_COMPANY Vendor::from
rust: pci: provide access to PCI Vendor values
This allows callers to write Vendor::SOME_COMPANY instead of bindings::PCI_VENDOR_ID_SOME_COMPANY.
New APIs: Vendor::SOME_COMPANY Vendor::from_raw() -- Only accessible from the pci (parent) module. Vendor::as_raw() Vendor: fmt::Display for Vendor
Cc: Danilo Krummrich <dakr@kernel.org> Cc: Elle Rhumsaa <elle@weathered-steel.dev> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Signed-off-by: John Hubbard <jhubbard@nvidia.com> Link: https://lore.kernel.org/r/20250829223632.144030-3-jhubbard@nvidia.com [ Minor doc-comment improvements, align Debug and Display. - Danilo ] Signed-off-by: Danilo Krummrich <dakr@kernel.org>
show more ...
|