When timer_calc_usec() is used with large timeout falues, such as 60s,
the function lacks precision and produces different results than when
using timer_calc(time / 1000) for the same timeout. This patch fixes
the precision issue by falling back to timer_calc(time / 1000) for
usec values over one second.

Signed-off-by: Stefan Berger <[email protected]>
---
 src/hw/timer.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/hw/timer.c b/src/hw/timer.c
index 03d22b2..2f0c864 100644
--- a/src/hw/timer.c
+++ b/src/hw/timer.c
@@ -213,6 +213,8 @@ timer_calc(u32 msecs)
 u32
 timer_calc_usec(u32 usecs)
 {
+    if (usecs > 1000000)
+        return timer_calc(usecs / 1000);
     return timer_read() + DIV_ROUND_UP(GET_GLOBAL(TimerKHz) * usecs, 1000);
 }
 
-- 
2.5.5


_______________________________________________
SeaBIOS mailing list
[email protected]
https://mail.coreboot.org/mailman/listinfo/seabios

Reply via email to