serialqueue: Make 31-bit clock overflow check a little more robust

Allow reqclock to be slightly less than the transmitted messages's
deadline.  That is, delay messages with a reqclock far in the future
to slightly past (1<<31) ticks from its deadline.  Use (3<<29)
instead, which gives an additional (1<<29) grace period to avoid clock
overflows.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor
2025-12-14 15:55:57 -05:00
parent 8e6e467ebc
commit 867d73f0b8

View File

@@ -886,9 +886,10 @@ serialqueue_send_batch(struct serialqueue *sq, struct command_queue *cq
int len = 0;
struct queue_message *qm;
list_for_each_entry(qm, msgs, node) {
if (qm->min_clock + (1LL<<31) < qm->req_clock
if (qm->min_clock + (3LL<<29) < qm->req_clock
&& qm->req_clock != BACKGROUND_PRIORITY_CLOCK)
qm->min_clock = qm->req_clock - (1LL<<31);
// Avoid mcu clock comparison 31-bit overflow issues
qm->min_clock = qm->req_clock - (3LL<<29);
len += qm->len;
}
if (! len)