Question

In linux kernel, in file arch/arm/mach-exynos/cpuidle.c, there is the following code:

    local_irq_disable();

    cpu_do_idle();

    local_irq_enable();

where cpu_do_idle is

    dsb         
    wfi
    mov     pc, lr

In cpu_do_idle, it does 'wfi' command which stands for wait for interrupt. But, what I'm not understanding is that it enters cpu_do_idle after disabling irq. How does this happen?

Was it helpful?

Solution

WFI waits for the hardware interrupt, regardless the current interrupt handling state of the CPU. When CPU is woken up, it has the chance to re-enable interrupts and process any pending ones:

WFI suspends execution until one of the following events occurs:

  • an IRQ interrupt, regardless of the CPSR I-bit

  • an FIQ interrupt, regardless of the CPSR F-bit

  • an Imprecise Data abort, unless masked by the CPSR A-bit

  • a Debug Entry request, regardless of whether Debug is enabled.

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0489c/CIHEGBBF.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top