Re: [PATCH] spi: rzv2h-rspi: fix incorrect readl() accessor for 8-bit RX path
From: Geert Uytterhoeven
Date: Mon Jun 08 2026 - 04:02:06 EST
Hi Felix,
On Fri, 5 Jun 2026 at 17:26, Felix Gu <ustc.gu@xxxxxxxxx> wrote:
> The RZV2H_RSPI_RX macro instantiation for u8 data incorrectly uses
> readl(). It performs a 32-bit read which can consume excess data and
> cause corruption.
>
> Fixes: 8b61c8919dff ("spi: Add driver for the RZ/V2H(P) RSPI IP")
> Signed-off-by: Felix Gu <ustc.gu@xxxxxxxxx>
Thanks for your patch!
> --- a/drivers/spi/spi-rzv2h-rspi.c
> +++ b/drivers/spi/spi-rzv2h-rspi.c
> @@ -137,7 +137,7 @@ RZV2H_RSPI_TX(writew, u16)
> RZV2H_RSPI_TX(writeb, u8)
> RZV2H_RSPI_RX(readl, u32)
> RZV2H_RSPI_RX(readw, u16)
> -RZV2H_RSPI_RX(readl, u8)
> +RZV2H_RSPI_RX(readb, u8)
>
> static void rzv2h_rspi_reg_rmw(const struct rzv2h_rspi_priv *rspi,
> int reg_offs, u32 bit_mask, u32 value)
>
According to Chapter 7.5 Serial Peripheral Interface (RSPI) Subsection
7.5.2.1 List of Registers, the SPI Data Register supports access sizes
of 8, 16, and 32 bits.
However, the "Access Size [bits]*1" column header has a foot note:
"Note 1. The read access size is fixed at 32 bits."
Hence that means the rzv2h_rspi_rx_u8() function as generated by the
RZV2H_RSPI_RX() macro is correct, but rzv2h_rspi_rx_u16() is not?
Also, readw() in rzv2h_rx_irq_handler() is wrong, too?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds