From 48a5647796ffa766c825d47b16d75ae31cebce2c Mon Sep 17 00:00:00 2001 From: sigsegv7 Date: Fri, 15 Sep 2023 23:09:33 -0400 Subject: kernel: dev: Handle faulty HPET in msleep routine Signed-off-by: sigsegv7 --- sys/dev/timer/hpet.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sys/dev/timer/hpet.c b/sys/dev/timer/hpet.c index 1089096..d276456 100644 --- a/sys/dev/timer/hpet.c +++ b/sys/dev/timer/hpet.c @@ -95,7 +95,7 @@ hpet_write(uint32_t reg, uint64_t val) mmio_write64(addr, val); } -void +int hpet_msleep(size_t ms) { uint64_t caps; @@ -103,6 +103,11 @@ hpet_msleep(size_t ms) uint64_t counter_val; volatile size_t ticks; + /* Don't even try if faulty, would probably cause deadlock */ + if (is_faulty) { + return 1; + } + caps = hpet_read(HPET_REG_CAPS); period = CAP_CLK_PERIOD(caps); counter_val = hpet_read(HPET_REG_MAIN_COUNTER); @@ -112,6 +117,8 @@ hpet_msleep(size_t ms) while (hpet_read(HPET_REG_MAIN_COUNTER) < ticks) { spinwait_hint(); } + + return 0; } int -- cgit v1.2.3