SysMemBackend's IoCapable<u64> impl is currently gated on CONFIG_64BIT,
copying the MMIO backend's restriction. MMIO needs that gate because
readq() is not available on 32bit. System memory has no such dependency:
a u64 volatile load/store compiles on any architecture, it's just not
single-copy atomic on 32bit.

Drop the gate so u64-backed types, such as bitfields, work on 32bit too.
Document the non-atomicity at the impl instead of enforcing it at build
time.

Co-developed-by: Daniel Almeida <[email protected]>
Signed-off-by: Daniel Almeida <[email protected]>
Signed-off-by: Laura Nao <[email protected]>
---
 rust/kernel/io.rs | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/rust/kernel/io.rs b/rust/kernel/io.rs
index de8ef8e2aec4..a85ddd07cb7f 100644
--- a/rust/kernel/io.rs
+++ b/rust/kernel/io.rs
@@ -1428,7 +1428,9 @@ fn io_write(view: SysMem<'_, $ty>, value: $ty) {
 impl_sysmem_io_capable!(u8);
 impl_sysmem_io_capable!(u16);
 impl_sysmem_io_capable!(u32);
-#[cfg(CONFIG_64BIT)]
+// Unlike MMIO, that needs `readq` which is not available on 32-bit, a
+// system-memory `u64` access compiles on any target. It is just not
+// single-copy atomic on 32-bit.
 impl_sysmem_io_capable!(u64);
 
 impl IoCopyable for SysMemBackend {

-- 
2.39.5

Reply via email to