[PATCH] PCI device-node failure detection

Nathan Lynch ntl at pobox.com
Wed Jun 1 05:51:27 EST 2005


Jake Moilanen wrote:
> 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;
> +}
> +

"fail" is not the only possible state that would indicate that the
device is unusable, if I'm reading IEEE 1275 right.  There is also
"disabled" and "fail-xxx" where xxx is additional info about the
fault.  I've never seen "fail-xxx" myself but I've seen "disabled" on
devices that were deconfigured by firmware (failing cpu iirc).

Unless we want to treat "disabled" and "fail[-xxx]" differently, I
think we should be checking that the status property, if present,
says "okay".

Something like:

int dn_failed(struct device_node *dn)
{
	char *status = get_property(dn, "status", NULL);

	if (!status)
		return 0;

	if (!strcmp(status, "okay"))
		return 0;

	return 1;
}

Also, I think this function could be made a static helper in
pSeries_pci.c until something outside of that file needs it.


Nathan



More information about the Linuxppc64-dev mailing list