[PATCH] ppc64: PCI device-node failure detection

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@austin.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>

authored by

Jake Moilanen and committed by
Paul Mackerras
293da76b 34153fa3

+17 -2
+17 -2
arch/ppc64/kernel/rtas_pci.c
··· 58 58 return 0; 59 59 } 60 60 61 + static int of_device_available(struct device_node * dn) 62 + { 63 + char * status; 64 + 65 + status = get_property(dn, "status", NULL); 66 + 67 + if (!status) 68 + return 1; 69 + 70 + if (!strcmp(status, "okay")) 71 + return 1; 72 + 73 + return 0; 74 + } 75 + 61 76 static int rtas_read_config(struct device_node *dn, int where, int size, u32 *val) 62 77 { 63 78 int returnval = -1; ··· 118 103 119 104 /* Search only direct children of the bus */ 120 105 for (dn = busdn->child; dn; dn = dn->sibling) 121 - if (dn->devfn == devfn) 106 + if (dn->devfn == devfn && of_device_available(dn)) 122 107 return rtas_read_config(dn, where, size, val); 123 108 return PCIBIOS_DEVICE_NOT_FOUND; 124 109 } ··· 161 146 162 147 /* Search only direct children of the bus */ 163 148 for (dn = busdn->child; dn; dn = dn->sibling) 164 - if (dn->devfn == devfn) 149 + if (dn->devfn == devfn && of_device_available(dn)) 165 150 return rtas_write_config(dn, where, size, val); 166 151 return PCIBIOS_DEVICE_NOT_FOUND; 167 152 }