[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 return 0; 59 } 60 61 static int rtas_read_config(struct device_node *dn, int where, int size, u32 *val) 62 { 63 int returnval = -1; ··· 118 119 /* Search only direct children of the bus */ 120 for (dn = busdn->child; dn; dn = dn->sibling) 121 - if (dn->devfn == devfn) 122 return rtas_read_config(dn, where, size, val); 123 return PCIBIOS_DEVICE_NOT_FOUND; 124 } ··· 161 162 /* Search only direct children of the bus */ 163 for (dn = busdn->child; dn; dn = dn->sibling) 164 - if (dn->devfn == devfn) 165 return rtas_write_config(dn, where, size, val); 166 return PCIBIOS_DEVICE_NOT_FOUND; 167 }
··· 58 return 0; 59 } 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 + 76 static int rtas_read_config(struct device_node *dn, int where, int size, u32 *val) 77 { 78 int returnval = -1; ··· 103 104 /* Search only direct children of the bus */ 105 for (dn = busdn->child; dn; dn = dn->sibling) 106 + if (dn->devfn == devfn && of_device_available(dn)) 107 return rtas_read_config(dn, where, size, val); 108 return PCIBIOS_DEVICE_NOT_FOUND; 109 } ··· 146 147 /* Search only direct children of the bus */ 148 for (dn = busdn->child; dn; dn = dn->sibling) 149 + if (dn->devfn == devfn && of_device_available(dn)) 150 return rtas_write_config(dn, where, size, val); 151 return PCIBIOS_DEVICE_NOT_FOUND; 152 }