This series adds read-only and write-only I/O views, and the #[ro] and #[wo] attributes to register!. An access in the wrong direction then does not compile.
This is needed by Tyr, where the doorbell registers are write-only and the CSF control and output blocks shared with the firmware must only be read by the driver. Laura's CSF interface series [1] will be the second user. Patches 1 and 2 split IoCapable into IoReadable and IoWritable, and IoCopyable into IoCopyReadable and IoCopyWritable. Patch 3 adds the ReadOnly and WriteOnly views, returned by Io::read_only() and Io::write_only(). They wrap any view, and the views projected from them keep the restriction. Patch 4 makes the primitive accessors (read32() and friends) project the view directly instead of going through the generic read and write methods. Patch 5 lets an IoLoc carry an access mode, which is applied to the view projected through it. Patch 6 adds the #[ro] and #[wo] attributes to register!. Patch 7 marks the read-only and write-only registers in Tyr. Where regs.rs does not document a mode, it follows the register permissions for v10 GPUs in Arm's kbase driver (r54p1). This is based on drm-rust-next. [1] https://lore.kernel.org/r/[email protected] Signed-off-by: Daniel Almeida <[email protected]> --- Daniel Almeida (7): rust: io: split IoCapable into IoReadable and IoWritable rust: io: split IoCopyable into IoCopyReadable and IoCopyWritable rust: io: add read-only and write-only views rust: io: project primitive accessors directly rust: io: let I/O locations carry an access mode rust: io: register: add `#[ro]` and `#[wo]` attributes drm/tyr: mark read-only and write-only registers drivers/gpu/drm/tyr/regs.rs | 77 ++++++++ rust/kernel/dma.rs | 29 +-- rust/kernel/io.rs | 416 +++++++++++++++++++++++++++++++++----------- rust/kernel/io/access.rs | 76 ++++++++ rust/kernel/io/register.rs | 71 +++++++- rust/kernel/pci/io.rs | 10 +- rust/macros/io/register.rs | 34 +++- 7 files changed, 595 insertions(+), 118 deletions(-) --- base-commit: 5a1b7121a6c4db6c0239d3ac3fd1c2bb33a40025 change-id: 20261015-io-access-modes-19ac2b0aa238 Best regards, -- Daniel Almeida <[email protected]>
