linux-stable/arch/loongarch/kernel
Tiezhu Yang acadbd058f LoongArch: Only call get_timer_irq() once in constant_clockevent_init()
[ Upstream commit bb7a78e343 ]

Under CONFIG_DEBUG_ATOMIC_SLEEP=y and CONFIG_DEBUG_PREEMPT=y, we can see
the following messages on LoongArch, this is because using might_sleep()
in preemption disable context.

[    0.001127] smp: Bringing up secondary CPUs ...
[    0.001222] Booting CPU#1...
[    0.001244] 64-bit Loongson Processor probed (LA464 Core)
[    0.001247] CPU1 revision is: 0014c012 (Loongson-64bit)
[    0.001250] FPU1 revision is: 00000000
[    0.001252] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:283
[    0.001255] in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 0, name: swapper/1
[    0.001257] preempt_count: 1, expected: 0
[    0.001258] RCU nest depth: 0, expected: 0
[    0.001259] Preemption disabled at:
[    0.001261] [<9000000000223800>] arch_dup_task_struct+0x20/0x110
[    0.001272] CPU: 1 PID: 0 Comm: swapper/1 Not tainted 6.2.0-rc7+ #43
[    0.001275] Hardware name: Loongson Loongson-3A5000-7A1000-1w-A2101/Loongson-LS3A5000-7A1000-1w-A2101, BIOS vUDK2018-LoongArch-V4.0.05132-beta10 12/13/202
[    0.001277] Stack : 0072617764726148 0000000000000000 9000000000222f1c 90000001001e0000
[    0.001286]         90000001001e3be0 90000001001e3be8 0000000000000000 0000000000000000
[    0.001292]         90000001001e3be8 0000000000000040 90000001001e3cb8 90000001001e3a50
[    0.001297]         9000000001642000 90000001001e3be8 be694d10ce4139dd 9000000100174500
[    0.001303]         0000000000000001 0000000000000001 00000000ffffe0a2 0000000000000020
[    0.001309]         000000000000002f 9000000001354116 00000000056b0000 ffffffffffffffff
[    0.001314]         0000000000000000 0000000000000000 90000000014f6e90 9000000001642000
[    0.001320]         900000000022b69c 0000000000000001 0000000000000000 9000000001736a90
[    0.001325]         9000000100038000 0000000000000000 9000000000222f34 0000000000000000
[    0.001331]         00000000000000b0 0000000000000004 0000000000000000 0000000000070000
[    0.001337]         ...
[    0.001339] Call Trace:
[    0.001342] [<9000000000222f34>] show_stack+0x5c/0x180
[    0.001346] [<90000000010bdd80>] dump_stack_lvl+0x60/0x88
[    0.001352] [<9000000000266418>] __might_resched+0x180/0x1cc
[    0.001356] [<90000000010c742c>] mutex_lock+0x20/0x64
[    0.001359] [<90000000002a8ccc>] irq_find_matching_fwspec+0x48/0x124
[    0.001364] [<90000000002259c4>] constant_clockevent_init+0x68/0x204
[    0.001368] [<900000000022acf4>] start_secondary+0x40/0xa8
[    0.001371] [<90000000010c0124>] smpboot_entry+0x60/0x64

Here are the complete call chains:

smpboot_entry()
  start_secondary()
    constant_clockevent_init()
      get_timer_irq()
        irq_find_matching_fwnode()
          irq_find_matching_fwspec()
            mutex_lock()
              might_sleep()
                __might_sleep()
                  __might_resched()

In order to avoid the above issue, we should break the call chains,
using timer_irq_installed variable as check condition to only call
get_timer_irq() once in constant_clockevent_init() is a simple and
proper way.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-03-22 13:37:56 +01:00
..
.gitignore
access-helper.h LoongArch: Add exception/interrupt handling 2022-06-03 20:09:28 +08:00
acpi.c LoongArch: Add suspend (ACPI S3) support 2022-12-14 08:41:53 +08:00
alternative.c LoongArch: Use common function sign_extend64() 2023-01-17 11:42:16 +08:00
asm-offsets.c LoongArch: Add basic STACKPROTECTOR support 2022-12-14 08:41:53 +08:00
cacheinfo.c LoongArch: Refactor cache probe and flush methods 2022-10-12 16:36:14 +08:00
cpu-probe.c LoongArch: Add HWCAP_LOONGARCH_CPUCFG to elf_hwcap 2023-01-17 11:42:16 +08:00
crash_dump.c LoongArch: Add kdump support 2022-10-12 16:36:19 +08:00
dma.c LoongArch: Use acpi_arch_dma_setup() and remove ARCH_HAS_PHYS_TO_DMA 2022-09-24 18:39:21 +02:00
efi-header.S efi/loongarch: Add efistub booting support 2022-09-06 11:19:34 +02:00
efi.c LoongArch changes for v6.2 2022-12-19 08:23:27 -06:00
elf.c LoongArch: Add ELF and module support 2022-06-03 20:09:28 +08:00
entry.S LoongArch: Re-tab the assembly files 2022-07-29 18:22:32 +08:00
env.c LoongArch: Add FDT booting support from efi system table 2022-12-14 08:41:53 +08:00
fpu.S LoongArch: Consolidate __ex_table construction 2022-12-14 08:36:11 +08:00
ftrace.c LoongArch/ftrace: Add basic support 2022-12-14 08:41:53 +08:00
ftrace_dyn.c LoongArch: modules/ftrace: Initialize PLT at load time 2022-12-14 08:41:54 +08:00
genex.S LoongArch: Add generic ex-handler unwind in prologue unwinder 2023-01-17 11:42:16 +08:00
head.S efi: Put Linux specific magic number in the DOS header 2022-12-05 09:31:46 +01:00
idle.c LoongArch: Add process management 2022-06-03 20:09:28 +08:00
image-vars.h efi: loongarch: Drop exports of unused string routines 2022-11-09 12:42:02 +01:00
inst.c LoongArch: Simplify larch_insn_gen_xxx implementation 2023-01-17 11:42:16 +08:00
io.c LoongArch: Add misc common routines 2022-06-03 20:09:28 +08:00
irq.c LoongArch: SMP: Change prefix from loongson3 to loongson 2022-11-21 19:02:57 +08:00
machine_kexec.c LoongArch: Add kdump support 2022-10-12 16:36:19 +08:00
Makefile LoongArch: Strip guess unwinder out from prologue unwinder 2023-01-17 11:42:16 +08:00
mcount.S LoongArch/ftrace: Add basic support 2022-12-14 08:41:53 +08:00
mcount_dyn.S LoongArch/ftrace: Add HAVE_DYNAMIC_FTRACE_WITH_REGS support 2022-12-14 08:41:53 +08:00
mem.c LoongArch: Add kdump support 2022-10-12 16:36:19 +08:00
module-sections.c LoongArch: modules/ftrace: Initialize PLT at load time 2022-12-14 08:41:54 +08:00
module.c LoongArch: modules/ftrace: Initialize PLT at load time 2022-12-14 08:41:54 +08:00
numa.c LoongArch changes for v6.2 2022-12-19 08:23:27 -06:00
perf_event.c LoongArch: Add perf events support 2022-10-12 16:36:14 +08:00
perf_regs.c LoongArch: Add perf events support 2022-10-12 16:36:14 +08:00
proc.c LoongArch: cpuinfo: Fix a warning for CONFIG_CPUMASK_OFFSTACK 2022-08-12 13:10:10 +08:00
process.c LoongArch: Get frame info in unwind_start() when regs is not available 2023-01-17 11:42:16 +08:00
ptrace.c LoongArch: Fix missing fcsr in ptrace's fpr_set 2022-07-29 18:22:33 +08:00
relocate_kernel.S LoongArch: Add kdump support 2022-10-12 16:36:19 +08:00
reset.c LoongArch: Add hibernation (ACPI S4) support 2022-12-14 08:41:53 +08:00
setup.c LoongArch: Add hibernation (ACPI S4) support 2022-12-14 08:41:53 +08:00
signal.c LoongArch: Adjust arch_do_signal_or_restart() to adapt generic entry 2022-09-03 18:01:27 +08:00
smp.c LoongArch: Add suspend (ACPI S3) support 2022-12-14 08:41:53 +08:00
stacktrace.c LoongArch: Add USER_STACKTRACE support 2022-08-12 13:10:11 +08:00
switch.S LoongArch: Add basic STACKPROTECTOR support 2022-12-14 08:41:53 +08:00
syscall.c LoongArch: Add system call support 2022-06-03 20:09:28 +08:00
sysrq.c LoongArch: Add SysRq-x (TLB Dump) support 2022-10-12 16:36:14 +08:00
time.c LoongArch: Only call get_timer_irq() once in constant_clockevent_init() 2023-03-22 13:37:56 +01:00
topology.c LoongArch: Do not create sysfs control file for io master CPUs 2022-10-12 16:36:08 +08:00
traps.c LoongArch: Strip guess unwinder out from prologue unwinder 2023-01-17 11:42:16 +08:00
unaligned.c LoongArch: Add unaligned access support 2022-12-14 08:36:11 +08:00
unwind.c LoongArch: Strip guess unwinder out from prologue unwinder 2023-01-17 11:42:16 +08:00
unwind_guess.c LoongArch: Strip guess unwinder out from prologue unwinder 2023-01-17 11:42:16 +08:00
unwind_prologue.c LoongArch: Add generic ex-handler unwind in prologue unwinder 2023-01-17 11:42:16 +08:00
vdso.c treewide: use get_random_u32_below() instead of deprecated function 2022-11-18 02:15:15 +01:00
vmlinux.lds.S LoongArch: Add alternative runtime patching mechanism 2022-12-14 08:36:11 +08:00