linux-stable/arch/riscv/kernel
Conor Dooley 80f3c56c15 RISC-V: time: initialize hrtimer based broadcast clock event device
[ Upstream commit 8b3b8fbb48 ]

Similarly to commit 022eb8ae8b ("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 232ccac1bd ("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: 232ccac1bd ("clocksource/drivers/riscv: Events are stopped during CPU suspend")
Suggested-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Reviewed-by: Samuel Holland <samuel@sholland.org>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Link: https://lore.kernel.org/r/20230103141102.772228-2-apatel@ventanamicro.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-03-11 16:31:38 +01:00
..
vdso RISC-V: vdso: Do not add missing symbols to version section in linker script 2022-12-08 11:18:29 +01:00
.gitignore RISC-V: Build Infrastructure 2017-09-26 15:26:49 -07:00
asm-offsets.c
cacheinfo.c drivers: base: cacheinfo: Get rid of DEFINE_SMP_CALL_CACHE_FUNCTION() 2021-09-26 13:39:48 +02:00
cpu.c
cpufeature.c RISC-V: User-facing API 2017-09-26 15:26:48 -07:00
entry.S riscv,entry: fix misaligned base for excp_vect_table 2021-04-16 11:49:30 +02:00
ftrace.c RISC-V: Take text_mutex in ftrace_init_nop() 2020-10-01 13:14:50 +02:00
head.S RISC-V: Add the directive for alignment of stvec's value 2018-08-13 08:31:31 -07:00
irq.c clocksource: new RISC-V SBI timer driver 2018-08-13 08:31:31 -07:00
Makefile perf: riscv: preliminary RISC-V support 2018-06-04 14:02:01 -07:00
mcount-dyn.S riscv/ftrace: Add DYNAMIC_FTRACE_WITH_REGS support 2018-04-02 19:59:13 -07:00
mcount.S riscv: Workaround mcount name prior to clang-13 2021-05-22 10:59:49 +02:00
module-sections.c RISC-V: Add section of GOT.PLT for kernel module 2018-04-02 20:00:54 -07:00
module.c riscv: Fix auipc+jalr relocation range checks 2022-03-16 13:20:27 +01:00
module.lds riscv module: remove (NOLOAD) 2022-04-15 14:15:00 +02:00
perf_event.c RISC-V: Fix !CONFIG_SMP compilation error 2018-08-13 08:31:32 -07:00
process.c riscv: process: fix kernel info leakage 2022-11-25 17:40:18 +01:00
ptrace.c riscv: fix trace_sys_exit hook 2019-02-20 10:25:40 +01:00
reset.c
riscv_ksyms.c riscv: split the declaration of __copy_user 2018-06-09 12:34:31 -07:00
setup.c riscv: set max_pfn to the PFN of the last page 2020-05-27 17:37:28 +02:00
signal.c RISC-V: User-facing API 2017-09-26 15:26:48 -07:00
smp.c RISC-V: simplify software interrupt / IPI code 2018-08-13 08:31:30 -07:00
smpboot.c clocksource: new RISC-V SBI timer driver 2018-08-13 08:31:31 -07:00
stacktrace.c riscv: stacktrace: Fix undefined reference to `walk_stackframe' 2020-06-03 08:19:30 +02:00
sys_riscv.c riscv: Allow PROT_WRITE-only mmap() 2022-10-26 13:19:21 +02:00
syscall_table.c RISC-V: Make __NR_riscv_flush_icache visible to userspace 2018-01-07 15:14:37 -08:00
time.c RISC-V: time: initialize hrtimer based broadcast clock event device 2023-03-11 16:31:38 +01:00
traps.c exit: Add and use make_task_dead. 2023-02-06 07:49:45 +01:00
vdso.c riscv: remove redundant unlikely() 2018-01-30 19:12:06 -08:00
vmlinux.lds.S RISC-V: Build Infrastructure 2017-09-26 15:26:49 -07:00