Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 63f9ccb8 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki
Browse files

Merge back earlier suspend/hibernation changes for v4.8.

parents 65c0554b 307c5971
Loading
Loading
Loading
Loading
+2 −3
Original line number Original line Diff line number Diff line
@@ -18,12 +18,11 @@ static inline void pm_set_vt_switch(int do_switch)
#endif
#endif


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


static inline void pm_restore_console(void)
static inline void pm_restore_console(void)
+2 −0
Original line number Original line Diff line number Diff line


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


KASAN_SANITIZE_snapshot.o	:= n

obj-y				+= qos.o
obj-y				+= qos.o
obj-$(CONFIG_PM)		+= main.o
obj-$(CONFIG_PM)		+= main.o
obj-$(CONFIG_VT_CONSOLE_SLEEP)	+= console.o
obj-$(CONFIG_VT_CONSOLE_SLEEP)	+= console.o
+4 −4
Original line number Original line Diff line number Diff line
@@ -126,17 +126,17 @@ static bool pm_vt_switch(void)
	return ret;
	return ret;
}
}


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


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


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


void pm_restore_console(void)
void pm_restore_console(void)
+12 −8
Original line number Original line Diff line number Diff line
@@ -647,7 +647,7 @@ static void power_down(void)
 */
 */
int hibernate(void)
int hibernate(void)
{
{
	int error;
	int error, nr_calls = 0;


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


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


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


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


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


	pr_debug("PM: Preparing processes for restore.\n");
	pr_debug("PM: Preparing processes for restore.\n");
	error = freeze_processes();
	error = freeze_processes();
@@ -855,7 +859,7 @@ static int software_resume(void)
	unlock_device_hotplug();
	unlock_device_hotplug();
	thaw_processes();
	thaw_processes();
 Finish:
 Finish:
	pm_notifier_call_chain(PM_POST_RESTORE);
	__pm_notifier_call_chain(PM_POST_RESTORE, nr_calls, NULL);
	pm_restore_console();
	pm_restore_console();
	atomic_inc(&snapshot_device_available);
	atomic_inc(&snapshot_device_available);
	/* For success case, the suspend path will release the lock */
	/* For success case, the suspend path will release the lock */
+9 −2
Original line number Original line Diff line number Diff line
@@ -38,12 +38,19 @@ int unregister_pm_notifier(struct notifier_block *nb)
}
}
EXPORT_SYMBOL_GPL(unregister_pm_notifier);
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);
	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. */
/* If set, devices may be suspended and resumed asynchronously. */
int pm_async_enabled = 1;
int pm_async_enabled = 1;
Loading