Skip to content

Commit e56e8bd

Browse files
atishp04palmer-dabbelt
authored andcommitted
RISCV: Disable timer interrupt in handler to fix nohz.
The timer interrupt pending bit is cleared in bbl while reprogramming the timer. This works fine unless we are in nohz mode. In nohz mode, the timer is not reprogrammed. Thus, the pending bits are not cleared leading to continuous timer interrupt firing and cpu stalls. Disable timer interrupt in interrupt handler to ignore the pending bit until next interrupt. Timer interrupt is enabled again before next timer event is set. The details of the stalls can be found in riscvarchive#127 Other possible ideas discussion: riscv-software-src/riscv-pk#108 Signed-off-by: Atish Patra <[email protected]> Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 2b030aa commit e56e8bd

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

arch/riscv/kernel/time.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ void riscv_timer_interrupt(void)
3535
*/
3636
struct clock_event_device *evdev = this_cpu_ptr(&riscv_clock_event);
3737

38+
/*
39+
* There are no direct SBI calls to clear pending timer interrupt bit.
40+
* Disable timer interrupt to ignore pending interrupt until next
41+
* interrupt.
42+
*/
43+
csr_clear(sie, SIE_STIE);
3844
evdev->event_handler(evdev);
3945
#endif
4046
}

drivers/clocksource/riscv_timer.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ static int next_event(unsigned long delta, struct clock_event_device *ce)
3838
* harts.
3939
*/
4040
BUG_ON(ce != this_cpu_ptr(&riscv_clock_event));
41+
csr_set(sie, SIE_STIE);
4142
sbi_set_timer(get_cycles64() + delta);
4243
return 0;
4344
}

0 commit comments

Comments
 (0)