Re: [PATCH net-next v2 1/1] net: rnpgbe: fix mailbox endianness and remove pointer casts

From: Andrew Lunn

Date: Wed Jul 01 2026 - 10:58:28 EST


On Wed, Jul 01, 2026 at 11:22:08AM +0800, Dong Yibo wrote:
> 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@xxxxxxxxx>

Reviewed-by: Andrew Lunn <andrew@xxxxxxx>

Andrew