diff options
| author | Sean Cross <sean@xobs.io> | 2020-12-24 14:03:10 +0800 |
|---|---|---|
| committer | Sean Cross <sean@xobs.io> | 2020-12-24 14:03:10 +0800 |
| commit | f3e54414e5771a2463a8a93b4dcbb395584d2fe3 (patch) | |
| tree | 09af7a1f244b65158f54f315a05651334672bfbc /ports/litex/supervisor | |
| parent | 42ca57ff8f19368dff97bebd9ca0ac061b219084 (diff) | |
litex: ensure we don't re-enable interrups during ISR
During an interrupt handler, interrupts are implicitly disabled. They
will be re-enabled when the interrupt handler returns.
Due to some changes that were made, varous calls will re-enable
interrupts after they're finished. Examples of this include calling
`CALLBACK_CRITICAL_END` and getting the number of ticks with
`port_get_raw_ticks()`.
This patch prevents this from happening by doing two things:
1. Use standard calls in `port_get_raw_ticks()` to disable and re-enable
interrupts, preventing nesting issues, and
2. Increase the nesting count inside `isr()`, reflecting the implicit
call that is made by hardware when an interrupt is handled
This helps to address #3841.
Signed-off-by: Sean Cross <sean@xobs.io>
Diffstat (limited to 'ports/litex/supervisor')
| -rw-r--r-- | ports/litex/supervisor/port.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/ports/litex/supervisor/port.c b/ports/litex/supervisor/port.c index 02617b9af..9897fa397 100644 --- a/ports/litex/supervisor/port.c +++ b/ports/litex/supervisor/port.c @@ -32,6 +32,8 @@ #include "irq.h" #include "csr.h" +#include "shared-bindings/microcontroller/__init__.h" + // Global millisecond tick count. 1024 per second because most RTCs are clocked with 32.768khz // crystals. volatile uint64_t raw_ticks = 0; @@ -129,9 +131,9 @@ uint32_t port_get_saved_word(void) { uint64_t port_get_raw_ticks(uint8_t* subticks) { // Reading 64 bits may take two loads, so turn of interrupts while we do it. - irq_setie(false); + common_hal_mcu_disable_interrupts(); uint64_t raw_tick_snapshot = raw_ticks; - irq_setie(true); + common_hal_mcu_enable_interrupts(); return raw_tick_snapshot; } |
