Skip to content

Commit 63f9ccb

Browse files
committed
Merge back earlier suspend/hibernation changes for v4.8.
2 parents 65c0554 + 307c597 commit 63f9ccb

11 files changed

Lines changed: 151 additions & 98 deletions

File tree

‎include/linux/suspend.h‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@ static inline void pm_set_vt_switch(int do_switch)
1818
#endif
1919

2020
#ifdef CONFIG_VT_CONSOLE_SLEEP
21-
extern int pm_prepare_console(void);
21+
extern void pm_prepare_console(void);
2222
extern void pm_restore_console(void);
2323
#else
24-
static inline int pm_prepare_console(void)
24+
static inline void pm_prepare_console(void)
2525
{
26-
return 0;
2726
}
2827

2928
static inline void pm_restore_console(void)

‎kernel/power/Makefile‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
ccflags-$(CONFIG_PM_DEBUG) := -DDEBUG
33

4+
KASAN_SANITIZE_snapshot.o := n
5+
46
obj-y += qos.o
57
obj-$(CONFIG_PM) += main.o
68
obj-$(CONFIG_VT_CONSOLE_SLEEP) += console.o

‎kernel/power/console.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,17 @@ static bool pm_vt_switch(void)
126126
return ret;
127127
}
128128

129-
int pm_prepare_console(void)
129+
void pm_prepare_console(void)
130130
{
131131
if (!pm_vt_switch())
132-
return 0;
132+
return;
133133

134134
orig_fgconsole = vt_move_to_console(SUSPEND_CONSOLE, 1);
135135
if (orig_fgconsole < 0)
136-
return 1;
136+
return;
137137

138138
orig_kmsg = vt_kmsg_redirect(SUSPEND_CONSOLE);
139-
return 0;
139+
return;
140140
}
141141

142142
void pm_restore_console(void)

‎kernel/power/hibernate.c‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ static void power_down(void)
647647
*/
648648
int hibernate(void)
649649
{
650-
int error;
650+
int error, nr_calls = 0;
651651

652652
if (!hibernation_available()) {
653653
pr_debug("PM: Hibernation not available.\n");
@@ -662,9 +662,11 @@ int hibernate(void)
662662
}
663663

664664
pm_prepare_console();
665-
error = pm_notifier_call_chain(PM_HIBERNATION_PREPARE);
666-
if (error)
665+
error = __pm_notifier_call_chain(PM_HIBERNATION_PREPARE, -1, &nr_calls);
666+
if (error) {
667+
nr_calls--;
667668
goto Exit;
669+
}
668670

669671
printk(KERN_INFO "PM: Syncing filesystems ... ");
670672
sys_sync();
@@ -714,7 +716,7 @@ int hibernate(void)
714716
/* Don't bother checking whether freezer_test_done is true */
715717
freezer_test_done = false;
716718
Exit:
717-
pm_notifier_call_chain(PM_POST_HIBERNATION);
719+
__pm_notifier_call_chain(PM_POST_HIBERNATION, nr_calls, NULL);
718720
pm_restore_console();
719721
atomic_inc(&snapshot_device_available);
720722
Unlock:
@@ -740,7 +742,7 @@ int hibernate(void)
740742
*/
741743
static int software_resume(void)
742744
{
743-
int error;
745+
int error, nr_calls = 0;
744746
unsigned int flags;
745747

746748
/*
@@ -827,9 +829,11 @@ static int software_resume(void)
827829
}
828830

829831
pm_prepare_console();
830-
error = pm_notifier_call_chain(PM_RESTORE_PREPARE);
831-
if (error)
832+
error = __pm_notifier_call_chain(PM_RESTORE_PREPARE, -1, &nr_calls);
833+
if (error) {
834+
nr_calls--;
832835
goto Close_Finish;
836+
}
833837

834838
pr_debug("PM: Preparing processes for restore.\n");
835839
error = freeze_processes();
@@ -855,7 +859,7 @@ static int software_resume(void)
855859
unlock_device_hotplug();
856860
thaw_processes();
857861
Finish:
858-
pm_notifier_call_chain(PM_POST_RESTORE);
862+
__pm_notifier_call_chain(PM_POST_RESTORE, nr_calls, NULL);
859863
pm_restore_console();
860864
atomic_inc(&snapshot_device_available);
861865
/* For success case, the suspend path will release the lock */

‎kernel/power/main.c‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,19 @@ int unregister_pm_notifier(struct notifier_block *nb)
3838
}
3939
EXPORT_SYMBOL_GPL(unregister_pm_notifier);
4040

41-
int pm_notifier_call_chain(unsigned long val)
41+
int __pm_notifier_call_chain(unsigned long val, int nr_to_call, int *nr_calls)
4242
{
43-
int ret = blocking_notifier_call_chain(&pm_chain_head, val, NULL);
43+
int ret;
44+
45+
ret = __blocking_notifier_call_chain(&pm_chain_head, val, NULL,
46+
nr_to_call, nr_calls);
4447

4548
return notifier_to_errno(ret);
4649
}
50+
int pm_notifier_call_chain(unsigned long val)
51+
{
52+
return __pm_notifier_call_chain(val, -1, NULL);
53+
}
4754

4855
/* If set, devices may be suspended and resumed asynchronously. */
4956
int pm_async_enabled = 1;

‎kernel/power/power.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ static inline void suspend_test_finish(const char *label) {}
200200

201201
#ifdef CONFIG_PM_SLEEP
202202
/* kernel/power/main.c */
203+
extern int __pm_notifier_call_chain(unsigned long val, int nr_to_call,
204+
int *nr_calls);
203205
extern int pm_notifier_call_chain(unsigned long val);
204206
#endif
205207

‎kernel/power/process.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ static int try_to_freeze_tasks(bool user_only)
8989
elapsed_msecs / 1000, elapsed_msecs % 1000,
9090
todo - wq_busy, wq_busy);
9191

92+
if (wq_busy)
93+
show_workqueue_state();
94+
9295
if (!wakeup) {
9396
read_lock(&tasklist_lock);
9497
for_each_process_thread(g, p) {

0 commit comments

Comments
 (0)