Skip to content

Commit e6e82e5

Browse files
committed
Merge tag 'pm-6.16-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull power management fixes from Rafael Wysocki: "These address three issues introduced during the current development cycle and related to system suspend and hibernation, one triggering when asynchronous suspend of devices fails, one possibly affecting memory management in the core suspend code error path, and one due to duplicate filesystems freezing during system suspend: - Fix a deadlock that may occur on asynchronous device suspend failures due to missing completion updates in error paths (Rafael Wysocki) - Drop a misplaced pm_restore_gfp_mask() call, which may cause swap to be accessed too early if system suspend fails, from suspend_devices_and_enter() (Rafael Wysocki) - Remove duplicate filesystems_freeze/thaw() calls, which sometimes cause systems to be unable to resume, from enter_state() (Zihuan Zhang)" * tag 'pm-6.16-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: PM: sleep: Update power.completion for all devices on errors PM: suspend: clean up redundant filesystems_freeze/thaw() handling PM: suspend: Drop a misplaced pm_restore_gfp_mask() call
2 parents e229155 + ebd6884 commit e6e82e5

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

drivers/base/power/main.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,6 +1280,22 @@ static void dpm_async_suspend_parent(struct device *dev, async_func_t func)
12801280
dpm_async_with_cleanup(dev->parent, func);
12811281
}
12821282

1283+
static void dpm_async_suspend_complete_all(struct list_head *device_list)
1284+
{
1285+
struct device *dev;
1286+
1287+
guard(mutex)(&async_wip_mtx);
1288+
1289+
list_for_each_entry_reverse(dev, device_list, power.entry) {
1290+
/*
1291+
* In case the device is being waited for and async processing
1292+
* has not started for it yet, let the waiters make progress.
1293+
*/
1294+
if (!dev->power.work_in_progress)
1295+
complete_all(&dev->power.completion);
1296+
}
1297+
}
1298+
12831299
/**
12841300
* resume_event - Return a "resume" message for given "suspend" sleep state.
12851301
* @sleep_state: PM message representing a sleep state.
@@ -1456,6 +1472,7 @@ static int dpm_noirq_suspend_devices(pm_message_t state)
14561472
mutex_lock(&dpm_list_mtx);
14571473

14581474
if (error || async_error) {
1475+
dpm_async_suspend_complete_all(&dpm_late_early_list);
14591476
/*
14601477
* Move all devices to the target list to resume them
14611478
* properly.
@@ -1658,6 +1675,7 @@ int dpm_suspend_late(pm_message_t state)
16581675
mutex_lock(&dpm_list_mtx);
16591676

16601677
if (error || async_error) {
1678+
dpm_async_suspend_complete_all(&dpm_suspended_list);
16611679
/*
16621680
* Move all devices to the target list to resume them
16631681
* properly.
@@ -1951,6 +1969,7 @@ int dpm_suspend(pm_message_t state)
19511969
mutex_lock(&dpm_list_mtx);
19521970

19531971
if (error || async_error) {
1972+
dpm_async_suspend_complete_all(&dpm_prepared_list);
19541973
/*
19551974
* Move all devices to the target list to resume them
19561975
* properly.

kernel/power/suspend.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ static int suspend_prepare(suspend_state_t state)
384384
return 0;
385385

386386
dpm_save_failed_step(SUSPEND_FREEZE);
387+
filesystems_thaw();
387388
pm_notifier_call_chain(PM_POST_SUSPEND);
388389
Restore:
389390
pm_restore_console();
@@ -540,7 +541,6 @@ int suspend_devices_and_enter(suspend_state_t state)
540541
return error;
541542

542543
Recover_platform:
543-
pm_restore_gfp_mask();
544544
platform_recover(state);
545545
goto Resume_devices;
546546
}
@@ -593,8 +593,6 @@ static int enter_state(suspend_state_t state)
593593
ksys_sync_helper();
594594
trace_suspend_resume(TPS("sync_filesystems"), 0, false);
595595
}
596-
if (filesystem_freeze_enabled)
597-
filesystems_freeze();
598596

599597
pm_pr_dbg("Preparing system for sleep (%s)\n", mem_sleep_labels[state]);
600598
pm_suspend_clear_flags();
@@ -614,7 +612,6 @@ static int enter_state(suspend_state_t state)
614612
pm_pr_dbg("Finishing wakeup.\n");
615613
suspend_finish();
616614
Unlock:
617-
filesystems_thaw();
618615
mutex_unlock(&system_transition_mutex);
619616
return error;
620617
}

0 commit comments

Comments
 (0)