Author: ian Date: Sun Aug 10 00:30:12 2014 New Revision: 269770 URL: http://svnweb.freebsd.org/changeset/base/269770
Log: Handle various ways that interrupt config data can be malformed by warning and assuming more or less reasonable values. Modified: head/sys/dev/ofw/ofwbus.c Modified: head/sys/dev/ofw/ofwbus.c ============================================================================== --- head/sys/dev/ofw/ofwbus.c Sun Aug 10 00:23:57 2014 (r269769) +++ head/sys/dev/ofw/ofwbus.c Sun Aug 10 00:30:12 2014 (r269770) @@ -435,6 +435,7 @@ ofwbus_setup_dinfo(device_t dev, phandle { struct ofwbus_softc *sc; struct ofwbus_devinfo *ndi; + const char *nodename; uint32_t *reg, *intr, icells; uint64_t phys, size; phandle_t iparent; @@ -449,8 +450,8 @@ ofwbus_setup_dinfo(device_t dev, phandle free(ndi, M_DEVBUF); return (NULL); } - if (OFWBUS_EXCLUDED(ndi->ndi_obdinfo.obd_name, - ndi->ndi_obdinfo.obd_type)) { + nodename = ndi->ndi_obdinfo.obd_name; + if (OFWBUS_EXCLUDED(nodename, ndi->ndi_obdinfo.obd_type)) { ofw_bus_gen_destroy_devinfo(&ndi->ndi_obdinfo); free(ndi, M_DEVBUF); return (NULL); @@ -463,7 +464,7 @@ ofwbus_setup_dinfo(device_t dev, phandle if (nreg % (sc->acells + sc->scells) != 0) { if (bootverbose) device_printf(dev, "Malformed reg property on <%s>\n", - ndi->ndi_obdinfo.obd_name); + nodename); nreg = 0; } @@ -487,11 +488,24 @@ ofwbus_setup_dinfo(device_t dev, phandle nintr = OF_getencprop_alloc(node, "interrupts", sizeof(*intr), (void **)&intr); if (nintr > 0) { - iparent = 0; - OF_searchencprop(node, "interrupt-parent", &iparent, - sizeof(iparent)); - OF_searchencprop(OF_xref_phandle(iparent), "#interrupt-cells", - &icells, sizeof(icells)); + if (OF_searchencprop(node, "interrupt-parent", &iparent, + sizeof(iparent)) == -1) { + device_printf(dev, "No interrupt-parent found, " + "assuming nexus on <%s>\n", nodename); + iparent = 0xffffffff; + } + if (OF_searchencprop(OF_xref_phandle(iparent), + "#interrupt-cells", &icells, sizeof(icells)) == -1) { + device_printf(dev, "Missing #interrupt-cells property, " + "assuming <1> on <%s>\n", nodename); + icells = 1; + } + if (icells < 1 || icells > nintr) { + device_printf(dev, "Invalid #interrupt-cells property " + "value <%d>, assuming <1> on <%s>\n", icells, + nodename); + icells = 1; + } for (i = 0, rid = 0; i < nintr; i += icells, rid++) { intr[i] = ofw_bus_map_intr(dev, iparent, icells, &intr[i]); _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"