| 9a52a8f5 | 14-Mar-2026 |
Alexandre Courbot <acourbot@nvidia.com> |
rust: io: introduce `write_reg` and `LocatedRegister`
Some I/O types, like fixed address registers, carry their location alongside their values. For these types, the regular `Io::write` method can l
rust: io: introduce `write_reg` and `LocatedRegister`
Some I/O types, like fixed address registers, carry their location alongside their values. For these types, the regular `Io::write` method can lead into repeating the location information twice: once to provide the location itself, another time to build the value.
We are also considering supporting making all register values carry their full location information for convenience and safety.
Add a new `Io::write_reg` method that takes a single argument implementing `LocatedRegister`, a trait that decomposes implementors into a `(location, value)` tuple. This allows write operations on fixed offset registers to be done while specifying their name only once.
Suggested-by: Danilo Krummrich <dakr@kernel.org> Link: https://lore.kernel.org/all/DH0XBLXZD81K.22SWIZ1ZAOW1@kernel.org/ Signed-off-by: Alexandre Courbot <acourbot@nvidia.com> Link: https://patch.msgid.link/20260314-register-v9-8-86805b2f7e9d@nvidia.com [ Replace FIFO with VERSION register in the examples. - Danilo ] Signed-off-by: Danilo Krummrich <dakr@kernel.org>
show more ...
|
| 20ba6a1d | 14-Mar-2026 |
Alexandre Courbot <acourbot@nvidia.com> |
rust: io: add `register!` macro
Add a macro for defining hardware register types with I/O accessors.
Each register field is represented as a `Bounded` of the appropriate bit width, ensuring field v
rust: io: add `register!` macro
Add a macro for defining hardware register types with I/O accessors.
Each register field is represented as a `Bounded` of the appropriate bit width, ensuring field values are never silently truncated.
Fields can optionally be converted to/from custom types, either fallibly or infallibly.
The address of registers can be direct, relative, or indexed, supporting most of the patterns in which registers are arranged.
Suggested-by: Danilo Krummrich <dakr@kernel.org> Link: https://lore.kernel.org/all/20250306222336.23482-6-dakr@kernel.org/ Co-developed-by: Gary Guo <gary@garyguo.net> Signed-off-by: Gary Guo <gary@garyguo.net> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com> Link: https://patch.msgid.link/20260314-register-v9-7-86805b2f7e9d@nvidia.com [ * Improve wording and formatting of doc-comments, * Import build_assert!(), * Add missing inline annotations, * Call static_assert!() with absolute path, * Use expect instead of allow.
- Danilo ] Signed-off-by: Danilo Krummrich <dakr@kernel.org>
show more ...
|
| dd6ff5cf | 12-Nov-2025 |
Alice Ryhl <aliceryhl@google.com> |
rust: io: add typedef for phys_addr_t
The C typedef phys_addr_t is missing an analogue in Rust, meaning that we end up using bindings::phys_addr_t or ResourceSize as a replacement in various places
rust: io: add typedef for phys_addr_t
The C typedef phys_addr_t is missing an analogue in Rust, meaning that we end up using bindings::phys_addr_t or ResourceSize as a replacement in various places throughout the kernel. Fix that by introducing a new typedef on the Rust side. Place it next to the existing ResourceSize typedef since they're quite related to each other.
Cc: stable@vger.kernel.org # for v6.18 [1] Signed-off-by: Alice Ryhl <aliceryhl@google.com> Link: https://patch.msgid.link/20251112-resource-phys-typedefs-v2-4-538307384f82@google.com Link: https://lore.kernel.org/all/20251112-resource-phys-typedefs-v2-0-538307384f82@google.com/ [1] Signed-off-by: Danilo Krummrich <dakr@kernel.org>
show more ...
|
| dfd67993 | 12-Nov-2025 |
Alice Ryhl <aliceryhl@google.com> |
rust: io: move ResourceSize to top-level io module
Resource sizes are a general concept for dealing with physical addresses, and not specific to the Resource type, which is just one way to access ph
rust: io: move ResourceSize to top-level io module
Resource sizes are a general concept for dealing with physical addresses, and not specific to the Resource type, which is just one way to access physical addresses. Thus, move the typedef to the io module.
Still keep a re-export under resource. This avoids this commit from being a flag-day, but I also think it's a useful re-export in general so that you can import
use kernel::io::resource::{Resource, ResourceSize};
instead of having to write
use kernel::io::{ resource::Resource, ResourceSize, };
in the specific cases where you need ResourceSize because you are using the Resource type. Therefore I think it makes sense to keep this re-export indefinitely and it is *not* intended as a temporary re-export for migration purposes.
Cc: stable@vger.kernel.org # for v6.18 [1] Signed-off-by: Alice Ryhl <aliceryhl@google.com> Link: https://patch.msgid.link/20251112-resource-phys-typedefs-v2-2-538307384f82@google.com Link: https://lore.kernel.org/all/20251112-resource-phys-typedefs-v2-0-538307384f82@google.com/ [1] Signed-off-by: Danilo Krummrich <dakr@kernel.org>
show more ...
|
| 919b7292 | 12-Nov-2025 |
Alice Ryhl <aliceryhl@google.com> |
rust: io: define ResourceSize as resource_size_t
These typedefs are always equivalent so this should not change anything, but the code makes a lot more sense like this.
Cc: stable@vger.kernel.org S
rust: io: define ResourceSize as resource_size_t
These typedefs are always equivalent so this should not change anything, but the code makes a lot more sense like this.
Cc: stable@vger.kernel.org Signed-off-by: Alice Ryhl <aliceryhl@google.com> Fixes: 493fc33ec252 ("rust: io: add resource abstraction") Link: https://patch.msgid.link/20251112-resource-phys-typedefs-v2-1-538307384f82@google.com Signed-off-by: Danilo Krummrich <dakr@kernel.org>
show more ...
|
| 9d39842f | 04-Nov-2025 |
Danilo Krummrich <dakr@kernel.org> |
rust: io: cleanup imports and use "kernel vertical" style
Commit 46f045db5a94 ("rust: Add read_poll_timeout_atomic function") initiated the first import change in the I/O module using the agreed "ke
rust: io: cleanup imports and use "kernel vertical" style
Commit 46f045db5a94 ("rust: Add read_poll_timeout_atomic function") initiated the first import change in the I/O module using the agreed "kernel vertical" import style [1].
For consistency throughout the module, adjust all other imports accordingly.
While at it, drop unnecessary imports covered by prelude::*.
Link: https://docs.kernel.org/rust/coding-guidelines.html#imports [1] Reviewed-by: Zhi Wang <zhiw@nvidia.com> Link: https://patch.msgid.link/20251104133301.59402-1-dakr@kernel.org [ Use prelude::* in io/poll.rs. - Danilo ] Signed-off-by: Danilo Krummrich <dakr@kernel.org>
show more ...
|
| 51a486fe | 22-Jul-2025 |
Miguel Ojeda <ojeda@kernel.org> |
rust: io: fix broken intra-doc links to `platform::Device`
`platform` is not accessible from here.
Thus fix the intra-doc links by qualifying the paths a bit more.
Fixes: 1d0d4b28513b ("rust: io:
rust: io: fix broken intra-doc links to `platform::Device`
`platform` is not accessible from here.
Thus fix the intra-doc links by qualifying the paths a bit more.
Fixes: 1d0d4b28513b ("rust: io: mem: add a generic iomem abstraction") Signed-off-by: Miguel Ojeda <ojeda@kernel.org> Link: https://lore.kernel.org/r/20250722085500.1360401-2-ojeda@kernel.org Signed-off-by: Danilo Krummrich <dakr@kernel.org>
show more ...
|
| 83fb6160 | 22-Jul-2025 |
Miguel Ojeda <ojeda@kernel.org> |
rust: io: fix broken intra-doc link to missing `flags` module
There is no `mod flags` in this case, unlike others. Instead, they are associated constants for the `Flags` type.
Thus reword the sente
rust: io: fix broken intra-doc link to missing `flags` module
There is no `mod flags` in this case, unlike others. Instead, they are associated constants for the `Flags` type.
Thus reword the sentence to fix the broken intra-doc link, providing an example of constant and linking to it to clarify which ones we are referring to.
Fixes: 493fc33ec252 ("rust: io: add resource abstraction") Signed-off-by: Miguel Ojeda <ojeda@kernel.org> Link: https://lore.kernel.org/r/20250722085500.1360401-1-ojeda@kernel.org Signed-off-by: Danilo Krummrich <dakr@kernel.org>
show more ...
|
| 696b2a6c | 19-Jul-2025 |
Danilo Krummrich <dakr@kernel.org> |
rust: io: mem: enable IoRequest doc-tests
When introduced, the IoRequest doc-tests did depend on infrastructure added in subsequent patches, hence they temporarily had to be disabled.
Now that we h
rust: io: mem: enable IoRequest doc-tests
When introduced, the IoRequest doc-tests did depend on infrastructure added in subsequent patches, hence they temporarily had to be disabled.
Now that we have the corresponding platform device infrastructure, enable them.
Link: https://lore.kernel.org/r/DBG39YMN2TX6.1VR4PEQSI8PSG@kernel.org Signed-off-by: Danilo Krummrich <dakr@kernel.org>
show more ...
|
| bc4f9045 | 17-Jul-2025 |
Daniel Almeida <daniel.almeida@collabora.com> |
rust: platform: add resource accessors
The previous patches have added the abstractions for Resources and the ability to map them and therefore read and write the underlying memory .
The only thing
rust: platform: add resource accessors
The previous patches have added the abstractions for Resources and the ability to map them and therefore read and write the underlying memory .
The only thing missing to make this accessible for platform devices is to provide accessors that return instances of IoRequest<'a>. These ensure that the resource are valid only for the lifetime of the platform device, and that the platform device is in the Bound state.
Therefore, add these accessors. Also make it possible to retrieve resources from platform devices in Rust using either a name or an index.
Acked-by: Miguel Ojeda <ojeda@kernel.org> Signed-off-by: Daniel Almeida <daniel.almeida@collabora.com> Link: https://lore.kernel.org/r/20250717-topics-tyr-platform_iomem-v15-3-beca780b77e3@collabora.com [ Remove #[expect(dead_code)] from IoRequest::new() and move SAFETY comments right on top of unsafe blocks to avoid clippy warnings for some (older) clippy versions. - Danilo ] Signed-off-by: Danilo Krummrich <dakr@kernel.org>
show more ...
|
| 1d0d4b28 | 17-Jul-2025 |
Daniel Almeida <daniel.almeida@collabora.com> |
rust: io: mem: add a generic iomem abstraction
Add a generic iomem abstraction to safely read and write ioremapped regions. This abstraction requires a previously acquired IoRequest instance. This m
rust: io: mem: add a generic iomem abstraction
Add a generic iomem abstraction to safely read and write ioremapped regions. This abstraction requires a previously acquired IoRequest instance. This makes it so that both the resource and the device match, or, in other words, that the resource is indeed a valid resource for a given bound device.
A subsequent patch will add the ability to retrieve IoRequest instances from platform devices.
The reads and writes are done through IoRaw, and are thus checked either at compile-time, if the size of the region is known at that point, or at runtime otherwise.
Non-exclusive access to the underlying memory region is made possible to cater to cases where overlapped regions are unavoidable.
Acked-by: Miguel Ojeda <ojeda@kernel.org> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Signed-off-by: Daniel Almeida <daniel.almeida@collabora.com> Link: https://lore.kernel.org/r/20250717-topics-tyr-platform_iomem-v15-2-beca780b77e3@collabora.com [ Add #[expect(dead_code)] to avoid a temporary warning, remove unnecessary OF_ID_TABLE constants in doc-tests and ignore doc-tests for now to avoid a temporary build failure. - Danilo ] Signed-off-by: Danilo Krummrich <dakr@kernel.org>
show more ...
|