2
0
mirror of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2025-09-04 20:19:47 +08:00
linux/rust/kernel
Danilo Krummrich ce30d94e68 rust: add io::{Io, IoRaw} base types
I/O memory is typically either mapped through direct calls to ioremap()
or subsystem / bus specific ones such as pci_iomap().

Even though subsystem / bus specific functions to map I/O memory are
based on ioremap() / iounmap() it is not desirable to re-implement them
in Rust.

Instead, implement a base type for I/O mapped memory, which generically
provides the corresponding accessors, such as `Io::readb` or
`Io:try_readb`.

`Io` supports an optional const generic, such that a driver can indicate
the minimal expected and required size of the mapping at compile time.
Correspondingly, calls to the 'non-try' accessors, support compile time
checks of the I/O memory offset to read / write, while the 'try'
accessors, provide boundary checks on runtime.

`IoRaw` is meant to be embedded into a structure (e.g. pci::Bar or
io::IoMem) which creates the actual I/O memory mapping and initializes
`IoRaw` accordingly.

To ensure that I/O mapped memory can't out-live the device it may be
bound to, subsystems must embed the corresponding I/O memory type (e.g.
pci::Bar) into a `Devres` container, such that it gets revoked once the
device is unbound.

Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Tested-by: Daniel Almeida <daniel.almeida@collabora.com>
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Tested-by: Dirk Behme <dirk.behme@de.bosch.com>
Link: https://lore.kernel.org/r/20241219170425.12036-8-dakr@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-12-20 17:19:26 +01:00
..
alloc rust: alloc: Fix ArrayLayout allocations 2024-11-25 00:11:07 +01:00
block block-6.13-20242901 2024-11-30 15:47:29 -08:00
fs rust: file: add FileDescriptorReservation 2024-09-30 13:02:29 +02:00
init rust: treewide: switch to our kernel Box type 2024-10-15 22:56:59 +02:00
list rust: enable arbitrary_self_types and remove Receiver 2024-10-07 21:39:57 +02:00
net Rust changes for v6.13 2024-11-26 14:00:26 -08:00
sync rust: add rcu abstraction 2024-12-20 17:19:26 +01:00
.gitignore rust: jump_label: skip formatting generated file 2024-11-20 13:32:42 -05:00
alloc.rs rust: alloc: update module comment of alloc.rs 2024-10-15 23:10:32 +02:00
block.rs rust: block: introduce kernel::block::mq module 2024-06-14 07:45:04 -06:00
build_assert.rs rust: upgrade to Rust 1.68.2 2023-05-31 17:35:03 +02:00
cred.rs rust: file: add Kuid wrapper 2024-09-30 13:02:29 +02:00
device_id.rs rust: implement IdArray, IdTable and RawDeviceId 2024-12-20 17:19:25 +01:00
device.rs rust: add dev_* print macros. 2024-11-05 05:33:46 +01:00
driver.rs rust: implement generic driver registration 2024-12-20 17:19:25 +01:00
error.rs rust: use custom FFI integer types 2024-11-10 23:58:00 +01:00
firmware.rs rust: device: change the from_raw() function 2024-10-03 13:54:48 +02:00
fs.rs rust: file: add Rust abstraction for struct file 2024-09-30 13:02:28 +02:00
generated_arch_static_branch_asm.rs.S rust: jump_label: skip formatting generated file 2024-11-20 13:32:42 -05:00
init.rs rust: use custom FFI integer types 2024-11-10 23:58:00 +01:00
io.rs rust: add io::{Io, IoRaw} base types 2024-12-20 17:19:26 +01:00
ioctl.rs rust: start using the #[expect(...)] attribute 2024-10-07 21:39:57 +02:00
jump_label.rs rust: jump_label: skip formatting generated file 2024-11-20 13:32:42 -05:00
kunit.rs rust: kunit: use C-string literals to clean warning 2024-10-01 23:46:42 +02:00
lib.rs rust: add io::{Io, IoRaw} base types 2024-12-20 17:19:26 +01:00
list.rs rust: enable clippy::undocumented_unsafe_blocks lint 2024-10-07 21:39:05 +02:00
miscdevice.rs rust: miscdevice: add fops->show_fdinfo() hook 2024-12-16 16:12:57 +01:00
net.rs rust: core abstractions for network PHY drivers 2023-12-15 09:35:50 +00:00
page.rs rust: page: add Rust version of PAGE_ALIGN 2024-10-21 20:34:46 +02:00
pid_namespace.rs rust: add PidNamespace 2024-10-08 15:44:36 +02:00
prelude.rs Char/Misc/IIO/Whatever driver subsystem updates for 6.13-rc1 2024-11-29 11:58:27 -08:00
print.rs rust: start using the #[expect(...)] attribute 2024-10-07 21:39:57 +02:00
rbtree.rs rust: treewide: switch to our kernel Box type 2024-10-15 22:56:59 +02:00
revocable.rs rust: add Revocable type 2024-12-20 17:19:26 +01:00
security.rs rust: security: add abstraction for secctx 2024-09-30 13:02:28 +02:00
seq_file.rs rust: add seqfile abstraction 2024-10-08 14:32:39 +02:00
sizes.rs rust: sizes: add commonly used constants 2024-08-30 10:27:34 +01:00
static_assert.rs rust: static_assert: add static_assert! macro 2022-12-04 01:59:16 +01:00
std_vendor.rs rust: std_vendor: update dbg macro from Rust upstream 2024-10-10 00:33:42 +02:00
str.rs rust: use custom FFI integer types 2024-11-10 23:58:00 +01:00
sync.rs rust: add rcu abstraction 2024-12-20 17:19:26 +01:00
task.rs rust: fix up formatting after merge 2024-11-26 17:54:58 -08:00
time.rs rust: use custom FFI integer types 2024-11-10 23:58:00 +01:00
tracepoint.rs rust: add tracepoint support 2024-11-04 16:21:44 -05:00
transmute.rs rust: kernel: move FromBytes and AsBytes traits to a new transmute module 2024-10-10 00:33:42 +02:00
types.rs rust: types: add Opaque::pin_init 2024-12-20 17:19:26 +01:00
uaccess.rs rust: use custom FFI integer types 2024-11-10 23:58:00 +01:00
workqueue.rs rust: treewide: switch to our kernel Box type 2024-10-15 22:56:59 +02:00