From 9b41f0a787b0051a4af89874fdab6ae3d78e12f9 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Mon, 10 Nov 2003 16:04:11 +0000 Subject: [PATCH] Don't establish the ISR in the sn_activate routine. I've had two crashes that had sn0 as the irq that's being serviced, when there was no sn0 in the system. This seems to prevent them. Also, we want to wait until after we've registered with the network layer before we turn on the interrupt spigot to avoid races. --- sys/dev/sn/if_sn.c | 18 +++++++++++------- sys/dev/sn/if_sn_isa.c | 5 ----- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/sys/dev/sn/if_sn.c b/sys/dev/sn/if_sn.c index 49cd84321f4c..5d5c05c71667 100644 --- a/sys/dev/sn/if_sn.c +++ b/sys/dev/sn/if_sn.c @@ -165,6 +165,7 @@ sn_attach(device_t dev) int rev; uint16_t address; int j; + int err; sc->dev = dev; sn_activate(dev); @@ -234,6 +235,16 @@ sn_attach(device_t dev) bcopy(sc->arpcom.ac_enaddr, LLADDR(sdl), ETHER_ADDR_LEN); } + /* + * Activate the interrupt so we can get card interrupts. This + * needs to be done last so that we don't have/hold the lock + * during startup to avoid LORs in the network layer. + */ + if ((err = bus_setup_intr(dev, sc->irq_res, + INTR_TYPE_NET | INTR_MPSAFE, sn_intr, sc, &sc->intrhand)) != 0) { + sn_detach(dev); + return err; + } return 0; } @@ -1223,7 +1234,6 @@ int sn_activate(device_t dev) { struct sn_softc *sc = device_get_softc(dev); - int err; sc->port_rid = 0; sc->port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->port_rid, @@ -1243,12 +1253,6 @@ sn_activate(device_t dev) sn_deactivate(dev); return ENOMEM; } - if ((err = bus_setup_intr(dev, sc->irq_res, - INTR_TYPE_NET | INTR_MPSAFE, sn_intr, sc, &sc->intrhand)) != 0) { - sn_deactivate(dev); - return err; - } - sc->bst = rman_get_bustag(sc->port_res); sc->bsh = rman_get_bushandle(sc->port_res); return (0); diff --git a/sys/dev/sn/if_sn_isa.c b/sys/dev/sn/if_sn_isa.c index a793be23f288..f88f3385d28b 100644 --- a/sys/dev/sn/if_sn_isa.c +++ b/sys/dev/sn/if_sn_isa.c @@ -10,11 +10,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Herb Peyerl. - * 4. The name of Herb Peyerl may not be used to endorse or promote products - * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES