Skip to contentSkip to conversation

PnP Fixes for 2.6.0-test5

PATCH In review Adam Belay 2 participants 10 messages Sep 22, 2003 – Sep 24, 2003

Subsystems (2)
lore
Share & tools
lore

Adam Belay

author
#0 lore raw

PATCH 1/1 PnP Fixes for 2.6.0-test5

# --------------------------------------------
# 03/09/21 [email protected] 1.1354
# [PNPBIOS] compilation fix for pnpbios without proc support #
# Here's an updated patch that will correct the compile error when PROC # FS is disabled. It also introduces better proc error recovery and

# moves the local proc functions to the local include file.  Thanks to
# Daniele Bellucci for finding the problem and contributing to this
# patch.
#
# --------------------------------------------
#
diff -Nru a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c
--- a/drivers/pnp/pnpbios/core.c	Sun Sep 21 19:46:16 2003
+++ b/drivers/pnp/pnpbios/core.c	Sun Sep 21 19:46:16 2003
@@ -431,14 +431,15 @@
 	}

/* register with the pnp layer */
- pnp_register_protocol(&pnpbios_protocol);
+ if (pnp_register_protocol(&pnpbios_protocol)) {
+ printk(KERN_ERR "PnPBIOS: Unable to register driver. Aborting.\n");
+ return -EIO;
+ }

-#ifdef CONFIG_PROC_FS
/* start the proc interface */
ret = pnpbios_proc_init();
if (ret)
- return ret;
-#endif
+ printk(KERN_ERR "PnPBIOS: Failed to create proc interface.\n");

/* scan for pnpbios devices */
build_devlist();

drivers/pnp/pnpbios/pnpbios.h +10 -0
diff -Nru a/drivers/pnp/pnpbios/pnpbios.h b/drivers/pnp/pnpbios/pnpbios.h
@@ -9,3 +9,13 @@
 
 extern void pnpbios_print_status(const char * module, u16 status);
 extern int pnpbios_probe_installation(void);
+
+#ifdef CONFIG_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);
+#else
+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 */
drivers/pnp/pnpbios/proc.c +12 -2
diff -Nru a/drivers/pnp/pnpbios/proc.c b/drivers/pnp/pnpbios/proc.c
@@ -31,6 +31,8 @@
 
 #include <asm/uaccess.h>
 
+#include "pnpbios.h"
+
 static struct proc_dir_entry *proc_pnp = NULL;
 static struct proc_dir_entry *proc_pnp_boot = NULL;
 
@@ -213,6 +215,9 @@
 	struct proc_dir_entry *ent;
 
 	sprintf(name, "%02x", node->handle);
+
+	if (!proc_pnp)
+		return -EIO;
 	if ( !pnpbios_dont_use_current_config ) {
 		ent = create_proc_entry(name, 0, proc_pnp);
 		if (ent) {
@@ -221,6 +226,9 @@
 			ent->data = (void *)(long)(node->handle);
 		}
 	}
+
+	if (!proc_pnp_boot)
+		return -EIO;
 	ent = create_proc_entry(name, 0, proc_pnp_boot);
 	if (ent) {
 		ent->read_proc = proc_read_node;
@@ -228,6 +236,7 @@
 		ent->data = (void *)(long)(node->handle+0x100);
 		return 0;
 	}
+
 	return -EIO;
 }
 
@@ -257,8 +266,9 @@
 {
 	int i;
 	char name[3];
-	
-	if (!proc_pnp) return;
+
+	if (!proc_pnp)
+		return;
 
 	for (i=0; i<0xff; i++) {
 		sprintf(name, "%02x", i);
include/linux/pnpbios.h +1 -4
diff -Nru a/include/linux/pnpbios.h b/include/linux/pnpbios.h
@@ -26,7 +26,7 @@
 #ifdef __KERNEL__
 
 #include <linux/types.h>
-#include <linux/pci.h>
+#include <linux/pnp.h>
 
 /*
  * Return codes
@@ -135,9 +135,6 @@
 extern struct pnp_dev_node_info node_info;
 extern void *pnpbios_kmalloc(size_t size, int f);
 extern int pnpbios_init (void);
-extern int pnpbios_interface_attach_device(struct pnp_bios_node * node);
-extern int pnpbios_proc_init (void);
-extern void pnpbios_proc_exit (void);
 
 extern int pnp_bios_dev_node_info (struct pnp_dev_node_info *data);
 extern int pnp_bios_get_dev_node (u8 *nodenum, char config, struct pnp_bios_node *data);
author
#1 lore raw

# --------------------------------------------
# 03/09/21 [email protected] 1.1355
# [PNP] release card devices on probe failure
#
# When a driver's probe routine fails, it may not release all of the

# card devices it requested.  This patch allows the pnp layer to ensure
# that all devices claimed by the failing driver are released properly.
# --------------------------------------------
#
diff -Nru a/drivers/pnp/card.c b/drivers/pnp/card.c
--- a/drivers/pnp/card.c	Sun Sep 21 19:46:10 2003
+++ b/drivers/pnp/card.c	Sun Sep 21 19:46:10 2003
@@ -62,8 +62,14 @@
 		if (drv->probe) {
 			if (drv->probe(clink, id)>=0)
 				return 1;
-			else
+			else {
+				struct pnp_dev * dev;
+				card_for_each_dev(card, dev) {
+					if (dev->card_link == clink)
+						pnp_release_card_device(dev);
+				}
 				kfree(clink);
+			}
 		} else
 			return 1;
 	}
author
#2 lore raw
In reply to Adam Belay

# --------------------------------------------
# 03/09/21 [email protected] 1.1357
# [PNP] remove DMA 0 restrictions
#
# The original argument for blocking DMA 0 was to avoid conflicts with # "memory refresh" but such configurations are only found on very old # 8-bit systems that are likely not supported by the linux kernel. # This patch allows dma 0 to be assigned to PnP devices by default. If

# for whatever reason dma 0 cannot be used, one can avoid allocating it
# by setting the pnp_reserve_dma= kernel parameter.
# --------------------------------------------
#
diff -Nru a/drivers/pnp/quirks.c b/drivers/pnp/quirks.c
--- a/drivers/pnp/quirks.c	Sun Sep 21 19:45:59 2003
+++ b/drivers/pnp/quirks.c	Sun Sep 21 19:45:59 2003
@@ -111,28 +111,6 @@
 	return;
 }

-extern int pnp_allow_dma0;
-static void quirk_opl3sax_resources(struct pnp_dev *dev)
-{
- /* This really isn't a device quirk but isapnp core code
- * doesn't allow a DMA channel of 0, afflicted card is an
- * OPL3Sax where x=4.
- */
- struct pnp_option *res;
- int max;
- res = dev->dependent;
- max = 0;
- for (; res; res = res->next) {
- if (res->dma->map > max)
- max = res->dma->map;
- }
- if (max == 1 && pnp_allow_dma0 == -1) {
- printk(KERN_INFO "pnp: opl3sa4 quirk: Allowing dma 0.\n");
- pnp_allow_dma0 = 1;
- }
- return;
-}
-
/*
* PnP Quirks
* Cards or devices that need some tweaking due to incomplete resource info
@@ -153,7 +131,6 @@
{ "CTL0043", quirk_sb16audio_resources },
{ "CTL0044", quirk_sb16audio_resources },
{ "CTL0045", quirk_sb16audio_resources },
- { "YMH0021", quirk_opl3sax_resources },
{ "" }
};

@@ -170,4 +147,3 @@
i++;
}
}
-

drivers/pnp/resource.c +2 -16
diff -Nru a/drivers/pnp/resource.c b/drivers/pnp/resource.c
@@ -21,8 +21,6 @@
 #include <linux/pnp.h>
 #include "base.h"
 
-int pnp_allow_dma0 = -1;		        /* allow dma 0 during auto activation:
-						 * -1=off (:default), 0=off (set by user), 1=on */
 int pnp_skip_pci_scan;				/* skip PCI resource scanning */
 int pnp_reserve_irq[16] = { [0 ... 15] = -1 };	/* reserve (don't use) some IRQ */
 int pnp_reserve_dma[8] = { [0 ... 7] = -1 };	/* reserve (don't use) some DMA */
@@ -426,7 +424,7 @@
 
 int pnp_check_dma(struct pnp_dev * dev, int idx)
 {
-	int tmp, mindma = 1;
+	int tmp;
 	struct pnp_dev *tdev;
 	unsigned long * dma = &dev->res.dma_resource[idx].start;
 
@@ -435,9 +433,7 @@
 		return 1;
 
 	/* check if the resource is valid */
-	if (pnp_allow_dma0 == 1)
-		mindma = 0;
-	if (*dma < mindma || *dma == 4 || *dma > 7)
+	if (*dma < 0 || *dma == 4 || *dma > 7)
 		return 0;
 
 	/* check if the resource is reserved */
@@ -487,16 +483,6 @@
 EXPORT_SYMBOL(pnp_register_port_resource);
 EXPORT_SYMBOL(pnp_register_mem_resource);
 
-
-/* format is: allowdma0 */
-
-static int __init pnp_allowdma0(char *str)
-{
-        pnp_allow_dma0 = 1;
-	return 1;
-}
-
-__setup("allowdma0", pnp_allowdma0);
 
 /* format is: pnp_reserve_irq=irq1[,irq2] .... */
 
#3 lore raw
Quoted 7 lines · Adam Belay

# --------------------------------------------
# 03/09/21 [email protected] 1.1357
# [PNP] remove DMA 0 restrictions
#
# The original argument for blocking DMA 0 was to avoid conflicts with # "memory refresh" but such configurations are only found on very old # 8-bit systems that are likely not supported by the linux kernel.

DMA0 is used by lots of 386/486 era systems for memory refresh. It is also "borrowed" by some other systems that know it isnt available to the OS. There are a couple of heuristics I've seen suggested by vendors of things like sound cards

1. Check the PnPBIOS information (never looked into this myself)
2. Assume DMA 0 is free if the machine has a PCI bus detected
3. Read the DMA 0 counter a few times. If it is continually changing
don't use DMA 0

#2 is certainly a good idea IMHO, I don't know how well the others work.

author
#4 lore raw
Quoted 9 lines · Alan Cox
Quoted 7 lines · Adam Belay

# --------------------------------------------
# 03/09/21 [email protected] 1.1357
# [PNP] remove DMA 0 restrictions
#
# The original argument for blocking DMA 0 was to avoid conflicts with # "memory refresh" but such configurations are only found on very old # 8-bit systems that are likely not supported by the linux kernel.

Quoted 6 lines

DMA0 is used by lots of 386/486 era systems for memory refresh. It is also "borrowed" by some other systems that know it isnt available to the OS. There are a couple of heuristics I've seen suggested by vendors of things like sound cards

1. Check the PnPBIOS information (never looked into this myself)

Assuming the PnPBIOS provides this information through device nodes, the current pnp code will ensure that dma 0 is not used.

Quoted 5 lines

2. Assume DMA 0 is free if the machine has a PCI bus detected
3. Read the DMA 0 counter a few times. If it is continually changing
don't use DMA 0

#2 is certainly a good idea IMHO, I don't know how well the others work.

Thanks, I'll look into these further.

Regards,
Adam

author
#5 lore raw
In reply to Adam Belay

# --------------------------------------------
# 03/09/21 [email protected] 1.1358
# [PATCH] janitor: remove unneeded includes (isapnp) #
# From: Randy Hron <[email protected]>
# -------------------------------------------- #

drivers/pnp/isapnp/compat.c +0 -1
diff -Nru a/drivers/pnp/isapnp/compat.c b/drivers/pnp/isapnp/compat.c
@@ -9,7 +9,6 @@
 /* TODO: see if more isapnp functions are needed here */
 
 #include <linux/config.h>
-#include <linux/version.h>
 #include <linux/module.h>
 #include <linux/isapnp.h>
 #include <linux/string.h>
drivers/pnp/isapnp/core.c +0 -1
diff -Nru a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c
@@ -35,7 +35,6 @@
  */
 
 #include <linux/config.h>
-#include <linux/version.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
drivers/pnp/isapnp/proc.c +0 -1
diff -Nru a/drivers/pnp/isapnp/proc.c b/drivers/pnp/isapnp/proc.c
@@ -20,7 +20,6 @@
  */
 
 #include <linux/config.h>
-#include <linux/version.h>
 #include <linux/module.h>
 #include <linux/isapnp.h>
 #include <linux/proc_fs.h>
author
#6 lore raw
In reply to Adam Belay

# --------------------------------------------
# 03/09/21 [email protected] 1.1356
# [PNPBIOS] move detection code into core.c
#
# This patch moves the detection code to a more appropriate file. # --------------------------------------------
#

drivers/pnp/pnpbios/bioscalls.c +3 -86
diff -Nru a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
@@ -23,41 +23,7 @@
 #include <asm/system.h>
 #include <asm/byteorder.h>
 
-
-/* PnP BIOS signature: "$PnP" */
-#define PNP_SIGNATURE   (('$' << 0) + ('P' << 8) + ('n' << 16) + ('P' << 24))
-
-#pragma pack(1)
-union pnp_bios_expansion_header {
-	struct {
-		u32 signature;    /* "$PnP" */
-		u8 version;	  /* in BCD */
-		u8 length;	  /* length in bytes, currently 21h */
-		u16 control;	  /* system capabilities */
-		u8 checksum;	  /* all bytes must add up to 0 */
-
-		u32 eventflag;    /* phys. address of the event flag */
-		u16 rmoffset;     /* real mode entry point */
-		u16 rmcseg;
-		u16 pm16offset;   /* 16 bit protected mode entry */
-		u32 pm16cseg;
-		u32 deviceID;	  /* EISA encoded system ID or 0 */
-		u16 rmdseg;	  /* real mode data segment */
-		u32 pm16dseg;	  /* 16 bit pm data segment base */
-	} fields;
-	char chars[0x21];	  /* To calculate the checksum */
-};
-#pragma pack()
-
-static union pnp_bios_expansion_header * pnp_bios_hdr = NULL;
-
-/*
- * Call this only after init time
- */
-static int pnp_bios_present(void)
-{
-	return (pnp_bios_hdr != NULL);
-}
+#include "pnpbios.h"
 
 static struct {
 	u16	offset;
@@ -557,10 +523,10 @@
 
 
 /*
- * Probing and Initialization
+ * Initialization
  */
 
-static void pnpbios_prepare_bios_calls(union pnp_bios_expansion_header *header)
+void pnpbios_calls_init(union pnp_bios_install_struct *header)
 {
 	int i;
 	spin_lock_init(&pnp_bios_lock);
@@ -575,53 +541,4 @@
 		Q_SET_SEL(i, PNP_CS16, header->fields.pm16cseg, 64 * 1024);
 		Q_SET_SEL(i, PNP_DS, header->fields.pm16dseg, 64 * 1024);
 	}
-}
-
-int pnpbios_probe_installation(void)
-{
-	union pnp_bios_expansion_header *check;
-	u8 sum;
-	int length, i;
-
-	printk(KERN_INFO "PnPBIOS: Scanning system for PnP BIOS support...\n");
-
-	/*
- 	 * Search the defined area (0xf0000-0xffff0) for a valid PnP BIOS
-	 * structure and, if one is found, sets up the selectors and
-	 * entry points
-	 */
-	for (check = (union pnp_bios_expansion_header *) __va(0xf0000);
-	     check < (union pnp_bios_expansion_header *) __va(0xffff0);
-	     ((void *) (check)) += 16) {
-		if (check->fields.signature != PNP_SIGNATURE)
-			continue;
-		printk(KERN_INFO "PnPBIOS: Found PnP BIOS installation structure at 0x%p\n", check);
-		length = check->fields.length;
-		if (!length) {
-			printk(KERN_ERR "PnPBIOS: installation structure is invalid, skipping\n");
-			continue;
-		}
-		for (sum = 0, i = 0; i < length; i++)
-			sum += check->chars[i];
-		if (sum) {
-			printk(KERN_ERR "PnPBIOS: installation structure is corrupted, skipping\n");
-			continue;
-		}
-		if (check->fields.version < 0x10) {
-			printk(KERN_WARNING "PnPBIOS: PnP BIOS version %d.%d is not supported\n",
-			       check->fields.version >> 4,
-			       check->fields.version & 15);
-			continue;
-		}
-		printk(KERN_INFO "PnPBIOS: PnP BIOS version %d.%d, entry 0x%x:0x%x, dseg 0x%x\n",
-                       check->fields.version >> 4, check->fields.version & 15,
-		       check->fields.pm16cseg, check->fields.pm16offset,
-		       check->fields.pm16dseg);
-		pnp_bios_hdr = check;
-		pnpbios_prepare_bios_calls(check);
-		return 1;
-	}
-
-	printk(KERN_INFO "PnPBIOS: PnP BIOS support was not detected.\n");
-	return 0;
 }
drivers/pnp/pnpbios/core.c +63 -2

91 lines not on this page · raw message

drivers/pnp/pnpbios/pnpbios.h +26 -2
diff -Nru a/drivers/pnp/pnpbios/pnpbios.h b/drivers/pnp/pnpbios/pnpbios.h
@@ -1,14 +1,38 @@
 /*
- * pnpbios.h - contains definitions for functions used only locally.
+ * pnpbios.h - contains local definitions
  */
 
+#pragma pack(1)
+union pnp_bios_install_struct {
+	struct {
+		u32 signature;    /* "$PnP" */
+		u8 version;	  /* in BCD */
+		u8 length;	  /* length in bytes, currently 21h */
+		u16 control;	  /* system capabilities */
+		u8 checksum;	  /* all bytes must add up to 0 */
+
+		u32 eventflag;    /* phys. address of the event flag */
+		u16 rmoffset;     /* real mode entry point */
+		u16 rmcseg;
+		u16 pm16offset;   /* 16 bit protected mode entry */
+		u32 pm16cseg;
+		u32 deviceID;	  /* EISA encoded system ID or 0 */
+		u16 rmdseg;	  /* real mode data segment */
+		u32 pm16dseg;	  /* 16 bit pm data segment base */
+	} fields;
+	char chars[0x21];	  /* To calculate the checksum */
+};
+#pragma pack()
+
+extern int pnp_bios_present(void);
+
 extern int pnpbios_parse_data_stream(struct pnp_dev *dev, struct pnp_bios_node * node);
 extern int pnpbios_read_resources_from_node(struct pnp_resource_table *res, struct pnp_bios_node * node);
 extern int pnpbios_write_resources_to_node(struct pnp_resource_table *res, struct pnp_bios_node * node);
 extern void pnpid32_to_pnpid(u32 id, char *str);
 
 extern void pnpbios_print_status(const char * module, u16 status);
-extern int pnpbios_probe_installation(void);
+extern void pnpbios_calls_init(union pnp_bios_install_struct * header);
 
 #ifdef CONFIG_PROC_FS
 extern int pnpbios_interface_attach_device(struct pnp_bios_node * node);
author
#7 lore raw
In reply to Adam Belay

# --------------------------------------------
# 03/09/21 [email protected] 1.1360
# [PNPBIOS] return proper error codes on init failure # -------------------------------------------- #

drivers/pnp/pnpbios/core.c +6 -4
diff -Nru a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c
@@ -484,15 +484,17 @@
 	pnpbios_calls_init(pnp_bios_install);
 
 	/* read the node info */
-	if (pnp_bios_dev_node_info(&node_info)) {
+	ret = pnp_bios_dev_node_info(&node_info);
+	if (ret) {
 		printk(KERN_ERR "PnPBIOS: Unable to get node info.  Aborting.\n");
-		return -EIO;
+		return ret;
 	}
 
 	/* register with the pnp layer */
-	if (pnp_register_protocol(&pnpbios_protocol)) {
+	ret = pnp_register_protocol(&pnpbios_protocol);
+	if (ret) {
 		printk(KERN_ERR "PnPBIOS: Unable to register driver.  Aborting.\n");
-		return -EIO;
+		return ret;
 	}
 
 	/* start the proc interface */
author
#8 lore raw
In reply to Adam Belay

# --------------------------------------------
# 03/09/21 [email protected] 1.1361
# [PNPBIOS] move some more functions to local include file #
# This patch moves some unnecessary global functions to the local

# pnpbios include file.
# 
# --------------------------------------------
#
diff -Nru a/drivers/pnp/pnpbios/pnpbios.h b/drivers/pnp/pnpbios/pnpbios.h
--- a/drivers/pnp/pnpbios/pnpbios.h	Sun Sep 21 19:45:34 2003
+++ b/drivers/pnp/pnpbios/pnpbios.h	Sun Sep 21 19:45:34 2003
@@ -25,6 +25,8 @@
 #pragma pack()

extern int pnp_bios_present(void);
+extern int pnpbios_dont_use_current_config; +extern void *pnpbios_kmalloc(size_t size, int f);

extern int pnpbios_parse_data_stream(struct pnp_dev *dev, struct pnp_bios_node * node); extern int pnpbios_read_resources_from_node(struct pnp_resource_table *res, struct pnp_bios_node * node);

include/linux/pnpbios.h +0 -3
diff -Nru a/include/linux/pnpbios.h b/include/linux/pnpbios.h
@@ -131,10 +131,7 @@
 #ifdef CONFIG_PNPBIOS
 
 /* non-exported */
-extern int  pnpbios_dont_use_current_config;
 extern struct pnp_dev_node_info node_info;
-extern void *pnpbios_kmalloc(size_t size, int f);
-extern int pnpbios_init (void);
 
 extern int pnp_bios_dev_node_info (struct pnp_dev_node_info *data);
 extern int pnp_bios_get_dev_node (u8 *nodenum, char config, struct pnp_bios_node *data);
author
#9 lore raw
In reply to Adam Belay

# --------------------------------------------
# 03/09/21 [email protected] 1.1359
# [ISAPNP] remove unused isapnp_allow_dma0 modparam
#
# It looks like this option has been moved from isapnp to resource.c,

# but the MODULE_PARM line is still there:
# 
# patch from: Gerald Teschl <[email protected]>
# --------------------------------------------
#
diff -Nru a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c
--- a/drivers/pnp/isapnp/core.c	Sun Sep 21 19:45:47 2003
+++ b/drivers/pnp/isapnp/core.c	Sun Sep 21 19:45:47 2003
@@ -64,7 +64,6 @@
 MODULE_PARM_DESC(isapnp_rdp, "ISA Plug & Play read data port");
 MODULE_PARM(isapnp_reset, "i");
 MODULE_PARM_DESC(isapnp_reset, "ISA Plug & Play reset all cards");
-MODULE_PARM(isapnp_allow_dma0, "i");
 MODULE_PARM(isapnp_verbose, "i");
 MODULE_PARM_DESC(isapnp_verbose, "ISA Plug & Play verbose mode");
 MODULE_LICENSE("GPL");