dff64b07 | 02-May-2025 |
FUJITA Tomonori <fujita.tomonori@gmail.com> |
rust: Add warn_on macro
Add warn_on macro, uses the BUG/WARN feature (lib/bug.c) via assembly for x86_64/arm64/riscv.
The current Rust code simply wraps BUG() macro but doesn't provide the proper d
rust: Add warn_on macro
Add warn_on macro, uses the BUG/WARN feature (lib/bug.c) via assembly for x86_64/arm64/riscv.
The current Rust code simply wraps BUG() macro but doesn't provide the proper debug information. The BUG/WARN feature can only be used from assembly.
This uses the assembly code exported by the C side via ARCH_WARN_ASM macro. To avoid duplicating the assembly code, this approach follows the same strategy as the static branch code: it generates the assembly code for Rust using the C preprocessor at compile time.
Similarly, ARCH_WARN_REACHABLE is also used at compile time to generate the assembly code; objtool's reachable annotation code. It's used for only architectures that use objtool.
For now, Loongarch and arm just use a wrapper for WARN macro.
UML doesn't use the assembly BUG/WARN feature; just wrapping generic BUG/WARN functions implemented in C works.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Link: https://lore.kernel.org/r/20250502094537.231725-5-fujita.tomonori@gmail.com [ Avoid evaluating the condition twice (a good idea in general, but it also matches the C side). Simplify with `as_char_ptr()` to avoid a cast. Cast to `ffi` integer types for `warn_slowpath_fmt`. Avoid cast for `null()`. - Miguel ] Signed-off-by: Miguel Ojeda <ojeda@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 ...
|
493fc33e | 17-Jul-2025 |
Daniel Almeida <daniel.almeida@collabora.com> |
rust: io: add resource abstraction
In preparation for ioremap support, add a Rust abstraction for struct resource.
A future commit will introduce the Rust API to ioremap a resource from a platform
rust: io: add resource abstraction
In preparation for ioremap support, add a Rust abstraction for struct resource.
A future commit will introduce the Rust API to ioremap a resource from a platform device. The current abstraction, therefore, adds only the minimum API needed to get that done.
Acked-by: Miguel Ojeda <ojeda@kernel.org> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Co-developed-by: Fiona Behrens <me@kloenk.dev> Signed-off-by: Fiona Behrens <me@kloenk.dev> Signed-off-by: Daniel Almeida <daniel.almeida@collabora.com> Link: https://lore.kernel.org/r/20250717-topics-tyr-platform_iomem-v15-1-beca780b77e3@collabora.com [ Capitalize safety comments and end it with a period. - Danilo ] Signed-off-by: Danilo Krummrich <dakr@kernel.org>
show more ...
|
c46f6024 | 21-Jun-2025 |
Danilo Krummrich <dakr@kernel.org> |
rust: auxiliary: use generic device drvdata accessors
Take advantage of the generic drvdata accessors of the generic Device type.
While at it, use from_result() instead of match.
Link: https://lor
rust: auxiliary: use generic device drvdata accessors
Take advantage of the generic drvdata accessors of the generic Device type.
While at it, use from_result() instead of match.
Link: https://lore.kernel.org/r/20250621195118.124245-6-dakr@kernel.org Signed-off-by: Danilo Krummrich <dakr@kernel.org>
show more ...
|
4231712c | 21-Jun-2025 |
Danilo Krummrich <dakr@kernel.org> |
rust: pci: use generic device drvdata accessors
Take advantage of the generic drvdata accessors of the generic Device type.
While at it, use from_result() instead of match.
Link: https://lore.kern
rust: pci: use generic device drvdata accessors
Take advantage of the generic drvdata accessors of the generic Device type.
While at it, use from_result() instead of match.
Link: https://lore.kernel.org/r/20250621195118.124245-5-dakr@kernel.org Signed-off-by: Danilo Krummrich <dakr@kernel.org>
show more ...
|
f0a68a91 | 21-Jun-2025 |
Danilo Krummrich <dakr@kernel.org> |
rust: platform: use generic device drvdata accessors
Take advantage of the generic drvdata accessors of the generic Device type.
While at it, use from_result() instead of match.
Link: https://lore
rust: platform: use generic device drvdata accessors
Take advantage of the generic drvdata accessors of the generic Device type.
While at it, use from_result() instead of match.
Link: https://lore.kernel.org/r/20250621195118.124245-4-dakr@kernel.org Signed-off-by: Danilo Krummrich <dakr@kernel.org>
show more ...
|
880dec12 | 21-Jun-2025 |
Danilo Krummrich <dakr@kernel.org> |
rust: device: add drvdata accessors
Implement generic accessors for the private data of a driver bound to a device.
Those accessors should be used by bus abstractions from their corresponding core
rust: device: add drvdata accessors
Implement generic accessors for the private data of a driver bound to a device.
Those accessors should be used by bus abstractions from their corresponding core callbacks, such as probe(), remove(), etc.
Implementing them for device::CoreInternal guarantees that driver's can't interfere with the logic implemented by the bus abstraction.
Acked-by: Benno Lossin <lossin@kernel.org> Link: https://lore.kernel.org/r/20250621195118.124245-3-dakr@kernel.org [ Improve safety comment as proposed by Benno. - Danilo ] Signed-off-by: Danilo Krummrich <dakr@kernel.org>
show more ...
|
d4b29ddf | 17-Jun-2025 |
FUJITA Tomonori <fujita.tomonori@gmail.com> |
rust: time: Add wrapper for fsleep() function
Add a wrapper for fsleep(), flexible sleep functions in include/linux/delay.h which typically deals with hardware delays.
The kernel supports several s
rust: time: Add wrapper for fsleep() function
Add a wrapper for fsleep(), flexible sleep functions in include/linux/delay.h which typically deals with hardware delays.
The kernel supports several sleep functions to handle various lengths of delay. This adds fsleep(), automatically chooses the best sleep method based on a duration.
fsleep() can only be used in a nonatomic context. This requirement is not checked by these abstractions, but it is intended that klint [1] or a similar tool will be used to check it in the future.
Link: https://rust-for-linux.com/klint [1] Reviewed-by: Gary Guo <gary@garyguo.net> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Fiona Behrens <me@kloenk.dev> Tested-by: Daniel Almeida <daniel.almeida@collabora.com> Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org> Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com> Link: https://lore.kernel.org/r/20250617144155.3903431-3-fujita.tomonori@gmail.com Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
show more ...
|
46ae8fd7 | 26-Jun-2025 |
Danilo Krummrich <dakr@kernel.org> |
rust: devres: replace Devres::new_foreign_owned()
Replace Devres::new_foreign_owned() with devres::register().
The current implementation of Devres::new_foreign_owned() creates a full Devres contai
rust: devres: replace Devres::new_foreign_owned()
Replace Devres::new_foreign_owned() with devres::register().
The current implementation of Devres::new_foreign_owned() creates a full Devres container instance, including the internal Revocable and completion.
However, none of that is necessary for the intended use of giving full ownership of an object to devres and getting it dropped once the given device is unbound.
Hence, implement devres::register(), which is limited to consume the given data, wrap it in a KBox and drop the KBox once the given device is unbound, without any other synchronization.
Cc: Dave Airlie <airlied@redhat.com> Cc: Simona Vetter <simona.vetter@ffwll.ch> Cc: Viresh Kumar <viresh.kumar@linaro.org> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Benno Lossin <lossin@kernel.org> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Link: https://lore.kernel.org/r/20250626200054.243480-3-dakr@kernel.org Signed-off-by: Danilo Krummrich <dakr@kernel.org>
show more ...
|
cc6d1098 | 10-Jun-2025 |
FUJITA Tomonori <fujita.tomonori@gmail.com> |
rust: time: Add ktime_get() to ClockSource trait
Introduce the ktime_get() associated function to the ClockSource trait, allowing each clock source to specify how it retrieves the current time. This
rust: time: Add ktime_get() to ClockSource trait
Introduce the ktime_get() associated function to the ClockSource trait, allowing each clock source to specify how it retrieves the current time. This enables Instant::now() to be implemented generically using the type-level ClockSource abstraction.
This change enhances the type safety and extensibility of timekeeping by statically associating time retrieval mechanisms with their respective clock types. It also reduces the reliance on hardcoded clock logic within Instant.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com> Link: https://lore.kernel.org/r/20250610093258.3435874-4-fujita.tomonori@gmail.com Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
show more ...
|