power: skip echo mem if there is pending transition 29/288229/1
authorYoungjae Cho <y0.cho@samsung.com>
Thu, 9 Feb 2023 02:33:52 +0000 (11:33 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Tue, 14 Feb 2023 03:15:22 +0000 (12:15 +0900)
For echo mem, there could be some pending transitions when it comes to
enter suspend. This is because transition is asynchronously processed.
That is, if there were another transition request during a sleep
transition, the sleep transition should be skipped and take the next
transition immediately. Otherwise, the next transition will handled
after wakeup, which is indefinite.

Change-Id: Ia09a1d1162e21710538f6e9ce7bd1fb3e9c43d0f
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
src/power/power-suspend.c
src/power/power.c
src/power/power.h

index ff4b60655adb677bd6d4cdf7d7ba5fe123423ca8..efd6ccd85c0dec813b2c1687447864087818d6db 100644 (file)
@@ -375,6 +375,18 @@ static int load_sleep_config(struct parse_result *result, void *user_data)
 
 static void suspend_echo_mem(void)
 {
+       if (is_there_pending_transition()) {
+               /**
+                * For echo mem, there could be some pending transitions at this point because
+                * transition is aynchronous. That is, if there were another transition request
+                * during a sleep transition, the sleep transition should be skipped and take
+                * the next transition immediately. Otherwise, the next transition will handled
+                * after wakeup, which is indefinite.
+                */
+               _D("Skip echo mem, trigger next transition immediately.");
+               return;
+       }
+
        sys_set_str("/sys/power/state", "mem");
 
        // resume
index 58a1e831e98b534921f27f1fae7ce64a4c514816..1ed50fceeec4c47e290772f6b94d7cfa76064cb8 100644 (file)
@@ -362,6 +362,11 @@ static void broadcast_transition_info(void)
                        transition_context.ti.reason));
 }
 
+int is_there_pending_transition(void)
+{
+       return (g_queue_peek_tail(transition_queue) != NULL);
+}
+
 static uint64_t available_starting_state(void)
 {
        struct trans_info *ti = NULL;
index 8de8bb7da5b6a94b1d082c67abf34e730a6081af..ea5190c47db945683b4196af18b435de7283d5ba 100644 (file)
@@ -150,6 +150,7 @@ static inline void power_request_change_state(uint64_t next, int reason)
 
 uint64_t power_get_state(void);
 int add_change_state_wait(pid_t pid, guint64 state);
+int is_there_pending_transition(void);
 void remove_change_state_wait(pid_t pid, guint64 state);
 int confirm_change_state_wait(pid_t pid, guint64 transition_id);
 int cancel_change_state_wait(pid_t pid, guint64 transition_id);