Suspend: Invoke suspend notifications after console switch

In order to fix APM emulation it is necessary to enable apm-emulation
notifications for suspends triggered in various ways via the suspend
notifiers. However, this will cause the systems using APM emulation
to lock up between X being needed to switch away from the VT and X
already waiting for resume in the APM ioctl.

This patch moves the console switch (if enabled) before the suspend
notification (and after the resume notification) to avoid this issue.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Len Brown <len.brown@intel.com>

authored by Johannes Berg and committed by Len Brown af258f51 17b7a89c

+4 -4
+4 -4
kernel/power/main.c
··· 175 175 if (!suspend_ops || !suspend_ops->enter) 176 176 return -EPERM; 177 177 178 + pm_prepare_console(); 179 + 178 180 error = pm_notifier_call_chain(PM_SUSPEND_PREPARE); 179 181 if (error) 180 182 goto Finish; 181 - 182 - pm_prepare_console(); 183 183 184 184 if (suspend_freeze_processes()) { 185 185 error = -EAGAIN; ··· 200 200 201 201 Thaw: 202 202 suspend_thaw_processes(); 203 - pm_restore_console(); 204 203 Finish: 205 204 pm_notifier_call_chain(PM_POST_SUSPEND); 205 + pm_restore_console(); 206 206 return error; 207 207 } 208 208 ··· 309 309 static void suspend_finish(void) 310 310 { 311 311 suspend_thaw_processes(); 312 - pm_restore_console(); 313 312 pm_notifier_call_chain(PM_POST_SUSPEND); 313 + pm_restore_console(); 314 314 } 315 315 316 316