]> www.infradead.org Git - users/willy/pagecache.git/commit
LoongArch: Fix idle VS timer enqueue
authorMarco Crivellari <marco.crivellari@suse.com>
Thu, 13 Feb 2025 04:02:35 +0000 (12:02 +0800)
committerHuacai Chen <chenhuacai@loongson.cn>
Thu, 13 Feb 2025 04:02:35 +0000 (12:02 +0800)
commitedb1942542bc538707cea221e9c7923a6270465f
treed46d29299dd3c23d38e5278aec19cb481e45c164
parenta64dcfb451e254085a7daee5fe51bf22959d52d3
LoongArch: Fix idle VS timer enqueue

LoongArch 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 idle instruction may set the
TIF_NEED_RESCHED flag. In order to deal with such a race, IRQs
interrupting __arch_cpu_idle() rollback their return address to the
beginning of __arch_cpu_idle() 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 __arch_cpu_idle() 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 can
handle both TIF_NEED_RESCHED and pending timers.

Fixes: 0603839b18f4 ("LoongArch: Add exception/interrupt handling")
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Marco Crivellari <marco.crivellari@suse.com>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
arch/loongarch/kernel/genex.S
arch/loongarch/kernel/idle.c
arch/loongarch/kernel/reset.c