Skip to content

Commit 52ff2b8

Browse files
ovpanaitgregkh
authored andcommitted
staging: axis-fifo: fix maximum TX packet length check
Since commit 2ca34b5 ("staging: axis-fifo: Correct handling of tx_fifo_depth for size validation"), write() operations with packets larger than 'tx_fifo_depth - 4' words are no longer rejected with -EINVAL. Fortunately, the packets are not actually getting transmitted to hardware, otherwise they would be raising a 'Transmit Packet Overrun Error' interrupt, which requires a reset of the TX circuit to recover from. Instead, the request times out inside wait_event_interruptible_timeout() and always returns -EAGAIN, since the wake up condition can never be true for these packets. But still, they unnecessarily block other tasks from writing to the FIFO and the EAGAIN return code signals userspace to retry the write() call, even though it will always fail and time out. According to the AXI4-Stream FIFO reference manual (PG080), the maximum valid packet length is 'tx_fifo_depth - 4' words, so attempting to send larger packets is invalid and should not be happening in the first place: > The maximum packet that can be transmitted is limited by the size of > the FIFO, which is (C_TX_FIFO_DEPTH–4)*(data interface width/8) bytes. Therefore, bring back the old behavior and outright reject packets larger than 'tx_fifo_depth - 4' with -EINVAL. Add a comment to explain why the check is necessary. The dev_err() message was removed to avoid cluttering the dmesg log if an invalid packet is received from userspace. Fixes: 2ca34b5 ("staging: axis-fifo: Correct handling of tx_fifo_depth for size validation") Cc: stable@vger.kernel.org Signed-off-by: Ovidiu Panait <ovidiu.panait.oss@gmail.com> Link: https://lore.kernel.org/r/20250817171350.872105-1-ovidiu.panait.oss@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 8f5ae30 commit 52ff2b8

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

drivers/staging/axis-fifo/axis-fifo.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,11 +322,17 @@ static ssize_t axis_fifo_write(struct file *f, const char __user *buf,
322322
return -EINVAL;
323323
}
324324

325-
if (words_to_write > fifo->tx_fifo_depth) {
326-
dev_err(fifo->dt_device, "tried to write more words [%u] than slots in the fifo buffer [%u]\n",
327-
words_to_write, fifo->tx_fifo_depth);
325+
/*
326+
* In 'Store-and-Forward' mode, the maximum packet that can be
327+
* transmitted is limited by the size of the FIFO, which is
328+
* (C_TX_FIFO_DEPTH–4)*(data interface width/8) bytes.
329+
*
330+
* Do not attempt to send a packet larger than 'tx_fifo_depth - 4',
331+
* otherwise a 'Transmit Packet Overrun Error' interrupt will be
332+
* raised, which requires a reset of the TX circuit to recover.
333+
*/
334+
if (words_to_write > (fifo->tx_fifo_depth - 4))
328335
return -EINVAL;
329-
}
330336

331337
if (fifo->write_flags & O_NONBLOCK) {
332338
/*

0 commit comments

Comments
 (0)