Skip to content

Commit 8b3b8fb

Browse files
ConchuODdlezcano
authored andcommitted
RISC-V: time: initialize hrtimer based broadcast clock event device
Similarly to commit 022eb8a ("ARM: 8938/1: kernel: initialize broadcast hrtimer based clock event device"), RISC-V needs to initiate hrtimer based broadcast clock event device before C3STOP can be used. Otherwise, the introduction of C3STOP for the RISC-V arch timer in commit 232ccac ("clocksource/drivers/riscv: Events are stopped during CPU suspend") leaves us without any broadcast timer registered. This prevents the kernel from entering oneshot mode, which breaks timer behaviour, for example clock_nanosleep(). A test app that sleeps each cpu for 6, 5, 4, 3 ms respectively, HZ=250 & C3STOP enabled, the sleep times are rounded up to the next jiffy: == CPU: 1 == == CPU: 2 == == CPU: 3 == == CPU: 4 == Mean: 7.974992 Mean: 7.976534 Mean: 7.962591 Mean: 3.952179 Std Dev: 0.154374 Std Dev: 0.156082 Std Dev: 0.171018 Std Dev: 0.076193 Hi: 9.472000 Hi: 10.495000 Hi: 8.864000 Hi: 4.736000 Lo: 6.087000 Lo: 6.380000 Lo: 4.872000 Lo: 3.403000 Samples: 521 Samples: 521 Samples: 521 Samples: 521 Link: https://lore.kernel.org/linux-riscv/YzYTNQRxLr7Q9JR0@spud/ Fixes: 232ccac ("clocksource/drivers/riscv: Events are stopped during CPU suspend") Suggested-by: Samuel Holland <[email protected]> Signed-off-by: Conor Dooley <[email protected]> Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Samuel Holland <[email protected]> Acked-by: Palmer Dabbelt <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Daniel Lezcano <[email protected]>
1 parent b3cbfb7 commit 8b3b8fb

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

arch/riscv/kernel/time.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
#include <linux/of_clk.h>
8+
#include <linux/clockchips.h>
89
#include <linux/clocksource.h>
910
#include <linux/delay.h>
1011
#include <asm/sbi.h>
@@ -29,6 +30,8 @@ void __init time_init(void)
2930

3031
of_clk_init(NULL);
3132
timer_probe();
33+
34+
tick_setup_hrtimer_broadcast();
3235
}
3336

3437
void clocksource_arch_init(struct clocksource *cs)

0 commit comments

Comments
 (0)