2003-11-16 05:30:27

by Adam Belay

[permalink] [raw]
Subject: [PATCH] PnP Fixes for 2.6.0-test9

# --------------------------------------------
# 03/11/15 [email protected] 1.1447
# [PnP] reserve resources specified by the PnPBIOS properly
#
# A bug prevents the PnP layer from reserving some of the resources
# specified by the PnPBIOS. As a result some systems will have
# unpredicable (random crashes etc.) problems because of resource
# conflicts, especially when PCMCIA support is enabled. This patch
# fixes the problem by ensuring that the proper resource data is
# reserved.
# --------------------------------------------
#
diff -Nru a/drivers/pnp/system.c b/drivers/pnp/system.c
--- a/drivers/pnp/system.c Sun Nov 16 00:25:14 2003
+++ b/drivers/pnp/system.c Sun Nov 16 00:25:14 2003
@@ -54,7 +54,7 @@
int i;

for (i=0;i<PNP_MAX_PORT;i++) {
- if (pnp_port_valid(dev, i))
+ if (!pnp_port_valid(dev, i))
/* end of resources */
continue;
if (pnp_port_start(dev, i) == 0)


2003-11-16 05:31:05

by Adam Belay

[permalink] [raw]
Subject: Re: [PATCH] PnP Fixes for 2.6.0-test9

# --------------------------------------------
# 03/11/15 [email protected] 1.1448
# [PnPBIOS] read static resources on PnPBIOS init
#
# The PnPBIOS specifications recommend that we read static (boot time)
# resources when the PnPBIOS driver is first initialized. Because the
# PnPBIOS driver is not modular and can not be ran more than once per
# boot, it's safe to access the static resource data. Many buggy
# BIOSes actually expect us to read from it first. With this patch,
# the PnPBIOS driver will read static resources initially and then
# switch to dynamic mode when allocating resources for specific nodes.
# --------------------------------------------
#
diff -Nru a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c
--- a/drivers/pnp/pnpbios/core.c Sun Nov 16 00:25:08 2003
+++ b/drivers/pnp/pnpbios/core.c Sun Nov 16 00:25:08 2003
@@ -353,16 +353,8 @@

for(nodenum=0; nodenum<0xff; ) {
u8 thisnodenum = nodenum;
- /* eventually we will want to use PNPMODE_STATIC here but for now
- * dynamic will help us catch buggy bioses to add to the blacklist.
- */
- if (!pnpbios_dont_use_current_config) {
- if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node))
- break;
- } else {
- if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_STATIC, node))
- break;
- }
+ if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_STATIC, node))
+ break;
nodes_got++;
dev = pnpbios_kmalloc(sizeof (struct pnp_dev), GFP_KERNEL);
if (!dev)

2003-11-16 05:33:33

by Adam Belay

[permalink] [raw]
Subject: Re: [PATCH] PnP Fixes for 2.6.0-test9

# --------------------------------------------
# 03/11/15 [email protected] 1.1450
# [BUG][PATCH] isapnp does not detect some cards
#
# From: Paul L. Rogers <[email protected]>
#
# Plug and Play Cards (Tested only one at a time. One ISA slot):
# NCI1000 NewCom 33.6KifxC ISA PnP Data/Fax Modem
# ADP1542 Adaptec AHA-1542CP ISA PnP SCSI Host Adapter
#
# Problem Description:
# The Linux ISA PnP subsystem assumes that the checksum of the
# Vendor ID and the Serial Number returned by a PnP card in
# the Config state is valid. However, the Plug and Play ISA
# Specification (Version 1.0a) found at
# http://www.nondot.org/sabre/os/files/PlugNPlay/PNP-ISA-v1.0a.pdf,
# states in Section 4.5 that when a card enters the Config state
# directly from the Sleep state and the 9-byte serial identifier
# is read, the checksum byte is not valid.
#
# While some cards do return a valid checksum in this case
# (ADP1542), others do not (NCI1000) and thus are not detected
# since isapnp_build_device_list requires that the computed
# checksum match the checksum returned by the card.
#
# Workaround:
# Continue using the isapnp utility instead of the kernel PnP support.
#
# Proposed solution:
# The attached patch removes checksum related tests from
# isapnp_build_device_list and instead relies on the behavior
# documented in Section 6.1 of the PnP ISA Specification that
# specifies that Bit[7] of Vendor ID Byte 0 must be 0 to
# determine if the selected CSN is returning valid data.
#
# A longer term solution would be for isapnp_build_device_list to
# only access CSNs that were assigned during the Isolation process.
# --------------------------------------------
#
diff -Nru a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c
--- a/drivers/pnp/isapnp/core.c Sun Nov 16 00:24:55 2003
+++ b/drivers/pnp/isapnp/core.c Sun Nov 16 00:24:55 2003
@@ -890,11 +890,9 @@
header[4], header[5], header[6], header[7], header[8]);
printk(KERN_DEBUG "checksum = 0x%x\n", checksum);
#endif
- /* Don't be strict on the checksum, here !
- e.g. 'SCM SwapBox Plug and Play' has header[8]==0 (should be: b7)*/
- if (header[8] == 0)
- ;
- else if (checksum == 0x00 || checksum != header[8]) /* not valid CSN */
+ /* Per Section 6.1 of the Plug and Play ISA Specification (Version 1.0a), */
+ /* Bit[7] of Vendor ID Byte 0 must be 0 */
+ if (header[0] & 0x80) /* not valid CSN */
continue;
if ((card = isapnp_alloc(sizeof(struct pnp_card))) == NULL)
continue;

2003-11-16 05:31:48

by Adam Belay

[permalink] [raw]
Subject: Re: [PATCH] PnP Fixes for 2.6.0-test9

# --------------------------------------------
# 03/11/15 [email protected] 1.1449
# [PnPBIOS] make /proc interface an optional feature
#
# The PnPBIOS /proc interface provides direct access to PnPBIOS calls.
# These calls can be potentially dangerous, especially on buggy systems.
# Therefore, this patch provides an option for PnPBIOS calls to be
# managed by the PnPBIOS driver exclusively. This patch also updates
# the KConfig documentation accordingly.
# --------------------------------------------
#
diff -Nru a/drivers/pnp/Kconfig b/drivers/pnp/Kconfig
--- a/drivers/pnp/Kconfig Sun Nov 16 00:25:01 2003
+++ b/drivers/pnp/Kconfig Sun Nov 16 00:25:01 2003
@@ -30,33 +30,9 @@
comment "Protocols"
depends on PNP

-config ISAPNP
- bool "ISA Plug and Play support (EXPERIMENTAL)"
- depends on PNP && EXPERIMENTAL
- help
- Say Y here if you would like support for ISA Plug and Play devices.
- Some information is in <file:Documentation/isapnp.txt>.
+source "drivers/pnp/isapnp/Kconfig"

- If unsure, say Y.
-
-config PNPBIOS
- bool "Plug and Play BIOS support (EXPERIMENTAL)"
- depends on PNP && EXPERIMENTAL
- ---help---
- Linux uses the PNPBIOS as defined in "Plug and Play BIOS
- Specification Version 1.0A May 5, 1994" to autodetect built-in
- mainboard resources (e.g. parallel port resources).
-
- Some features (e.g. event notification, docking station information,
- ISAPNP services) are not used.
-
- Note: ACPI is expected to supersede PNPBIOS some day, currently it
- co-exists nicely.
-
- See latest pcmcia-cs (stand-alone package) for a nice "lspnp" tools,
- or have a look at /proc/bus/pnp.
-
- If unsure, say Y.
+source "drivers/pnp/pnpbios/Kconfig"

endmenu

diff -Nru a/drivers/pnp/isapnp/Kconfig b/drivers/pnp/isapnp/Kconfig
--- /dev/null Wed Dec 31 16:00:00 1969
+++ b/drivers/pnp/isapnp/Kconfig Sun Nov 16 00:25:01 2003
@@ -0,0 +1,11 @@
+#
+# ISA Plug and Play configuration
+#
+config ISAPNP
+ bool "ISA Plug and Play support (EXPERIMENTAL)"
+ depends on PNP && EXPERIMENTAL
+ help
+ Say Y here if you would like support for ISA Plug and Play devices.
+ Some information is in <file:Documentation/isapnp.txt>.
+
+ If unsure, say Y.
diff -Nru a/drivers/pnp/pnpbios/Kconfig b/drivers/pnp/pnpbios/Kconfig
--- /dev/null Wed Dec 31 16:00:00 1969
+++ b/drivers/pnp/pnpbios/Kconfig Sun Nov 16 00:25:01 2003
@@ -0,0 +1,41 @@
+#
+# Plug and Play BIOS configuration
+#
+config PNPBIOS
+ bool "Plug and Play BIOS support (EXPERIMENTAL)"
+ depends on PNP && EXPERIMENTAL
+ ---help---
+ Linux uses the PNPBIOS as defined in "Plug and Play BIOS
+ Specification Version 1.0A May 5, 1994" to autodetect built-in
+ mainboard resources (e.g. parallel port resources).
+
+ Some features (e.g. event notification, docking station information,
+ ISAPNP services) are not currently implemented.
+
+ If you would like the kernel to detect and allocate resources to
+ your mainboard devices (on some systems they are disabled by the
+ BIOS) say Y here. Also the PNPBIOS can help prevent resource
+ conflicts between mainboard devices and other bus devices.
+
+ Note: ACPI is expected to supersede PNPBIOS some day, currently it
+ co-exists nicely. If you have a non-ISA system that supports ACPI,
+ you probably don't need PNPBIOS support.
+
+config PNPBIOS_PROC_FS
+ bool "Plug and Play BIOS /proc interface"
+ depends on PNPBIOS && PROC_FS
+ ---help---
+ If you say Y here and to "/proc file system support", you will be
+ able to directly access the PNPBIOS. This includes resource
+ allocation, ESCD, and other PNPBIOS services. Using this
+ interface is potentially dangerous because the PNPBIOS driver will
+ not be notified of any resource changes made by writting directly.
+ Also some buggy systems will fault when accessing certain features
+ in the PNPBIOS /proc interface (e.g. ESCD).
+
+ See the latest pcmcia-cs (stand-alone package) for a nice set of
+ PNPBIOS /proc interface tools (lspnp and setpnp).
+
+ Unless you are debugging or have other specific reasons, it is
+ recommended that you say N here.
+
diff -Nru a/drivers/pnp/pnpbios/Makefile b/drivers/pnp/pnpbios/Makefile
--- a/drivers/pnp/pnpbios/Makefile Sun Nov 16 00:25:01 2003
+++ b/drivers/pnp/pnpbios/Makefile Sun Nov 16 00:25:01 2003
@@ -2,6 +2,6 @@
# Makefile for the kernel PNPBIOS driver.
#

-pnpbios-proc-$(CONFIG_PROC_FS) = proc.o
+pnpbios-proc-$(CONFIG_PNPBIOS_PROC_FS) = proc.o

obj-y := core.o bioscalls.o rsparser.o $(pnpbios-proc-y)
diff -Nru a/drivers/pnp/pnpbios/pnpbios.h b/drivers/pnp/pnpbios/pnpbios.h
--- a/drivers/pnp/pnpbios/pnpbios.h Sun Nov 16 00:25:01 2003
+++ b/drivers/pnp/pnpbios/pnpbios.h Sun Nov 16 00:25:01 2003
@@ -36,7 +36,7 @@
extern void pnpbios_print_status(const char * module, u16 status);
extern void pnpbios_calls_init(union pnp_bios_install_struct * header);

-#ifdef CONFIG_PROC_FS
+#ifdef CONFIG_PNPBIOS_PROC_FS
extern int pnpbios_interface_attach_device(struct pnp_bios_node * node);
extern int pnpbios_proc_init (void);
extern void pnpbios_proc_exit (void);
@@ -44,4 +44,4 @@
static inline int pnpbios_interface_attach_device(struct pnp_bios_node * node) { return 0; }
static inline int pnpbios_proc_init (void) { return 0; }
static inline void pnpbios_proc_exit (void) { ; }
-#endif /* CONFIG_PROC */
+#endif /* CONFIG_PNPBIOS_PROC_FS */