[PATCH v6 3/7] char: xillybus: Avoid possible bandwidth inefficiency
From: Eli Billauer
Date: Fri Oct 09 2026 - 03:49:17 EST
The host flow controls the payload data flow from the FPGA by sending
OPCODE_SET_CHECKPOINT messages. Fix the condition for sending such a
message, to correctly handle the case where leap < 0.
The previous expression leap > (fifo->size >> 3) was not intended to
evaluate true when leap is negative. However, due to C's integer
promotion rules, leap (of s32 type) is promoted to unsigned int when
compared with the unsigned fifo->size >> 3 expression. As a result,
negative leap values are interpreted as large positive numbers, causing
the condition to evaluate true unintentionally.
Consequently, the device receives correctly formed checkpoint messages
that encourage it to send data, but too frequently. This may cause the
device to send short data chunks, wasting USB bandwidth.
Assisted-by: Deepseek:v4-pro Kimi:K2.6 ChatGPT:GPT-5.5 Claude:Sonnet-4.6
Signed-off-by: Eli Billauer <eli.billauer@xxxxxxxxx>
---
Notes:
Changelog:
=========
Change v5->v6: Rebase to current tree
No change on v4->v5.
No change on v3->v4.
Changes v2->v3:
-- Add Assisted-by tag to description
No change on v1->v2.
drivers/char/xillybus/xillyusb.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/char/xillybus/xillyusb.c b/drivers/char/xillybus/xillyusb.c
index 9de4298209e7..9182817c435b 100644
--- a/drivers/char/xillybus/xillyusb.c
+++ b/drivers/char/xillybus/xillyusb.c
@@ -1501,8 +1501,8 @@ static ssize_t xillyusb_read(struct file *filp, char __user *userbuf,
*/
if (chan->read_data_ok &&
- (leap > (fifo->size >> 3) ||
- (checkpoint_for_complete && leap > 0))) {
+ (leap > 0 && (leap > (fifo->size >> 3) ||
+ checkpoint_for_complete))) {
chan->in_current_checkpoint = checkpoint;
rc = xillyusb_send_opcode(xdev, chan_num,
OPCODE_SET_CHECKPOINT,
--
2.34.1