Commit a94e502c22b61072f808f53392a8433bc948b03d

Authored by Sudeep Holla
Committed by Rafael J. Wysocki
1 parent e5f1b24587

cpuidle: dt: assign ->enter_freeze to same as ->enter callback function

enter_freeze() callback is expected atleast to do the same as enter()
but it has to guarantee that interrupts aren't enabled at any point
in its execution, as the tick is frozen.

CPUs execute ->enter_freeze with the local tick or entire timekeeping
suspended, so it must not re-enable interrupts at any point (even
temporarily) or attempt to change states of clock event devices.

It will be called when the system goes to suspend-to-idle and will
reduce power usage because CPUs won't be awaken for unnecessary IRQs
(i.e. woken up only on IRQs from "wakeup sources")

We can reuse the same code for both the enter() and enter_freeze()
callbacks as along as they don't re-enable interrupts. Only "coupled"
cpuidle mechanism enables interrupts and doing that with timekeeping
suspended is generally not safe.

Since this generic DT based idle driver doesn't support "coupled"
states, it is safe to assume that the interrupts are not re-enabled.

This patch assign enter_freeze to same as enter callback function which
helps to save power without any intermittent spurious wakeups from
suspend-to-idle.

Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Tested-by: Andy Gross <andy.gross@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Showing 1 changed file with 6 additions and 0 deletions Side-by-side Diff

drivers/cpuidle/dt_idle_states.c
... ... @@ -38,6 +38,12 @@
38 38 * state enter function.
39 39 */
40 40 idle_state->enter = match_id->data;
  41 + /*
  42 + * Since this is not a "coupled" state, it's safe to assume interrupts
  43 + * won't be enabled when it exits allowing the tick to be frozen
  44 + * safely. So enter() can be also enter_freeze() callback.
  45 + */
  46 + idle_state->enter_freeze = match_id->data;
41 47  
42 48 err = of_property_read_u32(state_node, "wakeup-latency-us",
43 49 &idle_state->exit_latency);