Commit 89b30987 authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar
Browse files

arch/idle: Change arch_cpu_idle() behavior: always exit with IRQs disabled



Current arch_cpu_idle() is called with IRQs disabled, but will return
with IRQs enabled.

However, the very first thing the generic code does after calling
arch_cpu_idle() is raw_local_irq_disable(). This means that
architectures that can idle with IRQs disabled end up doing a
pointless 'enable-disable' dance.

Therefore, push this IRQ disabling into the idle function, meaning
that those architectures can avoid the pointless IRQ state flipping.

Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
Tested-by: default avatarTony Lindgren <tony@atomide.com>
Tested-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
Reviewed-by: default avatarGautham R. Shenoy <gautham.shenoy@amd.com>
Acked-by: Mark Rutland <mark.rutland@arm.com> [arm64]
Acked-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: default avatarGuo Ren <guoren@kernel.org>
Acked-by: default avatarFrederic Weisbecker <frederic@kernel.org>
Link: https://lore.kernel.org/r/20230112195540.618076436@infradead.org
parent 9b461a6f
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -57,7 +57,6 @@ EXPORT_SYMBOL(pm_power_off);
void arch_cpu_idle(void)
{
	wtint(0);
	raw_local_irq_enable();
}

void arch_cpu_idle_dead(void)
+3 −0
Original line number Diff line number Diff line
@@ -114,6 +114,8 @@ void arch_cpu_idle(void)
		"sleep %0	\n"
		:
		:"I"(arg)); /* can't be "r" has to be embedded const */

	raw_local_irq_disable();
}

#else	/* ARC700 */
@@ -122,6 +124,7 @@ void arch_cpu_idle(void)
{
	/* sleep, but enable both set E1/E2 (levels of interrupts) before committing */
	__asm__ __volatile__("sleep 0x3	\n");
	raw_local_irq_disable();
}

#endif
+0 −1
Original line number Diff line number Diff line
@@ -78,7 +78,6 @@ void arch_cpu_idle(void)
		arm_pm_idle();
	else
		cpu_do_idle();
	raw_local_irq_enable();
}

void arch_cpu_idle_prepare(void)
+2 −1
Original line number Diff line number Diff line
@@ -42,8 +42,9 @@ static void gemini_idle(void)
	 */

	/* FIXME: Enabling interrupts here is racy! */
	local_irq_enable();
	raw_local_irq_enable();
	cpu_do_idle();
	raw_local_irq_disable();
}

static void __init gemini_init_machine(void)
+0 −1
Original line number Diff line number Diff line
@@ -42,5 +42,4 @@ void noinstr arch_cpu_idle(void)
	 * tricks
	 */
	cpu_do_idle();
	raw_local_irq_enable();
}
Loading