Date: Sun, 22 Mar 2009 20:54:22 +0000 (UTC) From: Marius Strobl <marius@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org Subject: svn commit: r190281 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb sparc64/fhc sparc64/sparc64 Message-ID: <200903222054.n2MKsMAR083254@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: marius Date: Sun Mar 22 20:54:22 2009 New Revision: 190281 URL: http://svn.freebsd.org/changeset/base/190281 Log: MFC: r190098 - Failing to register as interrupt controller during attach shouldn't be fatal so just inform about this instead of panicing. - Sort device methods. - Take advantage of KOBJMETHOD_END. - Remove some redundant variables. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/sparc64/fhc/fhc.c stable/7/sys/sparc64/sparc64/upa.c Modified: stable/7/sys/sparc64/fhc/fhc.c ============================================================================== --- stable/7/sys/sparc64/fhc/fhc.c Sun Mar 22 20:52:44 2009 (r190280) +++ stable/7/sys/sparc64/fhc/fhc.c Sun Mar 22 20:54:22 2009 (r190281) @@ -90,14 +90,14 @@ static device_method_t fhc_methods[] = { /* Bus interface */ DEVMETHOD(bus_print_child, fhc_print_child), DEVMETHOD(bus_probe_nomatch, fhc_probe_nomatch), - DEVMETHOD(bus_setup_intr, fhc_setup_intr), - DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), DEVMETHOD(bus_alloc_resource, fhc_alloc_resource), - DEVMETHOD(bus_release_resource, bus_generic_rl_release_resource), DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), - DEVMETHOD(bus_get_resource_list, fhc_get_resource_list), + DEVMETHOD(bus_release_resource, bus_generic_rl_release_resource), + DEVMETHOD(bus_setup_intr, fhc_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), + DEVMETHOD(bus_get_resource_list, fhc_get_resource_list), /* ofw_bus interface */ DEVMETHOD(ofw_bus_get_devinfo, fhc_get_devinfo), @@ -107,7 +107,7 @@ static device_method_t fhc_methods[] = { DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node), DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type), - { NULL, NULL } + KOBJMETHOD_END }; static driver_t fhc_driver = { @@ -165,9 +165,7 @@ fhc_attach(device_t dev) int central; int error; int i; - int nintr; - int nreg; - int rid; + int j; sc = device_get_softc(dev); node = ofw_bus_get_node(dev); @@ -177,9 +175,9 @@ fhc_attach(device_t dev) central = 1; for (i = 0; i < FHC_NREG; i++) { - rid = i; + j = i; sc->sc_memres[i] = bus_alloc_resource_any(dev, SYS_RES_MEMORY, - &rid, RF_ACTIVE); + &j, RF_ACTIVE); if (sc->sc_memres[i] == NULL) { device_printf(dev, "cannot allocate resource %d\n", i); error = ENXIO; @@ -239,7 +237,8 @@ fhc_attach(device_t dev) /* * Hunt through all the interrupt mapping regs and register * our interrupt controller for the corresponding interrupt - * vectors. + * vectors. We do this early in order to be able to catch + * stray interrupts. */ for (i = FHC_FANFAIL; i <= FHC_TOD; i++) { fica = malloc(sizeof(*fica), M_DEVBUF, M_NOWAIT); @@ -259,11 +258,13 @@ fhc_attach(device_t dev) * the IGN and the IGN is constant for all devices * on that FireHose controller. */ - if (intr_controller_register(INTMAP_VEC(sc->sc_ign, + j = intr_controller_register(INTMAP_VEC(sc->sc_ign, INTINO(bus_read_4(fica->fica_memres, FHC_IMAP))), - &fhc_ic, fica) != 0) - panic("%s: could not register interrupt " - "controller for map %d", __func__, i); + &fhc_ic, fica); + if (j != 0) + device_printf(dev, "could not register " + "interrupt controller for map %d (%d)\n", + i, j); } } else { snprintf(ledname, sizeof(ledname), "board%d", board); @@ -276,9 +277,9 @@ fhc_attach(device_t dev) free(fdi, M_DEVBUF); continue; } - nreg = OF_getprop_alloc(child, "reg", sizeof(*reg), + i = OF_getprop_alloc(child, "reg", sizeof(*reg), (void **)®); - if (nreg == -1) { + if (i == -1) { device_printf(dev, "<%s>: incomplete\n", fdi->fdi_obdinfo.obd_name); ofw_bus_gen_destroy_devinfo(&fdi->fdi_obdinfo); @@ -286,19 +287,19 @@ fhc_attach(device_t dev) continue; } resource_list_init(&fdi->fdi_rl); - for (i = 0; i < nreg; i++) - resource_list_add(&fdi->fdi_rl, SYS_RES_MEMORY, i, - reg[i].sbr_offset, reg[i].sbr_offset + - reg[i].sbr_size, reg[i].sbr_size); + for (j = 0; j < i; j++) + resource_list_add(&fdi->fdi_rl, SYS_RES_MEMORY, j, + reg[j].sbr_offset, reg[j].sbr_offset + + reg[j].sbr_size, reg[j].sbr_size); free(reg, M_OFWPROP); if (central == 1) { - nintr = OF_getprop_alloc(child, "interrupts", + i = OF_getprop_alloc(child, "interrupts", sizeof(*intr), (void **)&intr); - if (nintr != -1) { - for (i = 0; i < nintr; i++) { - iv = INTMAP_VEC(sc->sc_ign, intr[i]); + if (i != -1) { + for (j = 0; j < i; j++) { + iv = INTMAP_VEC(sc->sc_ign, intr[j]); resource_list_add(&fdi->fdi_rl, - SYS_RES_IRQ, i, iv, iv, 1); + SYS_RES_IRQ, j, iv, iv, 1); } free(intr, M_OFWPROP); } Modified: stable/7/sys/sparc64/sparc64/upa.c ============================================================================== --- stable/7/sys/sparc64/sparc64/upa.c Sun Mar 22 20:52:44 2009 (r190280) +++ stable/7/sys/sparc64/sparc64/upa.c Sun Mar 22 20:54:22 2009 (r190281) @@ -144,7 +144,7 @@ static device_method_t upa_methods[] = { DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node), DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type), - { NULL, NULL } + KOBJMETHOD_END }; static devclass_t upa_devclass; @@ -241,7 +241,7 @@ upa_attach(device_t dev) "pci108e,8001") == 0 && ((bus_get_resource_start(children[j], SYS_RES_MEMORY, 0) >> 20) & 1) == 1) { - schizo = children[j]; + schizo = children[j]; break; } } @@ -287,9 +287,10 @@ upa_attach(device_t dev) goto fail; } - /* + /* * Hunt through all the interrupt mapping regs and register our * interrupt controller for the corresponding interrupt vectors. + * We do this early in order to be able to catch stray interrupts. */ for (i = UPA_INO_BASE; i <= UPA_INO_MAX; i++) { imr = 0; @@ -312,10 +313,11 @@ upa_attach(device_t dev) device_printf(dev, "intr map (INO %d) IMR%d: %#lx\n", i, imr, (u_long)UPA_READ(sc, imr, 0x0)); #endif - if (intr_controller_register(INTMAP_VEC(sc->sc_ign, i), - &upa_ic, uica) != 0) - panic("%s: could not register interrupt controller " - "for INO %d", __func__, i); + j = intr_controller_register(INTMAP_VEC(sc->sc_ign, i), + &upa_ic, uica); + if (j != 0) + device_printf(dev, "could not register interrupt " + "controller for INO %d (%d)\n", i, j); } /* Make sure the power level is appropriate for normal operation. */ @@ -345,13 +347,13 @@ upa_attach(device_t dev) device_printf(dev, "could not determine upa-portid of child 0x%lx\n", (unsigned long)child); - continue; + continue; } if (portid > 1) { device_printf(dev, "upa-portid %d of child 0x%lx invalid\n", portid, (unsigned long)child); - continue; + continue; } if ((udi = upa_setup_dinfo(dev, sc, child, portid)) == NULL) continue; @@ -493,12 +495,12 @@ upa_setup_intr(device_t dev, device_t ch /* * Make sure the vector is fully specified and we registered * our interrupt controller for it. - */ + */ vec = rman_get_start(ires); if (INTIGN(vec) != sc->sc_ign || intr_vectors[vec].iv_ic != &upa_ic) { device_printf(dev, "invalid interrupt vector 0x%lx\n", vec); - return (EINVAL); - } + return (EINVAL); + } return (bus_generic_setup_intr(dev, child, ires, flags, filt, func, arg, cookiep)); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200903222054.n2MKsMAR083254>