Re: [PATCH] staging: axis-fifo: flush the whole packet on RX read errors

From: Greg KH

Date: Sun Nov 29 2026 - 08:52:49 EST


On Sun, Nov 29, 2026 at 04:59:21PM +0900, Akito Nakano wrote:
> axis_fifo_read() flushes the remaining packet data from the RX FIFO
> on errors so that stale data does not remain for the next packet.
> The number of words to flush is computed as
> bytes_available / sizeof(u32), which rounds down.
>
> The RLR register reports the packet length in bytes. Packets whose
> length is not a multiple of 4 are valid for this IP, for example
> when TKEEP, the AXI4-Stream signal that marks the valid bytes of a
> beat, covers only part of the last beat. For such a packet, the
> driver reports "received a packet that isn't word-aligned" and
> flushes the FIFO, but the rounded-down word count leaves the last
> partial word in the FIFO. That leftover word is then returned as the
> first word of the next packet.
>
> This was observed on Zynq-7000 with AXI4-Stream FIFO v4.3. When a
> source whose last beat has TKEEP=0001 sends 29 bytes, RLR is 29 and
> RDFO is 8. After the failed read, sending the same packet again
> gives RDFO=9 instead of 8, and the first word read is the leftover
> one.
>
> Round the word count up so that the error path flushes the entire
> packet.
>
> Fixes: 82a051e2553b ("staging: axis-fifo: flush RX FIFO on read errors")
> Signed-off-by: Akito Nakano <kero.io.frog@xxxxxxxxx>
> ---
> drivers/staging/axis-fifo/axis-fifo.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/axis-fifo/axis-fifo.c b/drivers/staging/axis-fifo/axis-fifo.c
> index 233d2b153934..96653e4afa3d 100644
> --- a/drivers/staging/axis-fifo/axis-fifo.c
> +++ b/drivers/staging/axis-fifo/axis-fifo.c
> @@ -145,7 +145,7 @@ static ssize_t axis_fifo_read(struct file *f, char __user *buf,
> }
>
> bytes_available = ioread32(fifo->base_addr + XLLF_RLR_OFFSET);
> - words_available = bytes_available / sizeof(u32);
> + words_available = DIV_ROUND_UP(bytes_available, sizeof(u32));
>
> if (bytes_available > len) {
> ret = -EINVAL;
> --
> 2.43.0
>

If you have this hardware, any objection to moving this out of staging
and maintaining it in drivers/misc/ as a real driver? I don't think
anything is "left" to be done with it now, so I think it can be moved
out unless someone else has any issues?

thanks,

greg k-h