Don't lock in the attach routine. It isn't required. Register the

interrupt handler last.  This gets rid of the sleep while locked
messages.

Reviewed by: ambrisko
This commit is contained in:
Warner Losh 2003-04-10 05:12:45 +00:00
parent f5746231ff
commit 5414629575
4 changed files with 44 additions and 37 deletions

View File

@ -668,13 +668,12 @@ an_attach(sc, unit, flags)
int flags;
{
struct ifnet *ifp = &sc->arpcom.ac_if;
int error;
int error = EIO;
int i, nrate, mword;
u_int8_t r;
mtx_init(&sc->an_mtx, device_get_nameunit(sc->an_dev), MTX_NETWORK_LOCK,
MTX_DEF | MTX_RECURSE);
AN_LOCK(sc);
sc->an_gone = 0;
sc->an_associated = 0;
@ -687,15 +686,13 @@ an_attach(sc, unit, flags)
if (sc->mpi350) {
error = an_init_mpi350_desc(sc);
if (error)
return(error);
goto fail;
}
/* Load factory config */
if (an_cmd(sc, AN_CMD_READCFG, 0)) {
printf("an%d: failed to load config data\n", sc->an_unit);
AN_UNLOCK(sc);
mtx_destroy(&sc->an_mtx);
return(EIO);
goto fail;
}
/* Read the current configuration */
@ -703,9 +700,7 @@ an_attach(sc, unit, flags)
sc->an_config.an_len = sizeof(struct an_ltv_genconfig);
if (an_read_record(sc, (struct an_ltv_gen *)&sc->an_config)) {
printf("an%d: read record failed\n", sc->an_unit);
AN_UNLOCK(sc);
mtx_destroy(&sc->an_mtx);
return(EIO);
goto fail;
}
/* Read the card capabilities */
@ -713,9 +708,7 @@ an_attach(sc, unit, flags)
sc->an_caps.an_len = sizeof(struct an_ltv_caps);
if (an_read_record(sc, (struct an_ltv_gen *)&sc->an_caps)) {
printf("an%d: read record failed\n", sc->an_unit);
AN_UNLOCK(sc);
mtx_destroy(&sc->an_mtx);
return(EIO);
goto fail;
}
/* Read ssid list */
@ -723,9 +716,7 @@ an_attach(sc, unit, flags)
sc->an_ssidlist.an_len = sizeof(struct an_ltv_ssidlist);
if (an_read_record(sc, (struct an_ltv_gen *)&sc->an_ssidlist)) {
printf("an%d: read record failed\n", sc->an_unit);
AN_UNLOCK(sc);
mtx_destroy(&sc->an_mtx);
return(EIO);
goto fail;
}
/* Read AP list */
@ -733,9 +724,7 @@ an_attach(sc, unit, flags)
sc->an_aplist.an_len = sizeof(struct an_ltv_aplist);
if (an_read_record(sc, (struct an_ltv_gen *)&sc->an_aplist)) {
printf("an%d: read record failed\n", sc->an_unit);
AN_UNLOCK(sc);
mtx_destroy(&sc->an_mtx);
return(EIO);
goto fail;
}
#ifdef ANCACHE
@ -817,9 +806,11 @@ an_attach(sc, unit, flags)
*/
ether_ifattach(ifp, sc->arpcom.ac_enaddr);
callout_handle_init(&sc->an_stat_ch);
AN_UNLOCK(sc);
return(0);
fail:;
mtx_destroy(&sc->an_mtx);
return(error);
}
static void

View File

@ -115,18 +115,23 @@ an_attach_isa(dev)
an_alloc_port(dev, sc->port_rid, 1);
an_alloc_irq(dev, sc->irq_rid, 0);
sc->an_bhandle = rman_get_bushandle(sc->port_res);
sc->an_btag = rman_get_bustag(sc->port_res);
sc->an_dev = dev;
error = an_attach(sc, device_get_unit(dev), flags);
if (error) {
an_release_resources(dev);
return (error);
}
error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET,
an_intr, sc, &sc->irq_handle);
if (error) {
an_release_resources(dev);
return (error);
}
sc->an_bhandle = rman_get_bushandle(sc->port_res);
sc->an_btag = rman_get_bustag(sc->port_res);
sc->an_dev = dev;
return an_attach(sc, device_get_unit(dev), flags);
return (0);
}
static int

View File

@ -176,18 +176,26 @@ an_pccard_attach(device_t dev)
an_alloc_port(dev, sc->port_rid, AN_IOSIZ);
an_alloc_irq(dev, sc->irq_rid, 0);
error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET,
an_intr, sc, &sc->irq_handle);
if (error) {
printf("setup intr failed %d \n", error);
an_release_resources(dev);
return (error);
}
sc->an_bhandle = rman_get_bushandle(sc->port_res);
sc->an_btag = rman_get_bustag(sc->port_res);
sc->an_dev = dev;
error = an_attach(sc, device_get_unit(dev), flags);
if (error) {
goto fail;
}
/*
* Must setup the interrupt after the an_attach to prevent racing.
*/
error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET,
an_intr, sc, &sc->irq_handle);
if (error) {
goto fail;
}
fail:
if (error)
an_release_resources(dev);
return (error);
}

View File

@ -229,14 +229,17 @@ an_attach_pci(dev)
goto fail;
}
error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET,
an_intr, sc, &sc->irq_handle);
sc->an_dev = dev;
error = an_attach(sc, device_get_unit(dev), flags);
if (error) {
goto fail;
}
sc->an_dev = dev;
error = an_attach(sc, device_get_unit(dev), flags);
/*
* Must setup the interrupt after the an_attach to prevent racing.
*/
error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET,
an_intr, sc, &sc->irq_handle);
fail:
if (error)