Inside the linux kernel idle loop, for quite a few architectures (SH, ARM, X86 etc.. afaik) are the following lines:
if(cpuidle_idle_call())
pm_idle();
My doubt:
At-least for ARM, The default pm_idle function consists of WFI (Wait for interrupt) instruction but the confusing part is, interrupts are disabled then and are enabled after the WFI instruction executes, How does a CPU get back online from WFI when interrupts were disabled ?
I tried searching for my answers in various versions of linux, but the related code is unchanged since 2.6.32 (the last version i referred to) so it's more likely that I am missing something.
WFI wakes even if interrupts are disabled, but the ARM core doesn't receive the interrupts until interrupts are enabled again.