diff mbox series

PM: hibernate: Explicitly set PM_SUSPEND_MAX at hibernate entry

Message ID 20250501215838.2501827-1-superm1@kernel.org
State New
Headers show
Series PM: hibernate: Explicitly set PM_SUSPEND_MAX at hibernate entry | expand

Commit Message

Mario Limonciello May 1, 2025, 9:58 p.m. UTC
From: Mario Limonciello <mario.limonciello@amd.com>

This allows pm_debug_messages to work properly for hibernate.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 kernel/power/hibernate.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

kernel test robot May 7, 2025, 7:44 a.m. UTC | #1
Hi Mario,

kernel test robot noticed the following build errors:

[auto build test ERROR on amd-pstate/linux-next]
[also build test ERROR on amd-pstate/bleeding-edge linus/master v6.15-rc5 next-20250506]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Mario-Limonciello/PM-hibernate-Explicitly-set-PM_SUSPEND_MAX-at-hibernate-entry/20250502-060011
base:   https://git.kernel.org/pub/scm/linux/kernel/git/superm1/linux.git linux-next
patch link:    https://lore.kernel.org/r/20250501215838.2501827-1-superm1%40kernel.org
patch subject: [PATCH] PM: hibernate: Explicitly set PM_SUSPEND_MAX at hibernate entry
config: x86_64-randconfig-071-20250502 (https://download.01.org/0day-ci/archive/20250507/202505071516.juQNugSC-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250507/202505071516.juQNugSC-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202505071516.juQNugSC-lkp@intel.com/

All errors (new ones prefixed by >>):

>> kernel/power/hibernate.c:775:26: error: expression is not assignable
     775 |         pm_suspend_target_state = PM_SUSPEND_MAX;
         |         ~~~~~~~~~~~~~~~~~~~~~~~ ^
   kernel/power/hibernate.c:856:26: error: expression is not assignable
     856 |         pm_suspend_target_state = PM_SUSPEND_ON;
         |         ~~~~~~~~~~~~~~~~~~~~~~~ ^
   2 errors generated.


vim +775 kernel/power/hibernate.c

   741	
   742	/**
   743	 * hibernate - Carry out system hibernation, including saving the image.
   744	 */
   745	int hibernate(void)
   746	{
   747		bool snapshot_test = false;
   748		unsigned int sleep_flags;
   749		int error;
   750	
   751		if (!hibernation_available()) {
   752			pm_pr_dbg("Hibernation not available.\n");
   753			return -EPERM;
   754		}
   755	
   756		/*
   757		 * Query for the compression algorithm support if compression is enabled.
   758		 */
   759		if (!nocompress) {
   760			strscpy(hib_comp_algo, hibernate_compressor, sizeof(hib_comp_algo));
   761			if (!crypto_has_acomp(hib_comp_algo, 0, CRYPTO_ALG_ASYNC)) {
   762				pr_err("%s compression is not available\n", hib_comp_algo);
   763				return -EOPNOTSUPP;
   764			}
   765		}
   766	
   767		sleep_flags = lock_system_sleep();
   768		/* The snapshot device should not be opened while we're running */
   769		if (!hibernate_acquire()) {
   770			error = -EBUSY;
   771			goto Unlock;
   772		}
   773	
   774		pr_info("hibernation entry\n");
 > 775		pm_suspend_target_state = PM_SUSPEND_MAX;
   776		pm_prepare_console();
   777		error = pm_notifier_call_chain_robust(PM_HIBERNATION_PREPARE, PM_POST_HIBERNATION);
   778		if (error)
   779			goto Restore;
   780	
   781		ksys_sync_helper();
   782	
   783		error = freeze_processes();
   784		if (error)
   785			goto Exit;
   786	
   787		lock_device_hotplug();
   788		/* Allocate memory management structures */
   789		error = create_basic_memory_bitmaps();
   790		if (error)
   791			goto Thaw;
   792	
   793		error = hibernation_snapshot(hibernation_mode == HIBERNATION_PLATFORM);
   794		if (error || freezer_test_done)
   795			goto Free_bitmaps;
   796	
   797		if (in_suspend) {
   798			unsigned int flags = 0;
   799	
   800			if (hibernation_mode == HIBERNATION_PLATFORM)
   801				flags |= SF_PLATFORM_MODE;
   802			if (nocompress) {
   803				flags |= SF_NOCOMPRESS_MODE;
   804			} else {
   805			        flags |= SF_CRC32_MODE;
   806	
   807				/*
   808				 * By default, LZO compression is enabled. Use SF_COMPRESSION_ALG_LZ4
   809				 * to override this behaviour and use LZ4.
   810				 *
   811				 * Refer kernel/power/power.h for more details
   812				 */
   813	
   814				if (!strcmp(hib_comp_algo, COMPRESSION_ALGO_LZ4))
   815					flags |= SF_COMPRESSION_ALG_LZ4;
   816				else
   817					flags |= SF_COMPRESSION_ALG_LZO;
   818			}
   819	
   820			pm_pr_dbg("Writing hibernation image.\n");
   821			error = swsusp_write(flags);
   822			swsusp_free();
   823			if (!error) {
   824				if (hibernation_mode == HIBERNATION_TEST_RESUME)
   825					snapshot_test = true;
   826				else
   827					power_down();
   828			}
   829			in_suspend = 0;
   830			pm_restore_gfp_mask();
   831		} else {
   832			pm_pr_dbg("Hibernation image restored successfully.\n");
   833		}
   834	
   835	 Free_bitmaps:
   836		free_basic_memory_bitmaps();
   837	 Thaw:
   838		unlock_device_hotplug();
   839		if (snapshot_test) {
   840			pm_pr_dbg("Checking hibernation image\n");
   841			error = swsusp_check(false);
   842			if (!error)
   843				error = load_image_and_restore();
   844		}
   845		thaw_processes();
   846	
   847		/* Don't bother checking whether freezer_test_done is true */
   848		freezer_test_done = false;
   849	 Exit:
   850		pm_notifier_call_chain(PM_POST_HIBERNATION);
   851	 Restore:
   852		pm_restore_console();
   853		hibernate_release();
   854	 Unlock:
   855		unlock_system_sleep(sleep_flags);
   856		pm_suspend_target_state = PM_SUSPEND_ON;
   857		pr_info("hibernation exit\n");
   858	
   859		return error;
   860	}
   861
diff mbox series

Patch

diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index 23c0f4e6cb2ff..443002fd680de 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -772,6 +772,7 @@  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)
@@ -852,6 +853,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;