Fix use of stale power states in PSCI standby finisher
authorAchin Gupta <achin.gupta@arm.com>
Tue, 28 Jun 2016 15:46:15 +0000 (16:46 +0100)
committerAchin Gupta <achin.gupta@arm.com>
Mon, 25 Jul 2016 14:53:00 +0000 (15:53 +0100)
A PSCI CPU_SUSPEND request to place a CPU in retention states at power levels
higher than the CPU power level is subject to the same state coordination as a
power down state. A CPU could implement multiple retention states at a
particular power level. When exiting WFI, the non-CPU power levels may be in a
different retention state to what was initially requested, therefore each CPU
should refresh its view of the states of all power levels.

Previously, a CPU re-used the state of the power levels when it entered the
retention state. This patch fixes this issue by ensuring that a CPU upon exit
from retention reads the state of each power level afresh.

Change-Id: I93b5f5065c63400c6fd2598dbaafac385748f989

lib/psci/psci_common.c
lib/psci/psci_private.h
lib/psci/psci_suspend.c

index c6fea5b0469d10cdc46945c06bfa1b561764a9d2..e87e8c054d387b826e7ebf86a96a0210b315c4f3 100644 (file)
@@ -252,8 +252,8 @@ static plat_local_state_t *psci_get_req_local_pwr_states(unsigned int pwrlvl,
  * function will be called after a cpu is powered on to find the local state
  * each power domain has emerged from.
  *****************************************************************************/
-static void psci_get_target_local_pwr_states(unsigned int end_pwrlvl,
-                                            psci_power_state_t *target_state)
+void psci_get_target_local_pwr_states(unsigned int end_pwrlvl,
+                                     psci_power_state_t *target_state)
 {
        unsigned int parent_idx, lvl;
        plat_local_state_t *pd_state = target_state->pwr_domain_state;
index 49352144341fcbda131a447f0812fa16b6876620..b795c8e037ef6ede91a3c8d51c0dab407429cf83 100644 (file)
@@ -192,6 +192,8 @@ int psci_validate_power_state(unsigned int power_state,
 void psci_query_sys_suspend_pwrstate(psci_power_state_t *state_info);
 int psci_validate_mpidr(u_register_t mpidr);
 void psci_init_req_local_pwr_states(void);
+void psci_get_target_local_pwr_states(unsigned int end_pwrlvl,
+                                     psci_power_state_t *target_state);
 int psci_validate_entry_point(entry_point_info_t *ep,
                        uintptr_t entrypoint, u_register_t context_id);
 void psci_get_parent_pwr_domain_nodes(unsigned int cpu_idx,
index 904a4e75801c417c84775f438d5418ccf4e1f2f6..0887e3b2d5558b65d53dbefdb5c6709b3260a2e5 100644 (file)
  * from standby/retention states at multiple power levels.
  ******************************************************************************/
 static void psci_suspend_to_standby_finisher(unsigned int cpu_idx,
-                                            psci_power_state_t *state_info,
                                             unsigned int end_pwrlvl)
 {
+       psci_power_state_t state_info;
+
        psci_acquire_pwr_domain_locks(end_pwrlvl,
                                cpu_idx);
 
+       /*
+        * Find out which retention states this CPU has exited from until the
+        * 'end_pwrlvl'. The exit retention state could be deeper than the entry
+        * state as a result of state coordination amongst other CPUs post wfi.
+        */
+       psci_get_target_local_pwr_states(end_pwrlvl, &state_info);
+
        /*
         * Plat. management: Allow the platform to do operations
         * on waking up from retention.
         */
-       psci_plat_pm_ops->pwr_domain_suspend_finish(state_info);
+       psci_plat_pm_ops->pwr_domain_suspend_finish(&state_info);
 
        /*
         * Set the requested and target state of this CPU and all the higher
@@ -222,7 +230,7 @@ exit:
         * After we wake up from context retaining suspend, call the
         * context retaining suspend finisher.
         */
-       psci_suspend_to_standby_finisher(idx, state_info, end_pwrlvl);
+       psci_suspend_to_standby_finisher(idx, end_pwrlvl);
 }
 
 /*******************************************************************************