From: Pramod Maurya <pramod.nexgen@gmail.com>
To: gregkh@linuxfoundation.org
Cc: jacobsfeder@gmail.com, ovidiu.panait.oss@gmail.com,
gustavopiazdasilva2102@gmail.com, linux-staging@lists.linux.dev,
linux-kernel@vger.kernel.org,
Pramod Maurya <pramod.nexgen@gmail.com>
Subject: [PATCH] staging: axis-fifo: use stream accessors for FIFO data transfers
Date: Sat, 23 May 2026 15:40:09 -0400 [thread overview]
Message-ID: <20260523194009.195538-1-pramod.nexgen@gmail.com> (raw)
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
next reply other threads:[~2026-05-23 19:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-23 19:40 Pramod Maurya [this message]
2026-07-07 10:02 ` [PATCH] staging: axis-fifo: use stream accessors for FIFO data transfers Greg KH
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=20260523194009.195538-1-pramod.nexgen@gmail.com \
--to=pramod.nexgen@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=gustavopiazdasilva2102@gmail.com \
--cc=jacobsfeder@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox