Skip to content

Commit

Permalink
Merge back earlier suspend/hibernation changes for v4.8.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafael J. Wysocki committed Jul 8, 2016
2 parents 65c0554 + 307c597 commit 63f9ccb
Show file tree
Hide file tree
Showing 11 changed files with 151 additions and 98 deletions.
5 changes: 2 additions & 3 deletions include/linux/suspend.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ static inline void pm_set_vt_switch(int do_switch)
#endif

#ifdef CONFIG_VT_CONSOLE_SLEEP
extern int pm_prepare_console(void);
extern void pm_prepare_console(void);
extern void pm_restore_console(void);
#else
static inline int pm_prepare_console(void)
static inline void pm_prepare_console(void)
{
return 0;
}

static inline void pm_restore_console(void)
Expand Down
2 changes: 2 additions & 0 deletions kernel/power/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

ccflags-$(CONFIG_PM_DEBUG) := -DDEBUG

KASAN_SANITIZE_snapshot.o := n

obj-y += qos.o
obj-$(CONFIG_PM) += main.o
obj-$(CONFIG_VT_CONSOLE_SLEEP) += console.o
Expand Down
8 changes: 4 additions & 4 deletions kernel/power/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,17 @@ static bool pm_vt_switch(void)
return ret;
}

int pm_prepare_console(void)
void pm_prepare_console(void)
{
if (!pm_vt_switch())
return 0;
return;

orig_fgconsole = vt_move_to_console(SUSPEND_CONSOLE, 1);
if (orig_fgconsole < 0)
return 1;
return;

orig_kmsg = vt_kmsg_redirect(SUSPEND_CONSOLE);
return 0;
return;
}

void pm_restore_console(void)
Expand Down
20 changes: 12 additions & 8 deletions kernel/power/hibernate.c
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ static void power_down(void)
*/
int hibernate(void)
{
int error;
int error, nr_calls = 0;

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

pm_prepare_console();
error = pm_notifier_call_chain(PM_HIBERNATION_PREPARE);
if (error)
error = __pm_notifier_call_chain(PM_HIBERNATION_PREPARE, -1, &nr_calls);
if (error) {
nr_calls--;
goto Exit;
}

printk(KERN_INFO "PM: Syncing filesystems ... ");
sys_sync();
Expand Down Expand Up @@ -714,7 +716,7 @@ int hibernate(void)
/* Don't bother checking whether freezer_test_done is true */
freezer_test_done = false;
Exit:
pm_notifier_call_chain(PM_POST_HIBERNATION);
__pm_notifier_call_chain(PM_POST_HIBERNATION, nr_calls, NULL);
pm_restore_console();
atomic_inc(&snapshot_device_available);
Unlock:
Expand All @@ -740,7 +742,7 @@ int hibernate(void)
*/
static int software_resume(void)
{
int error;
int error, nr_calls = 0;
unsigned int flags;

/*
Expand Down Expand Up @@ -827,9 +829,11 @@ static int software_resume(void)
}

pm_prepare_console();
error = pm_notifier_call_chain(PM_RESTORE_PREPARE);
if (error)
error = __pm_notifier_call_chain(PM_RESTORE_PREPARE, -1, &nr_calls);
if (error) {
nr_calls--;
goto Close_Finish;
}

pr_debug("PM: Preparing processes for restore.\n");
error = freeze_processes();
Expand All @@ -855,7 +859,7 @@ static int software_resume(void)
unlock_device_hotplug();
thaw_processes();
Finish:
pm_notifier_call_chain(PM_POST_RESTORE);
__pm_notifier_call_chain(PM_POST_RESTORE, nr_calls, NULL);
pm_restore_console();
atomic_inc(&snapshot_device_available);
/* For success case, the suspend path will release the lock */
Expand Down
11 changes: 9 additions & 2 deletions kernel/power/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,19 @@ int unregister_pm_notifier(struct notifier_block *nb)
}
EXPORT_SYMBOL_GPL(unregister_pm_notifier);

int pm_notifier_call_chain(unsigned long val)
int __pm_notifier_call_chain(unsigned long val, int nr_to_call, int *nr_calls)
{
int ret = blocking_notifier_call_chain(&pm_chain_head, val, NULL);
int ret;

ret = __blocking_notifier_call_chain(&pm_chain_head, val, NULL,
nr_to_call, nr_calls);

return notifier_to_errno(ret);
}
int pm_notifier_call_chain(unsigned long val)
{
return __pm_notifier_call_chain(val, -1, NULL);
}

/* If set, devices may be suspended and resumed asynchronously. */
int pm_async_enabled = 1;
Expand Down
2 changes: 2 additions & 0 deletions kernel/power/power.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ static inline void suspend_test_finish(const char *label) {}

#ifdef CONFIG_PM_SLEEP
/* kernel/power/main.c */
extern int __pm_notifier_call_chain(unsigned long val, int nr_to_call,
int *nr_calls);
extern int pm_notifier_call_chain(unsigned long val);
#endif

Expand Down
3 changes: 3 additions & 0 deletions kernel/power/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ static int try_to_freeze_tasks(bool user_only)
elapsed_msecs / 1000, elapsed_msecs % 1000,
todo - wq_busy, wq_busy);

if (wq_busy)
show_workqueue_state();

if (!wakeup) {
read_lock(&tasklist_lock);
for_each_process_thread(g, p) {
Expand Down
Loading

0 comments on commit 63f9ccb

Please sign in to comment.