diff options
author | Len Brown <len.brown@intel.com> | 2007-12-13 17:38:03 -0500 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2008-01-11 12:26:47 -0500 |
commit | 9f9adecd2d0e4f88fa0e8cb06c6ec207748df70a (patch) | |
tree | b3914860b74a9f6c3ae42016aa708b54040248f8 | |
parent | da8cadb31b82c9d41fc593c8deab6aa20b162d6b (diff) |
PM: ACPI and APM must not be enabled at the same time
ACPI and APM used "pm_active" to guarantee that
they would not be simultaneously active.
But pm_active was recently moved under CONFIG_PM_LEGACY,
so that without CONFIG_PM_LEGACY, pm_active became a NOP --
allowing ACPI and APM to both be simultaneously enabled.
This caused unpredictable results, including boot hangs.
Further, the code under CONFIG_PM_LEGACY is scheduled
for removal.
So replace pm_active with pm_flags.
pm_flags depends only on CONFIG_PM,
which is present for both CONFIG_APM and CONFIG_ACPI.
http://bugzilla.kernel.org/show_bug.cgi?id=9194
Signed-off-by: Len Brown <len.brown@intel.com>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
-rw-r--r-- | arch/x86/kernel/apm_32.c | 10 | ||||
-rw-r--r-- | drivers/acpi/bus.c | 7 | ||||
-rw-r--r-- | include/linux/pm.h | 9 | ||||
-rw-r--r-- | include/linux/pm_legacy.h | 6 | ||||
-rw-r--r-- | kernel/power/main.c | 3 | ||||
-rw-r--r-- | kernel/power/pm.c | 4 |
6 files changed, 17 insertions, 22 deletions
diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c index 17089a041028..af045ca0f653 100644 --- a/arch/x86/kernel/apm_32.c +++ b/arch/x86/kernel/apm_32.c | |||
@@ -2256,14 +2256,12 @@ static int __init apm_init(void) | |||
2256 | apm_info.disabled = 1; | 2256 | apm_info.disabled = 1; |
2257 | return -ENODEV; | 2257 | return -ENODEV; |
2258 | } | 2258 | } |
2259 | if (PM_IS_ACTIVE()) { | 2259 | if (pm_flags & PM_ACPI) { |
2260 | printk(KERN_NOTICE "apm: overridden by ACPI.\n"); | 2260 | printk(KERN_NOTICE "apm: overridden by ACPI.\n"); |
2261 | apm_info.disabled = 1; | 2261 | apm_info.disabled = 1; |
2262 | return -ENODEV; | 2262 | return -ENODEV; |
2263 | } | 2263 | } |
2264 | #ifdef CONFIG_PM_LEGACY | 2264 | pm_flags |= PM_APM; |
2265 | pm_active = 1; | ||
2266 | #endif | ||
2267 | 2265 | ||
2268 | /* | 2266 | /* |
2269 | * Set up a segment that references the real mode segment 0x40 | 2267 | * Set up a segment that references the real mode segment 0x40 |
@@ -2366,9 +2364,7 @@ static void __exit apm_exit(void) | |||
2366 | kthread_stop(kapmd_task); | 2364 | kthread_stop(kapmd_task); |
2367 | kapmd_task = NULL; | 2365 | kapmd_task = NULL; |
2368 | } | 2366 | } |
2369 | #ifdef CONFIG_PM_LEGACY | 2367 | pm_flags &= ~PM_APM; |
2370 | pm_active = 0; | ||
2371 | #endif | ||
2372 | } | 2368 | } |
2373 | 2369 | ||
2374 | module_init(apm_init); | 2370 | module_init(apm_init); |
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 49d432d0a12c..d7a115c362d1 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include <linux/list.h> | 29 | #include <linux/list.h> |
30 | #include <linux/sched.h> | 30 | #include <linux/sched.h> |
31 | #include <linux/pm.h> | 31 | #include <linux/pm.h> |
32 | #include <linux/pm_legacy.h> | ||
33 | #include <linux/device.h> | 32 | #include <linux/device.h> |
34 | #include <linux/proc_fs.h> | 33 | #include <linux/proc_fs.h> |
35 | #ifdef CONFIG_X86 | 34 | #ifdef CONFIG_X86 |
@@ -764,16 +763,14 @@ static int __init acpi_init(void) | |||
764 | result = acpi_bus_init(); | 763 | result = acpi_bus_init(); |
765 | 764 | ||
766 | if (!result) { | 765 | if (!result) { |
767 | #ifdef CONFIG_PM_LEGACY | 766 | if (!(pm_flags & PM_APM)) |
768 | if (!PM_IS_ACTIVE()) | 767 | pm_flags |= PM_ACPI; |
769 | pm_active = 1; | ||
770 | else { | 768 | else { |
771 | printk(KERN_INFO PREFIX | 769 | printk(KERN_INFO PREFIX |
772 | "APM is already active, exiting\n"); | 770 | "APM is already active, exiting\n"); |
773 | disable_acpi(); | 771 | disable_acpi(); |
774 | result = -ENODEV; | 772 | result = -ENODEV; |
775 | } | 773 | } |
776 | #endif | ||
777 | } else | 774 | } else |
778 | disable_acpi(); | 775 | disable_acpi(); |
779 | 776 | ||
diff --git a/include/linux/pm.h b/include/linux/pm.h index 09a309b7b5d2..b78e0295adf4 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h | |||
@@ -246,6 +246,15 @@ static inline int call_platform_enable_wakeup(struct device *dev, int is_on) | |||
246 | device_set_wakeup_enable(dev,val); \ | 246 | device_set_wakeup_enable(dev,val); \ |
247 | } while(0) | 247 | } while(0) |
248 | 248 | ||
249 | /* | ||
250 | * Global Power Management flags | ||
251 | * Used to keep APM and ACPI from both being active | ||
252 | */ | ||
253 | extern unsigned int pm_flags; | ||
254 | |||
255 | #define PM_APM 1 | ||
256 | #define PM_ACPI 2 | ||
257 | |||
249 | #endif /* __KERNEL__ */ | 258 | #endif /* __KERNEL__ */ |
250 | 259 | ||
251 | #endif /* _LINUX_PM_H */ | 260 | #endif /* _LINUX_PM_H */ |
diff --git a/include/linux/pm_legacy.h b/include/linux/pm_legacy.h index 514729a44688..446f4f42b952 100644 --- a/include/linux/pm_legacy.h +++ b/include/linux/pm_legacy.h | |||
@@ -4,10 +4,6 @@ | |||
4 | 4 | ||
5 | #ifdef CONFIG_PM_LEGACY | 5 | #ifdef CONFIG_PM_LEGACY |
6 | 6 | ||
7 | extern int pm_active; | ||
8 | |||
9 | #define PM_IS_ACTIVE() (pm_active != 0) | ||
10 | |||
11 | /* | 7 | /* |
12 | * Register a device with power management | 8 | * Register a device with power management |
13 | */ | 9 | */ |
@@ -21,8 +17,6 @@ int __deprecated pm_send_all(pm_request_t rqst, void *data); | |||
21 | 17 | ||
22 | #else /* CONFIG_PM_LEGACY */ | 18 | #else /* CONFIG_PM_LEGACY */ |
23 | 19 | ||
24 | #define PM_IS_ACTIVE() 0 | ||
25 | |||
26 | static inline struct pm_dev *pm_register(pm_dev_t type, | 20 | static inline struct pm_dev *pm_register(pm_dev_t type, |
27 | unsigned long id, | 21 | unsigned long id, |
28 | pm_callback callback) | 22 | pm_callback callback) |
diff --git a/kernel/power/main.c b/kernel/power/main.c index 3cdf95b1dc92..f71c9504a5c5 100644 --- a/kernel/power/main.c +++ b/kernel/power/main.c | |||
@@ -28,6 +28,9 @@ BLOCKING_NOTIFIER_HEAD(pm_chain_head); | |||
28 | 28 | ||
29 | DEFINE_MUTEX(pm_mutex); | 29 | DEFINE_MUTEX(pm_mutex); |
30 | 30 | ||
31 | unsigned int pm_flags; | ||
32 | EXPORT_SYMBOL(pm_flags); | ||
33 | |||
31 | #ifdef CONFIG_SUSPEND | 34 | #ifdef CONFIG_SUSPEND |
32 | 35 | ||
33 | /* This is just an arbitrary number */ | 36 | /* This is just an arbitrary number */ |
diff --git a/kernel/power/pm.c b/kernel/power/pm.c index c50d15266c10..60c73fa670d5 100644 --- a/kernel/power/pm.c +++ b/kernel/power/pm.c | |||
@@ -27,8 +27,6 @@ | |||
27 | #include <linux/interrupt.h> | 27 | #include <linux/interrupt.h> |
28 | #include <linux/mutex.h> | 28 | #include <linux/mutex.h> |
29 | 29 | ||
30 | int pm_active; | ||
31 | |||
32 | /* | 30 | /* |
33 | * Locking notes: | 31 | * Locking notes: |
34 | * pm_devs_lock can be a semaphore providing pm ops are not called | 32 | * pm_devs_lock can be a semaphore providing pm ops are not called |
@@ -204,6 +202,4 @@ int pm_send_all(pm_request_t rqst, void *data) | |||
204 | 202 | ||
205 | EXPORT_SYMBOL(pm_register); | 203 | EXPORT_SYMBOL(pm_register); |
206 | EXPORT_SYMBOL(pm_send_all); | 204 | EXPORT_SYMBOL(pm_send_all); |
207 | EXPORT_SYMBOL(pm_active); | ||
208 | |||
209 | 205 | ||