kernel: power: Add PM_USERSPACE_FROZEN workqueue
Arto Merilainen [Tue, 27 Aug 2013 13:17:58 +0000 (16:17 +0300)]
Some device drivers require a callback to be called after the userspace
processes are frozen. This patch adds PM_USERSPACE_FROZEN workqueue
which is called after userspace processes are frozen but when the
kernel threads are still functioning.

Bug 1344551

Change-Id: I0e6fd7e2473db168d01c88bc0192326ceea92ebe
Signed-off-by: Arto Merilainen <amerilainen@nvidia.com>
Reviewed-on: http://git-master/r/266774
(cherry picked from commit d964493291ef87eea1a2ee47b5b66305bb18bcf3)
Reviewed-on: http://git-master/r/274939
Tested-by: Sang-Hun Lee <sanlee@nvidia.com>
Reviewed-by: Kevin Huang (Eng-SW) <kevinh@nvidia.com>
Reviewed-by: Mitch Luban <mluban@nvidia.com>

include/linux/suspend.h
kernel/power/power.h

index d4e3f16..19e07a4 100644 (file)
@@ -339,6 +339,7 @@ static inline bool system_entering_hibernation(void) { return false; }
 #define PM_POST_SUSPEND                0x0004 /* Suspend finished */
 #define PM_RESTORE_PREPARE     0x0005 /* Going to restore a saved image */
 #define PM_POST_RESTORE                0x0006 /* Restore failed */
+#define PM_USERSPACE_FROZEN    0x0007 /* Userspace frozen */
 
 extern struct mutex pm_mutex;
 
index 7d4b7ff..49deae3 100644 (file)
@@ -242,6 +242,13 @@ static inline int suspend_freeze_processes(void)
        if (error)
                return error;
 
+       error = pm_notifier_call_chain(PM_USERSPACE_FROZEN);
+       if (error) {
+               printk(KERN_INFO "Userspace frozen workqueue canceled suspend\n");
+               thaw_processes();
+               return error;
+       }
+
        error = freeze_kernel_threads();
        /*
         * freeze_kernel_threads() thaws only kernel threads upon freezing