diff mbox series

0001-power-add-PM_SUSPEND_MAX-in-pm_suspend_target_state.patch

Message ID 33254b4a-eaca-293d-041d-4dff1812c281@kylinos.cn (mailing list archive)
State Superseded, archived
Headers show
Series 0001-power-add-PM_SUSPEND_MAX-in-pm_suspend_target_state.patch | expand

Commit Message

lijun Nov. 4, 2024, 2:34 a.m. UTC
From 8196688c40b7ab55418588a29258fc8fb84905a8 Mon Sep 17 00:00:00 2001
From: Li Jun <lijun01@kylinos.cn>
Date: Fri, 1 Nov 2024 16:31:33 +0800
Subject: [PATCH] power: add PM_SUSPEND_MAX in pm_suspend_target_state

The system is switching to  disk sleep, when executing
to freeze_processes(),one of processes may be get the
system state, but the correct state  must after
suspend_devices_and_enter(state) ,so push this patch.

Signed-off-by: Li Jun <lijun01@kylinos.cn>
---
  kernel/power/hibernate.c | 3 +++
  kernel/power/suspend.c   | 4 +++-
  2 files changed, 6 insertions(+), 1 deletion(-)

      if (error)
@@ -603,6 +604,7 @@ static int enter_state(suspend_state_t state)
      pm_pr_dbg("Finishing wakeup.\n");
      suspend_finish();
   Unlock:
+    pm_suspend_target_state = PM_SUSPEND_ON;
      mutex_unlock(&system_transition_mutex);
      return error;
  }
diff mbox series

Patch

diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index 1f87aa01ba44..c7c0e7c51985 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -766,6 +766,8 @@  int hibernate(void)
      }

      pr_info("hibernation entry\n");
+    pm_suspend_target_state = PM_SUSPEND_MAX;
+
      pm_prepare_console();
      error = pm_notifier_call_chain_robust(PM_HIBERNATION_PREPARE, 
PM_POST_HIBERNATION);
      if (error)
@@ -846,6 +848,7 @@  int hibernate(void)
      hibernate_release();
   Unlock:
      unlock_system_sleep(sleep_flags);
+    pm_suspend_target_state = PM_SUSPEND_ON;
      pr_info("hibernation exit\n");

      return error;
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index 09f8397bae15..e965d29800d4 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -493,7 +493,6 @@  int suspend_devices_and_enter(suspend_state_t state)
      if (!sleep_state_supported(state))
          return -ENOSYS;

-    pm_suspend_target_state = state;

      if (state == PM_SUSPEND_TO_IDLE)
          pm_set_suspend_no_platform();
@@ -584,6 +583,8 @@  static int enter_state(suspend_state_t state)
      }

      pm_pr_dbg("Preparing system for sleep (%s)\n", 
mem_sleep_labels[state]);
+    pm_suspend_target_state = state;
+
      pm_suspend_clear_flags();
      error = suspend_prepare(state);