|
Revision tags: v6.15, v6.15-rc7, v6.15-rc6, v6.15-rc5, v6.15-rc4, v6.15-rc3 |
|
| #
53bd9780 |
| 13-Apr-2025 |
Christian Schrefl <[email protected]> |
rust: firmware: Use `ffi::c_char` type in `FwFunc`
The `FwFunc` struct contains an function with a char pointer argument, for which a `*const u8` pointer was used. This is not really the "proper" ty
rust: firmware: Use `ffi::c_char` type in `FwFunc`
The `FwFunc` struct contains an function with a char pointer argument, for which a `*const u8` pointer was used. This is not really the "proper" type for this, so use a `*const kernel::ffi::c_char` pointer instead.
This has no real functionality changes, since now `kernel::ffi::c_char` (which bindgen uses for `char`) is now a type alias to `u8` anyways, but before commit 1bae8729e50a ("rust: map `long` to `isize` and `char` to `u8`") the concrete type of `kernel::ffi::c_char` depended on the architecture (However all supported architectures at the time mapped to `i8`).
This caused problems on the v6.13 tag when building for 32 bit arm (with my patches), since back then `*const i8` was used in the function argument and the function that bindgen generated used `*const core::ffi::c_char` which Rust mapped to `*const u8` on 32 bit arm. The stable v6.13.y branch does not have this issue since commit 1bae8729e50a ("rust: map `long` to `isize` and `char` to `u8`") was backported.
This caused the following build error: ``` error[E0308]: mismatched types --> rust/kernel/firmware.rs:20:4 | 20 | Self(bindings::request_firmware) | ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected fn pointer, found fn item | | | arguments to this function are incorrect | = note: expected fn pointer `unsafe extern "C" fn(_, *const i8, _) -> _` found fn item `unsafe extern "C" fn(_, *const u8, _) -> _ {request_firmware}` note: tuple struct defined here --> rust/kernel/firmware.rs:14:8 | 14 | struct FwFunc( | ^^^^^^
error[E0308]: mismatched types --> rust/kernel/firmware.rs:24:14 | 24 | Self(bindings::firmware_request_nowarn) | ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected fn pointer, found fn item | | | arguments to this function are incorrect | = note: expected fn pointer `unsafe extern "C" fn(_, *const i8, _) -> _` found fn item `unsafe extern "C" fn(_, *const u8, _) -> _ {firmware_request_nowarn}` note: tuple struct defined here --> rust/kernel/firmware.rs:14:8 | 14 | struct FwFunc( | ^^^^^^
error[E0308]: mismatched types --> rust/kernel/firmware.rs:64:45 | 64 | let ret = unsafe { func.0(pfw as _, name.as_char_ptr(), dev.as_raw()) }; | ------ ^^^^^^^^^^^^^^^^^^ expected `*const i8`, found `*const u8` | | | arguments to this function are incorrect | = note: expected raw pointer `*const i8` found raw pointer `*const u8`
error: aborting due to 3 previous errors ```
Fixes: de6582833db0 ("rust: add firmware abstractions") Cc: [email protected] Reviewed-by: Benno Lossin <[email protected]> Signed-off-by: Christian Schrefl <[email protected]> Acked-by: Miguel Ojeda <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Add firmware prefix to commit subject. - Danilo ] Signed-off-by: Danilo Krummrich <[email protected]>
show more ...
|
|
Revision tags: v6.15-rc2, v6.15-rc1, v6.14, v6.14-rc7, v6.14-rc6 |
|
| #
1d121a33 |
| 06-Mar-2025 |
Danilo Krummrich <[email protected]> |
rust: firmware: add `module_firmware!` macro
Analogous to the `module!` macro `module_firmware!` adds additional firmware path strings to the .modinfo section.
In contrast to `module!`, where path
rust: firmware: add `module_firmware!` macro
Analogous to the `module!` macro `module_firmware!` adds additional firmware path strings to the .modinfo section.
In contrast to `module!`, where path strings need to be string literals, path strings can be composed with the `firmware::ModInfoBuilder`.
Some drivers require a lot of firmware files (such as nova-core) and hence benefit from more flexibility composing firmware path strings.
Acked-by: Jarkko Sakkinen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Danilo Krummrich <[email protected]>
show more ...
|
| #
ef476b0d |
| 06-Mar-2025 |
Danilo Krummrich <[email protected]> |
rust: firmware: introduce `firmware::ModInfoBuilder`
The `firmware` field of the `module!` only accepts literal strings, which is due to the fact that it is implemented as a proc macro.
Some driver
rust: firmware: introduce `firmware::ModInfoBuilder`
The `firmware` field of the `module!` only accepts literal strings, which is due to the fact that it is implemented as a proc macro.
Some drivers require a lot of firmware files (such as nova-core) and hence benefit from more flexibility composing firmware path strings.
The `firmware::ModInfoBuilder` is a helper component to flexibly compose firmware path strings for the .modinfo section in const context.
It is meant to be used in combination with `kernel::module_firmware!`.
Co-developed-by: Alice Ryhl <[email protected]> Signed-off-by: Alice Ryhl <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Danilo Krummrich <[email protected]>
show more ...
|
|
Revision tags: v6.14-rc5, v6.14-rc4, v6.14-rc3, v6.14-rc2, v6.14-rc1, v6.13, v6.13-rc7, v6.13-rc6, v6.13-rc5, v6.13-rc4, v6.13-rc3, v6.13-rc2, v6.13-rc1, v6.12, v6.12-rc7, v6.12-rc6, v6.12-rc5, v6.12-rc4, v6.12-rc3, v6.12-rc2, v6.12-rc1, v6.11 |
|
| #
1bae8729 |
| 13-Sep-2024 |
Gary Guo <[email protected]> |
rust: map `long` to `isize` and `char` to `u8`
The following FFI types are replaced compared to `core::ffi`:
1. `char` type is now always mapped to `u8`, since kernel uses `-funsigned-char` on t
rust: map `long` to `isize` and `char` to `u8`
The following FFI types are replaced compared to `core::ffi`:
1. `char` type is now always mapped to `u8`, since kernel uses `-funsigned-char` on the C code. `core::ffi` maps it to platform default ABI, which can be either signed or unsigned.
2. `long` is now always mapped to `isize`. It's very common in the kernel to use `long` to represent a pointer-sized integer, and in fact `intptr_t` is a typedef of `long` in the kernel. Enforce this mapping rather than mapping to `i32/i64` depending on platform can save us a lot of unnecessary casts.
Signed-off-by: Gary Guo <[email protected]> Reviewed-by: Alice Ryhl <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Moved `uaccess` changes from the next commit, since they were irrefutable patterns that Rust >= 1.82.0 warns about. Reworded slightly and reformatted a few documentation comments. Rebased on top of `rust-next`. Added the removal of two casts to avoid Clippy warnings. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
show more ...
|
| #
cc4332af |
| 01-Oct-2024 |
Guilherme Giacomo Simoes <[email protected]> |
rust: device: change the from_raw() function
The function Device::from_raw() increments a refcount by a call to bindings::get_device(ptr). This can be confused because usually from_raw() functions d
rust: device: change the from_raw() function
The function Device::from_raw() increments a refcount by a call to bindings::get_device(ptr). This can be confused because usually from_raw() functions don't increment a refcount. Hence, rename Device::from_raw() to avoid confuion with other "from_raw" semantics.
The new name of function should be "get_device" to be consistent with the function get_device() already exist in .c files.
This function body also changed, because the `into()` will convert the `&'a Device` into `ARef<Device>` and also call `inc_ref` from the `AlwaysRefCounted` trait implemented for Device.
Signed-off-by: Guilherme Giacomo Simoes <[email protected]> Acked-by: Danilo Krummrich <[email protected]> Closes: https://github.com/Rust-for-Linux/linux/issues/1088 Reviewed-by: Boqun Feng <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
show more ...
|
|
Revision tags: v6.11-rc7, v6.11-rc6, v6.11-rc5, v6.11-rc4, v6.11-rc3, v6.11-rc2, v6.11-rc1, v6.10 |
|
| #
cd04d509 |
| 09-Jul-2024 |
Andrew Ballance <[email protected]> |
rust: firmware: fix invalid rustdoc link
remove an extra quote from the doc comment so that rustdoc no longer genertes a link to a nonexistent file.
Signed-off-by: Andrew Ballance <andrewjballance@
rust: firmware: fix invalid rustdoc link
remove an extra quote from the doc comment so that rustdoc no longer genertes a link to a nonexistent file.
Signed-off-by: Andrew Ballance <[email protected]> Reviewed-by: Danilo Krummrich <[email protected]> Acked-by: Miguel Ojeda <[email protected]> Fixes: de6582833db0 ("rust: add firmware abstractions") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
show more ...
|
| #
a23b018c |
| 08-Jul-2024 |
Danilo Krummrich <[email protected]> |
firmware_loader: fix soundness issue in `request_internal`
`request_internal` must be called with one of the following function pointers: request_firmware(), firmware_request_nowarn(), firmware_requ
firmware_loader: fix soundness issue in `request_internal`
`request_internal` must be called with one of the following function pointers: request_firmware(), firmware_request_nowarn(), firmware_request_platform() or request_firmware_direct().
The previous `FwFunc` alias did not guarantee this, which is unsound.
In order to fix this up, implement `FwFunc` as new type with a corresponding type invariant.
Reported-by: Gary Guo <[email protected]> Closes: https://lore.kernel.org/lkml/20240620143611.7995e0bb@eugeo/ Signed-off-by: Danilo Krummrich <[email protected]> Reviewed-by: Christian Schrefl <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
show more ...
|
| #
2c61b8c5 |
| 08-Jul-2024 |
Danilo Krummrich <[email protected]> |
firmware_loader: annotate doctests as `no_run`
The doctests of `Firmware` are compile-time only tests, since they require a proper `Device` and a valid path to a (firmware) blob in order to do somet
firmware_loader: annotate doctests as `no_run`
The doctests of `Firmware` are compile-time only tests, since they require a proper `Device` and a valid path to a (firmware) blob in order to do something sane on runtime - we can't satisfy both of those requirements.
Hence, configure the example as `no_run`.
Unfortunately, the kernel's Rust build system can't consider the `no_run` attribute yet. Hence, for the meantime, wrap the example code into a new function and never actually call it.
Fixes: de6582833db0 ("rust: add firmware abstractions") Signed-off-by: Danilo Krummrich <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
show more ...
|
|
Revision tags: v6.10-rc7, v6.10-rc6, v6.10-rc5 |
|
| #
bbe98f4f |
| 19-Jun-2024 |
Danilo Krummrich <[email protected]> |
firmware: rust: improve safety comments
Improve the wording of safety comments to be more explicit about what exactly is guaranteed to be valid.
Suggested-by: Benno Lossin <[email protected]>
firmware: rust: improve safety comments
Improve the wording of safety comments to be more explicit about what exactly is guaranteed to be valid.
Suggested-by: Benno Lossin <[email protected]> Signed-off-by: Danilo Krummrich <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
show more ...
|
| #
de658283 |
| 18-Jun-2024 |
Danilo Krummrich <[email protected]> |
rust: add firmware abstractions
Add an abstraction around the kernels firmware API to request firmware images. The abstraction provides functions to access the firmware's size and backing buffer.
T
rust: add firmware abstractions
Add an abstraction around the kernels firmware API to request firmware images. The abstraction provides functions to access the firmware's size and backing buffer.
The firmware is released once the abstraction instance is dropped.
Signed-off-by: Danilo Krummrich <[email protected]> Acked-by: Boqun Feng <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
show more ...
|