]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
net: rnpgbe: fix mailbox endianness and remove pointer casts
authorDong Yibo <dong100@mucse.com>
Wed, 1 Jul 2026 03:22:08 +0000 (11:22 +0800)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 7 Jul 2026 08:45:42 +0000 (10:45 +0200)
commitd9d6d67f4c0877fde783c9d5beee013bcf1b1e85
tree255607792c371cdaf5e0999c7bee3f1574b072a4
parent3be28e2c9cd0230cb51fd4967df095273afd3848
net: rnpgbe: fix mailbox endianness and remove pointer casts

The rnpgbe mailbox exchanges data through 32-bit MMIO registers in
little-endian wire format. The original code had two problems:

  1. FW structs (with __le16/__le32 fields) were cast to (u32 *)
     before reaching the mailbox transport, hiding the endian
     annotations from sparse.

  2. No cpu_to_le32()/le32_to_cpu() conversion was done between
     CPU-endian MMIO values and the little-endian payload, causing
     data corruption on big-endian systems.

Fix by adding the missing byte-order conversions in the transport
layer and introducing union wrappers (mbx_fw_cmd_req_u,
mbx_fw_cmd_reply_u) that overlay each FW struct with a __le32
dwords[] array. Callers fill named fields using cpu_to_le16/32(),
then pass dwords[] to the transport, which now takes explicit
__le32 * instead of u32 *. This eliminates all pointer casts on
the mailbox data path and lets sparse verify the conversions.

Fixes: 4543534c3ef5 ("net: rnpgbe: Add basic mbx ops support")
Signed-off-by: Dong Yibo <dong100@mucse.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/20260701032208.1843156-2-dong100@mucse.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx.c
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx.h
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.c
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.h