lowRISC / qemu

Fork of QEMU for development of lowRISC platforms (including OpenTitan)
http://www.qemu.org
Other
3 stars 8 forks source link

No bite after bark by AON_TIMER #66

Closed stefanberger closed 4 months ago

stefanberger commented 4 months ago

I noticed there was not bite after the bark by the AON_TIMER. The following experimental patch fixed it for me.

diff --git a/hw/opentitan/ot_aon_timer.c b/hw/opentitan/ot_aon_timer.c
index c4ba28e82c..0f3b8d4e8c 100644
--- a/hw/opentitan/ot_aon_timer.c
+++ b/hw/opentitan/ot_aon_timer.c
@@ -258,18 +258,18 @@ static void ot_aon_timer_rearm_wdog(OtAonTimerState *s, bool reset_origin)
     uint32_t bite_threshold = s->regs[R_WDOG_BITE_THOLD];
     uint32_t threshold = 0;

-    if (count >= bark_threshold) {
-        s->regs[R_INTR_STATE] |= INTR_WDOG_TIMER_BARK_MASK;
-    } else {
-        threshold = bark_threshold;
-    }
-
     if (count >= bite_threshold) {
         s->wdog_bite = true;
-    } else if (bite_threshold < threshold) {
+    } else if (count < bite_threshold) {
         threshold = bite_threshold;
     }

+    if (count >= bark_threshold && !s->wdog_bite) {
+        s->regs[R_INTR_STATE] |= INTR_WDOG_TIMER_BARK_MASK;
+    } else if (bark_threshold < bite_threshold) {
+        threshold = bark_threshold;
+    }
+
     if (count >= threshold) {
         timer_del(s->wdog_timer);
     } else {
loiclefort commented 4 months ago

Thanks for the report. Can you give us the actual values you have configured in WDOG_BARK_THOLD and WDOG_BITE_THOLD?

stefanberger commented 4 months ago

Thanks for the report. Can you give us the actual values you have configured in WDOG_BARK_THOLD and WDOG_BITE_THOLD?

    # define AON_TIMER_FREQUENCY    62500000
    [...]
    unsigned int *wdog_bark_thold = (unsigned int *)(AON_TIMER_BASE + 0x18);
    unsigned int *wdog_bite_thold = (unsigned int *)(AON_TIMER_BASE + 0x1c);

    *wdog_bark_thold = (AON_TIMER_FREQUENCY * 5) / 10; // update every 0.5s
    *wdog_bite_thold = (AON_TIMER_FREQUENCY * 7) / 10;
rivos-eblot commented 4 months ago

Should be fixed in https://github.com/lowRISC/qemu/pull/67

stefanberger commented 4 months ago

Should be fixed in #67

Yes, it works now.