[PATCH] PCI device-node failure detection

Jake Moilanen moilanen at austin.ibm.com
Wed Jun 1 01:12:25 EST 2005


OpenFirmware marks devices as failed in the device-tree when a hardware
problem is detected.  The kernel needs to fail config reads/writes to
prevent a kernel crash when incorrect data is read.  

This patch validates that the device-node is not marked "fail" when
config space reads/writes are attempted.

Signed-off-by: Jake Moilanen <moilanen at austin.ibm.com>

Index: 2.6.12/arch/ppc64/kernel/prom.c
===================================================================
--- 2.6.12.orig/arch/ppc64/kernel/prom.c	2005-03-02 01:38:13.000000000 -0600
+++ 2.6.12/arch/ppc64/kernel/prom.c	2005-05-27 18:44:33.172559207 -0500
@@ -1887,6 +1887,19 @@
 	*next = prop;
 }
 
+int
+dn_failed(struct device_node * dn)
+{
+	char * status;
+
+	status = get_property(dn, "status", NULL);
+
+	if (status && !strcmp(status, "fail"))
+		return 1;
+
+	return 0;
+}
+
 #if 0
 void
 print_properties(struct device_node *np)
Index: 2.6.12/arch/ppc64/kernel/pSeries_pci.c
===================================================================
--- 2.6.12.orig/arch/ppc64/kernel/pSeries_pci.c	2005-03-02 01:38:34.000000000 -0600
+++ 2.6.12/arch/ppc64/kernel/pSeries_pci.c	2005-05-27 18:44:33.183563164 -0500
@@ -96,7 +96,7 @@
 
 	/* Search only direct children of the bus */
 	for (dn = busdn->child; dn; dn = dn->sibling)
-		if (dn->devfn == devfn)
+		if (dn->devfn == devfn && !dn_failed(dn))
 			return rtas_read_config(dn, where, size, val);
 	return PCIBIOS_DEVICE_NOT_FOUND;
 }
@@ -138,7 +138,7 @@
 
 	/* Search only direct children of the bus */
 	for (dn = busdn->child; dn; dn = dn->sibling)
-		if (dn->devfn == devfn)
+		if (dn->devfn == devfn && !dn_failed(dn))
 			return rtas_write_config(dn, where, size, val);
 	return PCIBIOS_DEVICE_NOT_FOUND;
 }
Index: 2.6.12/include/asm-ppc64/prom.h
===================================================================
--- 2.6.12.orig/include/asm-ppc64/prom.h	2005-03-02 01:38:33.000000000 -0600
+++ 2.6.12/include/asm-ppc64/prom.h	2005-05-27 18:44:33.192566401 -0500
@@ -225,5 +225,6 @@
 extern int prom_n_intr_cells(struct device_node* np);
 extern void prom_get_irq_senses(unsigned char *senses, int off, int max);
 extern void prom_add_property(struct device_node* np, struct property* prop);
+extern int dn_failed(struct device_node * dn);
 
 #endif /* _PPC64_PROM_H */



More information about the Linuxppc64-dev mailing list