summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Feng <li1.feng@intel.com>2022-05-04 18:18:42 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-05-06 01:40:59 +0000
commit9fceb6edb9d24d38e7ec59f940b10e9a9b82e97a (patch)
tree0035f1c3a0d8a3ffabd44ad4a543c93d3f3db3eb
parentade735848a985bb90073a320938d42064e788cee (diff)
downloadchrome-ec-9fceb6edb9d24d38e7ec59f940b10e9a9b82e97a.tar.gz
zephyr: subsys/ap_pwrseq: S0ix sleep transition check
In power state S0, "ap_power_sleep_notify_transition()" is called continually. This is confusing since it should only be called when AP sleep status changes in S0ix exit. This CL adds condition check before calling it. Now the S0ix handling has flow as: 1. Receive host command about AP sleep state changes(resume, suspend); 2. Process sleep state and send sleep notify for power state transition. ap_power_chipset_handle_host_sleep_event() ap_power_sleep_set_notify() 3. Power state machine will check current sleep notify and call the transition. ap_power_sleep_get_notify() ap_power_sleep_notify_transition() BUG=none BRANCH=none TEST=Run s0ix test on Nivviks for 100 times, pass. Signed-off-by: Li Feng <li1.feng@intel.com> Change-Id: I01c184da0f1aea2e9b99fda901f3df50555e126e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3628829 Reviewed-by: Peter Marheine <pmarheine@chromium.org> Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
-rw-r--r--zephyr/shim/include/power_host_sleep.h1
-rw-r--r--zephyr/subsys/ap_pwrseq/include/ap_power_host_sleep.h7
-rw-r--r--zephyr/subsys/ap_pwrseq/power_host_sleep.c5
-rw-r--r--zephyr/subsys/ap_pwrseq/x86_non_dsx_common_pwrseq_sm_handler.c10
4 files changed, 17 insertions, 6 deletions
diff --git a/zephyr/shim/include/power_host_sleep.h b/zephyr/shim/include/power_host_sleep.h
index e4f24b7d88..cc7fe04847 100644
--- a/zephyr/shim/include/power_host_sleep.h
+++ b/zephyr/shim/include/power_host_sleep.h
@@ -62,7 +62,6 @@ struct host_sleep_event_context {
void ap_power_chipset_handle_host_sleep_event(
enum host_sleep_event state,
struct host_sleep_event_context *ctx);
-enum host_sleep_event power_get_host_sleep_state(void);
void power_set_host_sleep_state(enum host_sleep_event state);
#endif /* CONFIG_AP_PWRSEQ_HOST_SLEEP */
diff --git a/zephyr/subsys/ap_pwrseq/include/ap_power_host_sleep.h b/zephyr/subsys/ap_pwrseq/include/ap_power_host_sleep.h
index d3cbc8c15f..9bee8af826 100644
--- a/zephyr/subsys/ap_pwrseq/include/ap_power_host_sleep.h
+++ b/zephyr/subsys/ap_pwrseq/include/ap_power_host_sleep.h
@@ -39,6 +39,13 @@ enum ap_power_sleep_type {
void ap_power_reset_host_sleep_state(void);
/*
+ * Get current sleep type notified.
+ *
+ * @return enum ap_power_sleep_type
+ */
+enum ap_power_sleep_type ap_power_sleep_get_notify(void);
+
+/*
* Check if the sleep type current power transition indicates is the same
* as what is notified. If same, means host sleep event notified by AP
* through Host Command and SLP_S0 are consistent. Process
diff --git a/zephyr/subsys/ap_pwrseq/power_host_sleep.c b/zephyr/subsys/ap_pwrseq/power_host_sleep.c
index 2e7df63c51..ff512fa941 100644
--- a/zephyr/subsys/ap_pwrseq/power_host_sleep.c
+++ b/zephyr/subsys/ap_pwrseq/power_host_sleep.c
@@ -151,6 +151,11 @@ static void ap_power_sleep_set_notify(enum ap_power_sleep_type new_state)
sleep_state = new_state;
}
+enum ap_power_sleep_type ap_power_sleep_get_notify(void)
+{
+ return sleep_state;
+}
+
void ap_power_sleep_notify_transition(enum ap_power_sleep_type check_state)
{
if (sleep_state != check_state)
diff --git a/zephyr/subsys/ap_pwrseq/x86_non_dsx_common_pwrseq_sm_handler.c b/zephyr/subsys/ap_pwrseq/x86_non_dsx_common_pwrseq_sm_handler.c
index a54de0a81d..d57ea0cf20 100644
--- a/zephyr/subsys/ap_pwrseq/x86_non_dsx_common_pwrseq_sm_handler.c
+++ b/zephyr/subsys/ap_pwrseq/x86_non_dsx_common_pwrseq_sm_handler.c
@@ -328,12 +328,12 @@ static int common_pwr_sm_run(int state)
* Ignore the SLP_S0 assertions in idle scenario by checking
* the host sleep state.
*/
- } else if (power_get_host_sleep_state()
- == HOST_SLEEP_EVENT_S0IX_SUSPEND &&
- power_signals_on(IN_PCH_SLP_S0)) {
-
+ } else if (ap_power_sleep_get_notify() ==
+ AP_POWER_SLEEP_SUSPEND &&
+ power_signals_on(IN_PCH_SLP_S0)) {
return SYS_POWER_STATE_S0S0ix;
- } else {
+ } else if (ap_power_sleep_get_notify() ==
+ AP_POWER_SLEEP_RESUME) {
ap_power_sleep_notify_transition(AP_POWER_SLEEP_RESUME);
#endif /* CONFIG_AP_PWRSEQ_S0IX */
}