]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - kernel/power/hibernate.c
PM: Make it possible to avoid races between wakeup and system sleep
[mv-sheeva.git] / kernel / power / hibernate.c
index aa9e916da4d53051eed6e7d12e9ddd37baaab3cd..f61202916631db8cf972c4c68d2f9ec7934dc45e 100644 (file)
@@ -277,7 +277,7 @@ static int create_image(int platform_mode)
                goto Enable_irqs;
        }
 
-       if (hibernation_test(TEST_CORE))
+       if (hibernation_test(TEST_CORE) || !pm_check_wakeup_events())
                goto Power_up;
 
        in_suspend = 1;
@@ -288,8 +288,10 @@ static int create_image(int platform_mode)
                        error);
        /* Restore control flow magically appears here */
        restore_processor_state();
-       if (!in_suspend)
+       if (!in_suspend) {
+               events_check_enabled = false;
                platform_leave(platform_mode);
+       }
 
  Power_up:
        sysdev_resume();
@@ -511,14 +513,20 @@ int hibernation_platform_enter(void)
 
        local_irq_disable();
        sysdev_suspend(PMSG_HIBERNATE);
+       if (!pm_check_wakeup_events()) {
+               error = -EAGAIN;
+               goto Power_up;
+       }
+
        hibernation_ops->enter();
        /* We should never get here */
        while (1);
 
-       /*
-        * We don't need to reenable the nonboot CPUs or resume consoles, since
-        * the system is going to be halted anyway.
-        */
+ Power_up:
+       sysdev_resume();
+       local_irq_enable();
+       enable_nonboot_cpus();
+
  Platform_finish:
        hibernation_ops->finish();