Skip to contentSkip to conversation

PM: sleep: Call pm_restore_gfp_mask() after dpm_resume()

PATCH In review Rafael J. Wysocki 2 participants 2 messages Jul 9, 2025

Subsystems (4)
lore
Share & tools
lore

Rafael J. Wysocki

author maintainer
#0 lore raw

PATCH 1/1 PM: sleep: Call pm_restore_gfp_mask() after dpm_resume()

From: Rafael J. Wysocki <[email protected]>

Commit 12ffc3b1513e ("PM: Restrict swap use to later in the suspend sequence") changed two pm_restore_gfp_mask() calls in enter_state() and hibernation_restore() into one pm_restore_gfp_mask() call in dpm_resume_end(), but it put that call before the dpm_resume() invocation which is too early (some swap-backing devices may not be ready at that point).

Moreover, this code ordering change was not even mentioned in the changelog of the commit mentioned above.

Address this by moving that call after the dpm_resume() one.

Fixes 12ffc3b1513e ("PM: Restrict swap use to later in the suspend sequence")
---
 drivers/base/power/main.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/power/main.c +1 -1
@@ -1254,8 +1254,8 @@
  */
 void dpm_resume_end(pm_message_t state)
 {
-	pm_restore_gfp_mask();
 	dpm_resume(state);
+	pm_restore_gfp_mask();
 	dpm_complete(state);
 }
 EXPORT_SYMBOL_GPL(dpm_resume_end);
Reviewed-by on v1 1/1
#1 lore raw
Quoted 26 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

Commit 12ffc3b1513e ("PM: Restrict swap use to later in the suspend sequence") changed two pm_restore_gfp_mask() calls in enter_state() and hibernation_restore() into one pm_restore_gfp_mask() call in dpm_resume_end(), but it put that call before the dpm_resume() invocation which is too early (some swap-backing devices may not be ready at that point).

Moreover, this code ordering change was not even mentioned in the changelog of the commit mentioned above.

Address this by moving that call after the dpm_resume() one.

Fixes 12ffc3b1513e ("PM: Restrict swap use to later in the suspend sequence")
---
  drivers/base/power/main.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

drivers/base/power/main.c line 1261

Quoted 9 lines
drivers/base/power/main.c +1 -1
@@ -1254,8 +1254,8 @@
   */
  void dpm_resume_end(pm_message_t state)
  {
-	pm_restore_gfp_mask();
  	dpm_resume(state);
+	pm_restore_gfp_mask();
  	dpm_complete(state);
  }
  EXPORT_SYMBOL_GPL(dpm_resume_end);

Thanks, I looked through the codepaths and I agree with this change. Thanks for catching it.