[patch] APM power-off on SMP fixed

From: Zlatko Calusic (zlatko@iskon.hr)
Date: Mon Apr 03 2000 - 07:57:31 EST


Hi!

After some unsuccessful tries to poweroff my SMP machine, I finally
digged apm.c in editor to see what's goin' on. And I found a thinko
there, which prevents APM power off to work on SMP.

Bug:
apm_init() fires up apm() kernel thread, which installs power_off
handler correctly, but then calls apm_mainloop() which on SMP returns
immediately, and after that power_off handler gets deleted.

Solution:
Exit early in apm() if we're running SMP. The patch is straightforward
and in fact code gets cleaner because we remove few checks of
smp_num_cpus. With patch applied, I can now poweroff my ABIT BP6 both
with and without REAL_MODE_POWER_OFF set. Patch is built on 2.3.99-pre3.

Index: 9903.5/arch/i386/kernel/apm.c
--- 9903.5/arch/i386/kernel/apm.c Wed, 15 Mar 2000 19:04:00 +0100 zcalusic (linux/w/32_apm.c 1.22 644)
+++ 9903.5(w)/arch/i386/kernel/apm.c Mon, 03 Apr 2000 01:53:54 +0200 zcalusic (linux/w/32_apm.c 1.22 644)
@@ -1060,9 +1060,6 @@
 {
         DECLARE_WAITQUEUE(wait, current);
 
- if (smp_num_cpus > 1)
- return;
-
         add_wait_queue(&apm_waitqueue, &wait);
         current->state = TASK_INTERRUPTIBLE;
         for (;;) {
@@ -1475,9 +1472,13 @@
 #ifdef CONFIG_MAGIC_SYSRQ
         sysrq_power_off = apm_power_off;
 #endif
+
+ /* Exit early if we're running on SMP machine -zcalusic */
+ if (smp_num_cpus > 1)
+ goto out;
+
 #if defined(CONFIG_APM_DISPLAY_BLANK) && defined(CONFIG_VT)
- if (smp_num_cpus == 1)
- console_blank_hook = apm_console_blank;
+ console_blank_hook = apm_console_blank;
 #endif
 
         pm_active = 1;
@@ -1487,15 +1488,15 @@
         pm_active = 0;
 
 #if defined(CONFIG_APM_DISPLAY_BLANK) && defined(CONFIG_VT)
- if (smp_num_cpus == 1)
- console_blank_hook = NULL;
+ console_blank_hook = NULL;
 #endif
+
 #ifdef CONFIG_MAGIC_SYSRQ
         sysrq_power_off = NULL;
 #endif
         if (power_off)
                 pm_power_off = NULL;
-
+out:
         kapmd_running = 0;
 
         return 0;

-- 
Zlatko

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Apr 07 2000 - 21:00:09 EST