]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
MIPS: Fix idle VS timer enqueue
authorMarco Crivellari <marco.crivellari@suse.com>
Thu, 3 Apr 2025 16:11:42 +0000 (18:11 +0200)
committerThomas Bogendoerfer <tsbogend@alpha.franken.de>
Sun, 27 Apr 2025 08:12:03 +0000 (10:12 +0200)
commit56651128e2fbad80f632f388d6bf1f39c928267a
tree94d3676270eb5105b7d4f4c87f8d6b391a6b884c
parent0af2f6be1b4281385b618cb86ad946eded089ac8
MIPS: Fix idle VS timer enqueue

MIPS re-enables interrupts on its idle routine and performs
a TIF_NEED_RESCHED check afterwards before putting the CPU to sleep.

The IRQs firing between the check and the 'wait' instruction may set the
TIF_NEED_RESCHED flag. In order to deal with this possible race, IRQs
interrupting __r4k_wait() rollback their return address to the
beginning of __r4k_wait() so that TIF_NEED_RESCHED is checked
again before going back to sleep.

However idle IRQs can also queue timers that may require a tick
reprogramming through a new generic idle loop iteration but those timers
would go unnoticed here because __r4k_wait() only checks
TIF_NEED_RESCHED. It doesn't check for pending timers.

Fix this with fast-forwarding idle IRQs return address to the end of the
idle routine instead of the beginning, so that the generic idle loop
handles both TIF_NEED_RESCHED and pending timers.

CONFIG_CPU_MICROMIPS has been removed along with the nop instructions.
There, NOPs are 2 byte in size, so change the code with 3 _ssnop which are
always 4 byte and remove the ifdef. Added ehb to make sure the hazard
is always cleared.

Fixes: c65a5480ff29 ("[MIPS] Fix potential latency problem due to non-atomic cpu_wait.")
Signed-off-by: Marco Crivellari <marco.crivellari@suse.com>
Signed-off-by: Maciej W. Rozycki <macro@orcam.me.uk>
Acked-by: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
arch/mips/include/asm/idle.h
arch/mips/kernel/genex.S
arch/mips/kernel/idle.c