LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* Re: Linux should not set the "PnP OS" boot flag
@ 2001-10-07  2:54 Thomas Hood
  2001-10-07 10:02 ` Alan Cox
  0 siblings, 1 reply; 15+ messages in thread
From: Thomas Hood @ 2001-10-07  2:54 UTC (permalink / raw)
  To: linux-kernel

ebiederman@uswest.net wrote:
> Hmm.  Linux isn't quite a "PnP OS".  I agree that in the short
> term we should not set the boot flag.  But we should also investigate
> what needs to added so that setpnp does not need to be called.

This change has to be permanent.  Linux should never automatically
set the boot flag, no matter how PnP-competent we make it.
The reason is that setting the flag affects what the BIOS will
do on the _subsequent_ boot.  But Linux can't possibly know 
which operating system will be booted _next time_.  This is
something that has to be left up to the user to control.

Assuming I've made that point, I'll go on to say that I do not
know of any reason why the PnP-OS flag should _ever_ be set.
SFAIK all that setting the flag does is stop the PnP BIOS
from configuring devices in the way that it has been told to do
(if we used "setpnp -b" to set the nonvolative configuration).
I don't see why we would ever want to do this.  If the BIOS does
configure the devices, nothing stops us from reconfiguring them
(using "setpnp") once Linux has booted.  The PnP-OS flag is called
a "quick boot" flag, but the time savings involved must be on the
order of milliseconds.  All that we seem to achieve by booting
Linux with disabled devices is to induce certain device drivers
to segfault.

Please let me know if I'm overlooking something.

If I'm right, then bootflag.c should be modified (see my patch)
to remove the bit that sets the flag.  It would be nice,
however, if the flag could be controlled via a /proc entry.

--
Thomas




^ permalink raw reply	[flat|nested] 15+ messages in thread
* Re: Linux should not set the "PnP OS" boot flag
@ 2001-10-08 12:40 Thomas Hood
  2001-10-08 13:25 ` Stelian Pop
  0 siblings, 1 reply; 15+ messages in thread
From: Thomas Hood @ 2001-10-08 12:40 UTC (permalink / raw)
  To: linux-kernel

(Sorry if this is a repeat ... a lot of my mail is getting
bounced back today for some reason.  This message hasn't 
turned up in the archives, so I'm resending.  // Thomas )

Alan Cox wrote:
> Would it not be better to tackle the job head on ? If the pnpbios scan
> as it walks the devices configured them would that do the job ?

Well, we could do the equivalent of a "setpnp xy on" on each device,
I suppose.  That just copies the "boot" config to the "current"
config.  That would suffice for me.  I don't know if it would
suffice for other people.  It wouldn't work for those Vaios and
Inspirons that have been causing problems, though.

I have a suspicion that those Phoenix BIOSes that oops when
"current" configuration is accessed are oopsing because
the BIOS hasn't initialized the "current" configuration ...
because the PnP-OS bit is set.  I've asked Stelian to test
this hypothesis; no word back yet.

In any case, though, I think the decision as to whether or not
to bypass PnP BIOS configuration _next time_ should be left up
to the user.  The user may want to boot Windows 3.1 next, or
some other non-PnP OS.  Same goes for skipping BIOS diagnostics.

As for the "Booting" flag, you're right, it should be cleared
by us.  SFAICT the current code fails to do this.  That needs
to be fixed.

So here's a new bootflag.c patch, now against 2.4.10-ac8.
(It defines some nice macros for the flags, etc.
Until CONFIG_SBF_DIAG and CONFIG_SBF_PNPOS are defined
somewhere, the default will be not to set the DIAG flag
and not to set the PnP-OS flag.  I still think a /proc
interface to these makes the most sense, but I haven't
implemented that yet.

--
Thomas

The patch:
--- linux-2.4.10-ac8/arch/i386/kernel/bootflag.c	Sun Oct  7 14:38:05 2001
+++ linux-2.4.10-ac8-fix/arch/i386/kernel/bootflag.c	Sun Oct  7 15:01:45 2001
@@ -15,6 +15,14 @@
 
 #include <linux/mc146818rtc.h>
 
+
+#define SBF_RESERVED (0x78)
+#define SBF_PNPOS    (1<<0)
+#define SBF_BOOTING  (1<<1)
+#define SBF_DIAG     (1<<2)
+#define SBF_PARITY   (1<<7)
+
+
 struct sbf_boot
 {
 	u8 sbf_signature[4];
@@ -59,7 +67,7 @@
 		return 0;
 
 	if (sb.sbf_len == 39)
-		printk (KERN_WARNING "ACPI BOOT descriptor is wrong length (%d)\n",
+		printk (KERN_WARNING "SBF: ACPI BOOT descriptor is wrong length (%d)\n",
 			sb.sbf_len);
 
 	sbf_port = sb.sbf_cmos;	/* Save CMOS port */
@@ -84,10 +92,12 @@
 	unsigned long flags;
 	if(sbf_port != -1)
 	{
-		v &= ~(1<<7);
+		v &= ~SBF_PARITY;
 		if(!parity(v))
-			v|=1<<7;
-			
+			v|=SBF_PARITY;
+
+		printk(KERN_INFO "SBF: Setting boot flags 0x%x\n",v);
+
 		spin_lock_irqsave(&rtc_lock, flags);
 		CMOS_WRITE(v, sbf_port);
 		spin_unlock_irqrestore(&rtc_lock, flags);
@@ -108,7 +118,7 @@
 
 static int __init sbf_value_valid(u8 v)
 {
-	if(v&0x78)		/* Reserved bits */
+	if(v&SBF_RESERVED)		/* Reserved bits */
 		return 0;
 	if(!parity(v))
 		return 0;
@@ -120,24 +130,22 @@
 {
 	u8 v = sbf_read();
 	if(!sbf_value_valid(v))
-		v = 0;
-#if defined(CONFIG_PNPBIOS)
-	/* Tell the BIOS to fast init as we are a PnP OS */
-	v |= (1<<0);	/* Set PNPOS flag */
-#endif
-	sbf_write(v);
-}
+		printk(KERN_WARNING "SBF: Simple boot flag value 0x%x read from CMOS RAM was invalid\n",v);
 
-#ifdef NOT_USED
-void linux_booted_ok(void)
-{
-	u8 v = sbf_read();
-	if(!sbf_value_valid(v))
-		return;
-	v &= ~(1<<1);	/* Clear BOOTING flag */
+	v &= ~SBF_RESERVED;
+	v &= ~SBF_BOOTING;
+#if defined(CONFIG_SBF_DIAG)
+	v |= SBF_DIAG;
+#else
+	v &= ~SBF_DIAG;
+#endif
+#if defined(CONFIG_SBF_PNPOS)
+	v |= SBF_PNPOS;
+#else
+	v &= ~SBF_PNPOS;
+#endif
 	sbf_write(v);
 }
-#endif /* NOT_USED */
 
 static int __init sbf_init(void)
 {
@@ -237,7 +245,7 @@
 		if(sbf_struct_valid(rp))
 		{
 			/* Found the BOOT table and processed it */
-			printk(KERN_INFO "Simple Boot Flag extension found and enabled.\n");
+			printk(KERN_INFO "SBF: Simple Boot Flag extension found and enabled.\n");
 		}
 		iounmap((void *)rp);
 	}


^ permalink raw reply	[flat|nested] 15+ messages in thread
* Linux should not set the "PnP OS" boot flag
@ 2001-10-06  3:35 Thomas Hood
  2001-10-06 19:24 ` Eric W. Biederman
  0 siblings, 1 reply; 15+ messages in thread
From: Thomas Hood @ 2001-10-06  3:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-thinkpad

My problem was: After running a recent 2.4.x kernel, on a subsequent
boot of Linux, all configurable devices (internal modem, audio chip,
parallel, serial and IR ports) were disabled.  This would causes
oopses in my sound device drivers.

My workarounds were:
(1) to reinitialize the BIOS prior to booting, or,
(2) to run "setpnp on" on all the configurable devices early in
    the boot sequence.

I just now figured out what was going on.  When the PnP BIOS is
going to boot a non-PnP OS, it configures all configurable devices
itself.  When the PnP BIOS is going to boot a PnP OS (which it
tells from a "boot flag") it leaves configurable devices, other
than those needed to boot the OS, unconfigured.  Recent Linux
kernels have set the "boot flag" indicating that the OS being booted
is a PnP OS.

Unfortunately, Linux isn't really a "PnP OS".  The kernel alone
doesn't configure the devices.  One has to use setpnp to do that.

On the ThinkPad there is an additional solution:
(3) Disable QuickBoot in EasySetup Config (the BIOS setup program)

The PnP BIOS mode in which it refrains from configuring the
configurable devices (because it thinks it's booting a PnP OS)
is called "QuickBoot" on the ThinkPad.  Recent Linux kernels switch
on QuickBoot.  However if QuickBoot is disabled in EasySetup then
the boot flag is ignored and the PnP BIOS goes ahead and configures
the devices itself.  One can still use setpnp to reconfigure the
devices, so this doesn't create a problem.

The best solution, though, is
(4) to modify Linux so that it doesn't set the QuickBoot boot flag.
The problem isn't just that Linux isn't a PnP OS.  It's that Linux
can't possibly know in a multi-boot setup WHICH OS is going to be
booted _next_.  So it just shouldn't futz with that boot flag.
Instead, control over the flag should be given to the user via
a /proc entry or something like that.  I append a short patch
to remove the bit of code that sets the boot flag.  (I see where
the function also zeroes out the sbf value if it appears not to be
a valid value.  That seems rather rash to me, but I leave it
alone because I don't understand why it's there.)

Thanks to ebiederm@xmission.com for pointing me to the bootflag
code, of whose existence I was until recently unaware.

--
Thomas Hood

The patch:
--- linux-2.4.10-ac5/arch/i386/kernel/bootflag.c	Fri Oct  5 14:57:10 2001
+++ linux-2.4.10-ac5-fix/arch/i386/kernel/bootflag.c	Fri Oct  5 23:20:43 2001
@@ -119,7 +119,7 @@
 	u8 v = sbf_read();
 	if(!sbf_value_valid(v))
 		v = 0;
-#if defined(CONFIG_PNPBIOS)
+#if 0            // WAS: #if defined(CONFIG_PNPBIOS)
 	/* Tell the BIOS to fast init as we are a PnP OS */
 	v |= (1<<0);	/* Set PNPOS flag */
 #endif



^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2001-10-08 22:11 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-07  2:54 Linux should not set the "PnP OS" boot flag Thomas Hood
2001-10-07 10:02 ` Alan Cox
2001-10-07 13:50   ` Thomas Hood
2001-10-07 14:07     ` Dave Jones
2001-10-07 14:18     ` Alan Cox
2001-10-07 17:10       ` Thomas Hood
2001-10-07 21:59         ` Alan Cox
2001-10-07 17:54       ` Thomas Hood
  -- strict thread matches above, loose matches on Subject: below --
2001-10-08 12:40 Thomas Hood
2001-10-08 13:25 ` Stelian Pop
2001-10-08 22:12   ` J.D. Hood
2001-10-06  3:35 Thomas Hood
2001-10-06 19:24 ` Eric W. Biederman
2001-10-06 21:11   ` Alan Cox
2001-10-07  1:08     ` Eric W. Biederman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).