* [PATCH] staging: axis-fifo: use stream accessors for FIFO data transfers
@ 2026-05-23 19:40 Pramod Maurya
2026-07-07 10:02 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Pramod Maurya @ 2026-05-23 19:40 UTC (permalink / raw)
To: gregkh
Cc: jacobsfeder, ovidiu.panait.oss, gustavopiazdasilva2102,
linux-staging, linux-kernel, Pramod Maurya
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jacob Feder <jacobsfeder@gmail.com>
Cc: Ovidiu Panait <ovidiu.panait.oss@gmail.com>
Cc: Gustavo Piaz da Silva <gustavopiazdasilva2102@gmail.com>
Cc: linux-staging@lists.linux.dev
Cc: linux-kernel@vger.kernel.org
The driver uses iowrite32()/ioread32() to transfer payload data to and
from the transmit (XLLF_TDFD_OFFSET) and receive (XLLF_RDFD_OFFSET)
data FIFOs. On big-endian architectures iowrite32() maps to writel()
and ioread32() maps to readl(), both of which perform CPU-to-device
byte-swapping. For AXI-Stream FIFOs, which carry opaque byte streams,
this byte-swapping silently corrupts the payload.
Replace the per-word iowrite32()/ioread32() loops with writesl()/readsl(),
which transfer data without byte-swapping, preserving memory byte order
as required by AXI-Stream FIFO semantics.
Also convert the err_flush_rx drain loop to use batched readsl() with
min_t(unsigned int, ...) to match the types of words_available and
READ_BUF_SIZE, reusing the existing local variable copy.
Fixes: 4a965c5f89de ("staging: add driver for Xilinx AXI-Stream FIFO v4.1 IP core")
Signed-off-by: Pramod Maurya <pramod.nexgen@gmail.com>
---
drivers/staging/axis-fifo/axis-fifo.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/drivers/staging/axis-fifo/axis-fifo.c b/drivers/staging/axis-fifo/axis-fifo.c
index 1c34de020cf8..38e4a691b6dc 100644
--- a/drivers/staging/axis-fifo/axis-fifo.c
+++ b/drivers/staging/axis-fifo/axis-fifo.c
@@ -125,7 +125,6 @@ static ssize_t axis_fifo_read(struct file *f, char __user *buf,
unsigned int words_available;
unsigned int copied;
unsigned int copy;
- unsigned int i;
int ret;
u32 tmp_buf[READ_BUF_SIZE];
@@ -167,10 +166,7 @@ static ssize_t axis_fifo_read(struct file *f, char __user *buf,
while (words_available > 0) {
copy = min(words_available, READ_BUF_SIZE);
- for (i = 0; i < copy; i++) {
- tmp_buf[i] = ioread32(fifo->base_addr +
- XLLF_RDFD_OFFSET);
- }
+ readsl(fifo->base_addr + XLLF_RDFD_OFFSET, tmp_buf, copy);
words_available -= copy;
if (copy_to_user(buf + copied * sizeof(u32), tmp_buf,
@@ -186,8 +182,11 @@ static ssize_t axis_fifo_read(struct file *f, char __user *buf,
return bytes_available;
err_flush_rx:
- while (words_available--)
- ioread32(fifo->base_addr + XLLF_RDFD_OFFSET);
+ while (words_available > 0) {
+ copy = min_t(unsigned int, words_available, READ_BUF_SIZE);
+ readsl(fifo->base_addr + XLLF_RDFD_OFFSET, tmp_buf, copy);
+ words_available -= copy;
+ }
end_unlock:
mutex_unlock(&fifo->read_lock);
@@ -258,8 +257,7 @@ static ssize_t axis_fifo_write(struct file *f, const char __user *buf,
goto end_unlock;
}
- for (int i = 0; i < words_to_write; ++i)
- iowrite32(txbuf[i], fifo->base_addr + XLLF_TDFD_OFFSET);
+ writesl(fifo->base_addr + XLLF_TDFD_OFFSET, txbuf, words_to_write);
iowrite32(len, fifo->base_addr + XLLF_TLR_OFFSET);
--
2.52.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] staging: axis-fifo: use stream accessors for FIFO data transfers
2026-05-23 19:40 [PATCH] staging: axis-fifo: use stream accessors for FIFO data transfers Pramod Maurya
@ 2026-07-07 10:02 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2026-07-07 10:02 UTC (permalink / raw)
To: Pramod Maurya
Cc: jacobsfeder, ovidiu.panait.oss, gustavopiazdasilva2102,
linux-staging, linux-kernel
On Sat, May 23, 2026 at 03:40:09PM -0400, Pramod Maurya wrote:
> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Jacob Feder <jacobsfeder@gmail.com>
> Cc: Ovidiu Panait <ovidiu.panait.oss@gmail.com>
> Cc: Gustavo Piaz da Silva <gustavopiazdasilva2102@gmail.com>
> Cc: linux-staging@lists.linux.dev
> Cc: linux-kernel@vger.kernel.org
Again, why is this here?
>
> The driver uses iowrite32()/ioread32() to transfer payload data to and
> from the transmit (XLLF_TDFD_OFFSET) and receive (XLLF_RDFD_OFFSET)
> data FIFOs. On big-endian architectures iowrite32() maps to writel()
> and ioread32() maps to readl(), both of which perform CPU-to-device
> byte-swapping. For AXI-Stream FIFOs, which carry opaque byte streams,
> this byte-swapping silently corrupts the payload.
>
> Replace the per-word iowrite32()/ioread32() loops with writesl()/readsl(),
> which transfer data without byte-swapping, preserving memory byte order
> as required by AXI-Stream FIFO semantics.
>
> Also convert the err_flush_rx drain loop to use batched readsl() with
> min_t(unsigned int, ...) to match the types of words_available and
> READ_BUF_SIZE, reusing the existing local variable copy.
When you have to say "also", that's a huge hint this should be split up
into multiple changes. Please do that here.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-07 10:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-23 19:40 [PATCH] staging: axis-fifo: use stream accessors for FIFO data transfers Pramod Maurya
2026-07-07 10:02 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox