linux/samples
Danilo Krummrich b07fc8d60b I/O type generalization and projection
This series presents a major rework of I/O types, as a summary:
 
 - Make I/O regions typed. The existing untyped region still exists
   with a dynamically sized `Region` type.
 
 - Create I/O view types to represent subregion of a full I/O region mapped.
   A projection macro is added to allow safely create such subviews.
 
 - Split I/O traits, make I/O views play a central role, avoid
   duplicate monomorphization and less `unsafe` code.
 
 - Add a `SysMem` backend, and make `Coherent` implement `Io`.
 
 - Add copying methods (memcpy_{from,to}io and friends).
 
 This series generalize `Mmio` type from just an untyped region to typed
 representations (so `MmioRaw<T>` is `__iomem *T`). This allows us to remove
 the `IoKnownSize` trait; the information is sourced from just the pointer
 from the `KnownSize` trait instead.
 
 Building on top of that, `Mmio` and `ConfigSpace` have been converted to
 typed views of I/O regions rather than just a big chunk of untyped I/O
 memory. These changes made it possible to implement `Io` trait for
 `Coherent<T>`.
 
 Shared system memory, `SysMem` is also added to the series, given it
 similarity in implementation compared to `Coherent`. In fact, the series
 use `SysMem` to implement `Coherent`'s I/O methods.
 
 Built on these generalization, this series add `io_project!()`.
 `io_project!()` performs a safe way to project a bigger view to a small
 subviews, and some Nova code has been converted in this series to
 demonstrate cleanups possible with this addition.
 
 New `io_read!()`, `io_write!()` has been added that supersedes
 `dma_read!()`, `dma_write!()` macro. Although, they work for primitives
 only (to be exact, types that the backend is `IoCapable` of).
 One feature that was lost from the old `dma_read!()` and `dma_write!()`
 series was the ability to read/write a large structs. However, the
 semantics was unclear to begin with, as there was no guarantee about their
 atomicity even for structs that were small enough to fit in u32.
 
 Suggested-by: Danilo Krummrich <dakr@kernel.org>
 Link: https://rust-for-linux.zulipchat.com/#narrow/channel/288089-General/topic/Generic.20I.2FO.20backends/near/571198078
 
 This is a stable tag for other trees to merge.
 -----BEGIN PGP SIGNATURE-----
 
 iHUEABYKAB0WIQS2q/xV6QjXAdC7k+1FlHeO1qrKLgUCalVZTQAKCRBFlHeO1qrK
 LtfZAP90BcixGO6G0L0UkyJ/f2yJz9wa2xD2lCwTvEnAxDa0EwEAzRxi9a/4CVOx
 y5lnqkmV+ViRYDrSihy8r994+ADI8w0=
 =+R8A
 -----END PGP SIGNATURE-----

Merge patch series "rust: I/O type generalization and projection"

Gary Guo <gary@garyguo.net> says:

This series presents a major rework of I/O types, as a summary:

- Make I/O regions typed. The existing untyped region still exists
  with a dynamically sized `Region` type.

- Create I/O view types to represent subregion of a full I/O region mapped.
  A projection macro is added to allow safely create such subviews.

- Split I/O traits, make I/O views play a central role, avoid
  duplicate monomorphization and less `unsafe` code.

- Add a `SysMem` backend, and make `Coherent` implement `Io`.

- Add copying methods (memcpy_{from,to}io and friends).

This series generalize `Mmio` type from just an untyped region to typed
representations (so `MmioRaw<T>` is `__iomem *T`). This allows us to remove
the `IoKnownSize` trait; the information is sourced from just the pointer
from the `KnownSize` trait instead.

Building on top of that, `Mmio` and `ConfigSpace` have been converted to
typed views of I/O regions rather than just a big chunk of untyped I/O
memory. These changes made it possible to implement `Io` trait for
`Coherent<T>`.

Shared system memory, `SysMem` is also added to the series, given it
similarity in implementation compared to `Coherent`. In fact, the series
use `SysMem` to implement `Coherent`'s I/O methods.

Built on these generalization, this series add `io_project!()`.
`io_project!()` performs a safe way to project a bigger view to a small
subviews, and some Nova code has been converted in this series to
demonstrate cleanups possible with this addition.

New `io_read!()`, `io_write!()` has been added that supersedes
`dma_read!()`, `dma_write!()` macro. Although, they work for primitives
only (to be exact, types that the backend is `IoCapable` of).
One feature that was lost from the old `dma_read!()` and `dma_write!()`
series was the ability to read/write a large structs. However, the
semantics was unclear to begin with, as there was no guarantee about their
atomicity even for structs that were small enough to fit in u32.

Suggested-by: Danilo Krummrich <dakr@kernel.org>
Link: https://rust-for-linux.zulipchat.com/#narrow/channel/288089-General/topic/Generic.20I.2FO.20backends/near/571198078
Link: https://patch.msgid.link/20260706-io_projection-v6-0-72cd5d055d54@garyguo.net
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
2026-07-13 23:50:39 +02:00
..
acrn virt: acrn: Fix typos 2024-05-04 18:59:44 +02:00
auxdisplay .gitignore: prefix local generated files with a slash 2021-05-02 00:43:35 +09:00
binderfs .gitignore: prefix local generated files with a slash 2021-05-02 00:43:35 +09:00
bpf samples/bpf: Fix spelling typos in samples/bpf 2025-10-18 19:26:23 -07:00
cgroup samples/cgroup: rm unused MEMCG_EVENTS macro 2025-09-21 14:22:26 -07:00
check-exec samples/check-exec: Fix script name 2025-03-07 19:58:05 -08:00
configfs samples: configfs: Constify struct configfs_item_operations and configfs_group_operations 2026-01-15 09:27:27 +01:00
connector treewide: Switch/rename to timer_delete[_sync]() 2025-04-05 10:30:12 +02:00
coresight coresight: syscfg: Example CoreSight configuration loadable module 2021-11-26 11:34:07 -07:00
damon samples/damon/mtier: replace damon_add_region() with damon_set_regions() 2026-06-04 14:45:00 -07:00
fanotify samples: fix building fs-monitor on musl systems 2025-07-28 18:14:15 +02:00
fprobe fprobe: Use ftrace_regs in fprobe exit handler 2024-12-26 10:50:03 -05:00
ftrace samples/ftrace: Adjust LoongArch register restore order in direct calls 2025-12-31 15:19:25 +08:00
hid samples/hid: fix broken vmlinux path for VMLINUX_BTF 2025-02-04 11:07:41 +01:00
hidraw .gitignore: prefix local generated files with a slash 2021-05-02 00:43:35 +09:00
hung_task samples: enhance hung_task detector test with read-write semaphore support 2025-07-19 19:08:26 -07:00
hw_breakpoint perf/hw_breakpoint: use ERR_PTR_PCPU(), IS_ERR_PCPU() and PTR_ERR_PCPU() macros 2024-11-05 17:12:32 -08:00
kdb kdb: Rename members of struct kdbtab_t 2021-07-27 17:05:06 +01:00
kfifo kfifo: don't include dma-mapping.h in kfifo.h 2024-10-23 08:05:20 +02:00
kmemleak samples: kmemleak: print the raw pointers for debugging purposes 2025-03-16 22:06:08 -07:00
kobject samples/kobject: Constify kobject attributes 2026-07-11 20:38:01 +02:00
kprobes samples: kprobes: add missing MODULE_DESCRIPTION() macros 2024-06-12 08:44:27 +09:00
landlock samples/landlock: Add quiet flag support to sandboxer 2026-06-14 20:17:20 +02:00
livepatch samples/livepatch: add module descriptions 2025-04-11 17:32:38 -07:00
mei samples: mei: Fix building on musl libc 2025-07-16 14:17:47 +02:00
nitro_enclaves nitro_enclaves: Add fixes for checkpatch blank line reports 2021-09-14 11:11:20 +02:00
pfsm samples: Add userspace example for TI TPS6594 PFSM 2023-06-15 13:41:53 +02:00
pidfd .gitignore: prefix local generated files with a slash 2021-05-02 00:43:35 +09:00
pktgen samples: pktgen: correct dev to DEV 2024-11-13 18:54:33 -08:00
qmi samples: qmi: Use the unified QMI service ID instead of defining it locally 2026-03-15 20:54:39 -05:00
rpmsg
rust I/O type generalization and projection 2026-07-13 23:50:39 +02:00
seccomp samples: user-trap: fix strict-aliasing warning 2024-02-12 10:42:02 -08:00
timers .gitignore: prefix local generated files with a slash 2021-05-02 00:43:35 +09:00
trace_events tracing: Verify event formats that have "%*p.." 2025-04-02 09:51:26 -04:00
trace_printk
tsm-mr sample/tsm-mr: Use SHA-2 library APIs 2026-03-19 10:57:15 -07:00
uhid
user_events tracing/user_events: Use write ABI in example 2023-03-29 06:52:09 -04:00
v4l media: v4l2-pci-skeleton: Rename second ioctl handlers argument to 'void *priv' 2025-08-13 08:33:59 +02:00
vfio-mdev vfio: Adapt drivers to use the core helper vfio_check_precopy_ioctl 2026-03-19 12:32:09 -06:00
vfs Significant patch series in this pull request: 2025-12-06 14:01:20 -08:00
watch_queue samples: work around glibc redefining some of our defines wrong 2025-11-21 09:29:02 -08:00
watchdog .gitignore: prefix local generated files with a slash 2021-05-02 00:43:35 +09:00
workqueue/stall_detector workqueue: Add stall detector sample module 2026-03-05 07:30:49 -10:00
Kconfig sample/tsm-mr: Use SHA-2 library APIs 2026-03-19 10:57:15 -07:00
Makefile - The 11 patch series "Add folio_mk_pte()" from Matthew Wilcox 2025-05-31 15:44:16 -07:00