Commit d639f909a0 for qemu.org
commit d639f909a00ef9ca1fd367854149158e46fdad22
Author: Yashaswin Sharma Puranik <puranikyashaswinsharma@gmail.com>
Date: Wed Nov 25 10:22:05 2026 +0530
hw/net/can/ctucan: send a Ready TXT buffer that has priority 0
ctucan_send_ready_buffers() starts each round with tx_prio_max = 0 and
takes a Ready buffer only when its priority is higher. A Ready buffer
with priority 0 is never picked. It stays Ready and the frame is never
sent.
The CTU CAN FD datasheet (v2.7.0, section 2.9) has no such rule. The
Ready buffer with the highest priority is sent, and of two buffers with
equal priority the one with the lower index goes first. TX_PRIORITY
resets to 0 for every buffer but the first. Linux does not hit this
with four buffers, because it rotates the priorities 7 down to 4.
Select the first Ready buffer regardless of its priority. Replace it
only for a strictly higher priority, so that the lower index still goes
first when priorities are equal.
Fixes: aa406e8b7ecd ("hw/net/can: CTU CAN FD IP open hardware core emulation.")
Suggested-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Signed-off-by: Yashaswin Sharma Puranik <puranikyashaswinsharma@gmail.com>
Tested-by: Pavel Pisa <pisa@fel.cvut.cz>
Acked-by: Pavel Pisa <pisa@fel.cvut.cz>
Message-ID: <20261130143015.98626-2-puranikyashaswinsharma@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
diff --git a/hw/net/can/ctucan_core.c b/hw/net/can/ctucan_core.c
index f6ff4ad200..380a3ee21d 100644
--- a/hw/net/can/ctucan_core.c
+++ b/hw/net/can/ctucan_core.c
@@ -259,7 +259,7 @@ static void ctucan_send_ready_buffers(CtuCanCoreState *s)
continue;
}
prio = (s->tx_priority.u32 >> (i * 4)) & 0x7;
- if (tx_prio_max < prio) {
+ if (tx_prio_max < prio || buff2tx_idx == -1) {
tx_prio_max = prio;
buff2tx_idx = i;
}