From: Greg KH <gregkh@linuxfoundation.org>
To: Akito Nakano <kero.io.frog@gmail.com>
Cc: ovidiu.panait.oss@gmail.com, linux-staging@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: axis-fifo: flush the whole packet on RX read errors
Date: Sun, 29 Nov 2026 14:52:40 +0100 [thread overview]
Message-ID: <2026112903-diffusion-babied-69aa@gregkh> (raw)
In-Reply-To: <20261129075921.2897492-1-kero.io.frog@gmail.com>
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@gmail.com>
> ---
> 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
next prev parent reply other threads:[~2026-11-29 13:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 7:59 [PATCH] staging: axis-fifo: flush the whole packet on RX read errors Akito Nakano
2026-11-29 13:52 ` Greg KH [this message]
2026-11-30 14:11 ` IO KeRo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2026112903-diffusion-babied-69aa@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=kero.io.frog@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=ovidiu.panait.oss@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.