APM Power off w/ SMP (was: New APM BIOS patch)

Kurt Garloff (garloff@kg1.ping.de)
Wed, 11 Nov 1998 22:19:42 +0100


--cWoXeonUoKmBZSoM
Content-Type: text/plain; charset=us-ascii

On Mon, Nov 02, 1998 at 07:25:14PM +0200, Jukka Tainio wrote:
> On Tue, 3 Nov 1998 Stephen.Rothwell@canb.auug.org.au wrote:
> > I am considering some (bad) hacks that will be able to be enabled
> > in the source. The APM BIOS's don't support SMP, but some people
> > have seen them work OK for stuff like power dwon on halt.
>
> I volunteer to try them out ;)

Here's the patch I created and which works here.
My box will hang if I fully enable APM on my SMP (Dual PII) box, but the
appended patch works very well: It just enables soft power_off.
Patch is against 2.1.125 (no changes have been made since, so it should
apply cleanly against 2.1.127).

Have fun!

-- 
Kurt Garloff <K.Garloff@ping.de>  (Dortmund, FRG)
PGP key on http://student.physik.uni-dortmund.de/homepages/garloff
Unix IS user friendly - it's just selective about who its friends are!

--cWoXeonUoKmBZSoM Content-Type: text/plain; charset=us-ascii Content-Description: 21125-apm-smp-pwoff.patch Content-Disposition: attachment; filename="21125-apm-smp-pwoff.patch"

--- linux/arch/i386/kernel/apm.c.orig Wed Oct 7 18:52:05 1998 +++ linux/arch/i386/kernel/apm.c Wed Nov 11 22:16:04 1998 @@ -60,6 +60,7 @@ * Fix OOPS at power off with no APM BIOS by Jan Echternach * <echter@informatik.uni-rostock.de> * Stephen Rothwell + * 1.61:On SMP, still allow power_off() to work. <K.Garloff@ping.de> * * APM 1.1 Reference: * @@ -256,6 +257,7 @@ unsigned short segment; } apm_bios_entry; static int apm_enabled = 0; +static int apm_detected = 0; #ifdef CONFIG_APM_CPU_IDLE static int clock_slowed = 0; #endif @@ -273,7 +275,7 @@ static struct timer_list apm_timer; -static char driver_version[] = "1.6"; /* no spaces */ +static char driver_version[] = "1.61"; /* no spaces */ #ifdef APM_DEBUG static char * apm_event_name[] = { @@ -486,7 +488,7 @@ void apm_power_off(void) { - if (apm_enabled) + if (apm_detected) (void) apm_set_power_state(APM_STATE_OFF); } @@ -1178,12 +1180,6 @@ char * bat_stat; static struct proc_dir_entry *ent; -#ifdef __SMP__ - if (smp_num_cpus > 1) { - printk(KERN_NOTICE "APM disabled: APM is not SMP safe.\n"); - return; - } -#endif if (apm_bios_info.version == 0) { printk(KERN_INFO "APM BIOS not found.\n"); return; @@ -1265,12 +1261,25 @@ if (error != APM_SUCCESS) /* Fall back to an APM 1.0 connection. */ apm_bios_info.version = 0x100; else { +#ifdef __SMP__ + if (smp_num_cpus <= 1) +#endif apm_engage_power_management(0x0001); printk( " Connection version %d.%d\n", (apm_bios_info.version >> 8) & 0xff, apm_bios_info.version & 0xff ); } } + + apm_detected = 1; + +#ifdef __SMP__ + if (smp_num_cpus > 1) { + printk(KERN_NOTICE "APM disabled: APM is not SMP safe.\n"); + return; + } +#endif + error = apm_get_power_status(&bx, &cx, &dx); if (error)

--cWoXeonUoKmBZSoM--

- 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/