* [PATCH] staging: axis-fifo: flush the whole packet on RX read errors
@ 2026-11-29 7:59 Akito Nakano
2026-11-29 13:52 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Akito Nakano @ 2026-11-29 7:59 UTC (permalink / raw)
To: gregkh; +Cc: ovidiu.panait.oss, linux-staging, linux-kernel, Akito Nakano
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
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] staging: axis-fifo: flush the whole packet on RX read errors
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
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2026-11-29 13:52 UTC (permalink / raw)
To: Akito Nakano; +Cc: ovidiu.panait.oss, linux-staging, linux-kernel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-29 13:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®