:: commit 706bbac2343eb83c2c491551e19926ad01879c02

Mintsuki <mintsuki@protonmail.com> — 2026-02-24 06:11

parents: aad4f66fec

sys/cpu: Round up stall() tick count for sub-MHz timer frequencies

diff --git a/common/sys/cpu.h b/common/sys/cpu.h
index 41c7576b..f8ee3b39 100644
--- a/common/sys/cpu.h
+++ b/common/sys/cpu.h
@@ -424,7 +424,7 @@ static inline void stall(uint64_t us) {
         return;
     }
 #endif
-    uint64_t ticks = tsc_freq * us / 1000000;
+    uint64_t ticks = (tsc_freq * us + 999999) / 1000000;
     uint64_t next_stop = rdtsc() + ticks;
     while (rdtsc() < next_stop);
 }
tab: 248 wrap: offon