diff options
author | wpaul <wpaul@FreeBSD.org> | 2000-10-13 18:35:49 +0000 |
---|---|---|
committer | wpaul <wpaul@FreeBSD.org> | 2000-10-13 18:35:49 +0000 |
commit | 8e0abe4cc479954f239d4623eb511af27738df8c (patch) | |
tree | fff6a7e2bdedaad22a27ef128d69bb1169c24bfb /sys | |
parent | 9ddccb55057ef3b64d80b6d90cb2b25b56238ba3 (diff) | |
download | FreeBSD-src-8e0abe4cc479954f239d4623eb511af27738df8c.zip FreeBSD-src-8e0abe4cc479954f239d4623eb511af27738df8c.tar.gz |
Use device_get_nameunit(dev) as the mutex string when calling
mtx_init() instead of hard-coded string constant. Also remember to do
the mutex changes to the ste driver, which I forgot in the first commit.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/dc/if_dc.c | 2 | ||||
-rw-r--r-- | sys/dev/sf/if_sf.c | 2 | ||||
-rw-r--r-- | sys/dev/sk/if_sk.c | 2 | ||||
-rw-r--r-- | sys/dev/ti/if_ti.c | 2 | ||||
-rw-r--r-- | sys/dev/vr/if_vr.c | 2 | ||||
-rw-r--r-- | sys/pci/if_dc.c | 2 | ||||
-rw-r--r-- | sys/pci/if_pcn.c | 5 | ||||
-rw-r--r-- | sys/pci/if_rl.c | 2 | ||||
-rw-r--r-- | sys/pci/if_sf.c | 2 | ||||
-rw-r--r-- | sys/pci/if_sis.c | 2 | ||||
-rw-r--r-- | sys/pci/if_sk.c | 2 | ||||
-rw-r--r-- | sys/pci/if_ste.c | 80 | ||||
-rw-r--r-- | sys/pci/if_stereg.h | 4 | ||||
-rw-r--r-- | sys/pci/if_ti.c | 2 | ||||
-rw-r--r-- | sys/pci/if_tl.c | 2 | ||||
-rw-r--r-- | sys/pci/if_vr.c | 2 | ||||
-rw-r--r-- | sys/pci/if_wb.c | 2 | ||||
-rw-r--r-- | sys/pci/if_xl.c | 2 |
18 files changed, 70 insertions, 49 deletions
diff --git a/sys/dev/dc/if_dc.c b/sys/dev/dc/if_dc.c index f7c97a1..38475ab 100644 --- a/sys/dev/dc/if_dc.c +++ b/sys/dev/dc/if_dc.c @@ -1699,7 +1699,7 @@ static int dc_attach(dev) goto fail; } - mtx_init(&sc->dc_mtx, "dc", MTX_DEF); + mtx_init(&sc->dc_mtx, device_get_nameunit(dev), MTX_DEF); DC_LOCK(sc); /* Need this info to decide on a chip type. */ sc->dc_info = dc_devtype(dev); diff --git a/sys/dev/sf/if_sf.c b/sys/dev/sf/if_sf.c index a7d14522..eac7980 100644 --- a/sys/dev/sf/if_sf.c +++ b/sys/dev/sf/if_sf.c @@ -766,7 +766,7 @@ static int sf_attach(dev) } callout_handle_init(&sc->sf_stat_ch); - mtx_init(&sc->sf_mtx, "sf", MTX_DEF); + mtx_init(&sc->sf_mtx, device_get_nameunit(dev), MTX_DEF); SF_LOCK(sc); /* Reset the adapter. */ sf_reset(sc); diff --git a/sys/dev/sk/if_sk.c b/sys/dev/sk/if_sk.c index 963f754..b1f0bfd 100644 --- a/sys/dev/sk/if_sk.c +++ b/sys/dev/sk/if_sk.c @@ -1277,7 +1277,7 @@ static int sk_attach(dev) goto fail; } - mtx_init(&sc->sk_mtx, "skc", MTX_DEF); + mtx_init(&sc->sk_mtx, device_get_nameunit(dev), MTX_DEF); SK_LOCK(sc); /* Reset the adapter. */ sk_reset(sc); diff --git a/sys/dev/ti/if_ti.c b/sys/dev/ti/if_ti.c index 04ec29d..1afd6ed 100644 --- a/sys/dev/ti/if_ti.c +++ b/sys/dev/ti/if_ti.c @@ -1537,7 +1537,7 @@ static int ti_attach(dev) goto fail; } - mtx_init(&sc->ti_mtx, "ti", MTX_DEF); + mtx_init(&sc->ti_mtx, device_get_nameunit(dev), MTX_DEF); TI_LOCK(sc); sc->ti_unit = unit; diff --git a/sys/dev/vr/if_vr.c b/sys/dev/vr/if_vr.c index 10b9942..7430a8c 100644 --- a/sys/dev/vr/if_vr.c +++ b/sys/dev/vr/if_vr.c @@ -729,7 +729,7 @@ static int vr_attach(dev) goto fail; } - mtx_init(&sc->vr_mtx, "vr", MTX_DEF); + mtx_init(&sc->vr_mtx, device_get_nameunit(dev), MTX_DEF); VR_LOCK(sc); /* Reset the adapter. */ vr_reset(sc); diff --git a/sys/pci/if_dc.c b/sys/pci/if_dc.c index f7c97a1..38475ab 100644 --- a/sys/pci/if_dc.c +++ b/sys/pci/if_dc.c @@ -1699,7 +1699,7 @@ static int dc_attach(dev) goto fail; } - mtx_init(&sc->dc_mtx, "dc", MTX_DEF); + mtx_init(&sc->dc_mtx, device_get_nameunit(dev), MTX_DEF); DC_LOCK(sc); /* Need this info to decide on a chip type. */ sc->dc_info = dc_devtype(dev); diff --git a/sys/pci/if_pcn.c b/sys/pci/if_pcn.c index 9accefb..c9952f3 100644 --- a/sys/pci/if_pcn.c +++ b/sys/pci/if_pcn.c @@ -398,7 +398,8 @@ static int pcn_probe(dev) } sc->pcn_btag = rman_get_bustag(sc->pcn_res); sc->pcn_bhandle = rman_get_bushandle(sc->pcn_res); - mtx_init(&sc->pcn_mtx, "pcn", MTX_DEF); + mtx_init(&sc->pcn_mtx, + device_get_nameunit(dev), MTX_DEF); PCN_LOCK(sc); pcn_reset(sc); chip_id = pcn_csr_read(sc, PCN_CSR_CHIPID1); @@ -534,7 +535,7 @@ static int pcn_attach(dev) } /* Initialize our mutex. */ - mtx_init(&sc->pcn_mtx, "pcn", MTX_DEF); + mtx_init(&sc->pcn_mtx, device_get_nameunit(dev), MTX_DEF); PCN_LOCK(sc); /* Reset the adapter. */ diff --git a/sys/pci/if_rl.c b/sys/pci/if_rl.c index 010f612..fd9a75f 100644 --- a/sys/pci/if_rl.c +++ b/sys/pci/if_rl.c @@ -887,7 +887,7 @@ static int rl_attach(dev) callout_handle_init(&sc->rl_stat_ch); - mtx_init(&sc->rl_mtx, "rl", MTX_DEF); + mtx_init(&sc->rl_mtx, device_get_nameunit(dev), MTX_DEF); RL_LOCK(sc); /* Reset the adapter. */ diff --git a/sys/pci/if_sf.c b/sys/pci/if_sf.c index a7d14522..eac7980 100644 --- a/sys/pci/if_sf.c +++ b/sys/pci/if_sf.c @@ -766,7 +766,7 @@ static int sf_attach(dev) } callout_handle_init(&sc->sf_stat_ch); - mtx_init(&sc->sf_mtx, "sf", MTX_DEF); + mtx_init(&sc->sf_mtx, device_get_nameunit(dev), MTX_DEF); SF_LOCK(sc); /* Reset the adapter. */ sf_reset(sc); diff --git a/sys/pci/if_sis.c b/sys/pci/if_sis.c index cca772c..4602e58 100644 --- a/sys/pci/if_sis.c +++ b/sys/pci/if_sis.c @@ -732,7 +732,7 @@ static int sis_attach(dev) goto fail; } - mtx_init(&sc->sis_mtx, "sis", MTX_DEF); + mtx_init(&sc->sis_mtx, device_get_nameunit(dev), MTX_DEF); SIS_LOCK(sc); /* Reset the adapter. */ diff --git a/sys/pci/if_sk.c b/sys/pci/if_sk.c index 963f754..b1f0bfd 100644 --- a/sys/pci/if_sk.c +++ b/sys/pci/if_sk.c @@ -1277,7 +1277,7 @@ static int sk_attach(dev) goto fail; } - mtx_init(&sc->sk_mtx, "skc", MTX_DEF); + mtx_init(&sc->sk_mtx, device_get_nameunit(dev), MTX_DEF); SK_LOCK(sc); /* Reset the adapter. */ sk_reset(sc); diff --git a/sys/pci/if_ste.c b/sys/pci/if_ste.c index 18d355c..77895f8 100644 --- a/sys/pci/if_ste.c +++ b/sys/pci/if_ste.c @@ -242,9 +242,9 @@ static int ste_mii_readreg(sc, frame) struct ste_mii_frame *frame; { - int i, ack, s; + int i, ack; - s = splimp(); + STE_LOCK(sc); /* * Set up frame for RX. @@ -319,7 +319,7 @@ fail: MII_SET(STE_PHYCTL_MCLK); DELAY(1); - splx(s); + STE_UNLOCK(sc); if (ack) return(1); @@ -334,9 +334,8 @@ static int ste_mii_writereg(sc, frame) struct ste_mii_frame *frame; { - int s; + STE_LOCK(sc); - s = splimp(); /* * Set up frame for TX. */ @@ -370,7 +369,7 @@ static int ste_mii_writereg(sc, frame) */ MII_CLR(STE_PHYCTL_MDIR); - splx(s); + STE_UNLOCK(sc); return(0); } @@ -419,6 +418,7 @@ static void ste_miibus_statchg(dev) struct mii_data *mii; sc = device_get_softc(dev); + STE_LOCK(sc); mii = device_get_softc(sc->ste_miibus); if ((mii->mii_media_active & IFM_GMASK) == IFM_FDX) { @@ -426,6 +426,7 @@ static void ste_miibus_statchg(dev) } else { STE_CLRBIT2(sc, STE_MACCTL0, STE_MACCTL0_FULLDUPLEX); } + STE_UNLOCK(sc); return; } @@ -615,11 +616,14 @@ static void ste_intr(xsc) u_int16_t status; sc = xsc; + STE_LOCK(sc); ifp = &sc->arpcom.ac_if; /* See if this is really our interrupt. */ - if (!(CSR_READ_2(sc, STE_ISR) & STE_ISR_INTLATCH)) + if (!(CSR_READ_2(sc, STE_ISR) & STE_ISR_INTLATCH)) { + STE_UNLOCK(sc); return; + } for (;;) { status = CSR_READ_2(sc, STE_ISR_ACK); @@ -653,6 +657,8 @@ static void ste_intr(xsc) if (ifp->if_snd.ifq_head != NULL) ste_start(ifp); + STE_UNLOCK(sc); + return; } @@ -837,12 +843,12 @@ static void ste_stats_update(xsc) struct ste_stats stats; struct ifnet *ifp; struct mii_data *mii; - int i, s; + int i; u_int8_t *p; - s = splimp(); - sc = xsc; + STE_LOCK(sc); + ifp = &sc->arpcom.ac_if; mii = device_get_softc(sc->ste_miibus); @@ -867,7 +873,7 @@ static void ste_stats_update(xsc) } sc->ste_stat_ch = timeout(ste_stats_update, sc, hz); - splx(s); + STE_UNLOCK(sc); return; } @@ -903,14 +909,11 @@ static int ste_probe(dev) static int ste_attach(dev) device_t dev; { - int s; u_int32_t command; struct ste_softc *sc; struct ifnet *ifp; int unit, error = 0, rid; - s = splimp(); - sc = device_get_softc(dev); unit = device_get_unit(dev); bzero(sc, sizeof(struct ste_softc)); @@ -1000,6 +1003,8 @@ static int ste_attach(dev) } callout_handle_init(&sc->ste_stat_ch); + mtx_init(&sc->ste_mtx, device_get_nameunit(dev), MTX_DEF); + STE_LOCK(sc); /* Reset the adapter. */ ste_reset(sc); @@ -1071,9 +1076,12 @@ static int ste_attach(dev) * Call MI attach routine. */ ether_ifattach(ifp, ETHER_BPF_SUPPORTED); + STE_UNLOCK(sc); + return(0); fail: - splx(s); + STE_UNLOCK(sc); + mtx_destroy(&sc->ste_mtx); return(error); } @@ -1082,11 +1090,9 @@ static int ste_detach(dev) { struct ste_softc *sc; struct ifnet *ifp; - int s; - - s = splimp(); sc = device_get_softc(dev); + STE_LOCK(sc); ifp = &sc->arpcom.ac_if; ste_stop(sc); @@ -1101,7 +1107,8 @@ static int ste_detach(dev) contigfree(sc->ste_ldata, sizeof(struct ste_list_data), M_DEVBUF); - splx(s); + STE_UNLOCK(sc); + mtx_destroy(&sc->ste_mtx); return(0); } @@ -1218,13 +1225,12 @@ static void ste_init(xsc) void *xsc; { struct ste_softc *sc; - int i, s; + int i; struct ifnet *ifp; struct mii_data *mii; - s = splimp(); - sc = xsc; + STE_LOCK(sc); ifp = &sc->arpcom.ac_if; mii = device_get_softc(sc->ste_miibus); @@ -1240,7 +1246,7 @@ static void ste_init(xsc) printf("ste%d: initialization failed: no " "memory for RX buffers\n", sc->ste_unit); ste_stop(sc); - splx(s); + STE_UNLOCK(sc); return; } @@ -1312,9 +1318,8 @@ static void ste_init(xsc) ifp->if_flags |= IFF_RUNNING; ifp->if_flags &= ~IFF_OACTIVE; - splx(s); - sc->ste_stat_ch = timeout(ste_stats_update, sc, hz); + STE_UNLOCK(sc); return; } @@ -1325,6 +1330,7 @@ static void ste_stop(sc) int i; struct ifnet *ifp; + STE_LOCK(sc); ifp = &sc->arpcom.ac_if; untimeout(ste_stats_update, sc, sc->ste_stat_ch); @@ -1354,6 +1360,7 @@ static void ste_stop(sc) } ifp->if_flags &= ~(IFF_RUNNING|IFF_OACTIVE); + STE_UNLOCK(sc); return; } @@ -1391,11 +1398,10 @@ static int ste_ioctl(ifp, command, data) struct ste_softc *sc; struct ifreq *ifr; struct mii_data *mii; - int error = 0, s; - - s = splimp(); + int error = 0; sc = ifp->if_softc; + STE_LOCK(sc); ifr = (struct ifreq *)data; switch(command) { @@ -1442,7 +1448,7 @@ static int ste_ioctl(ifp, command, data) break; } - splx(s); + STE_UNLOCK(sc); return(error); } @@ -1490,12 +1496,17 @@ static void ste_start(ifp) int idx; sc = ifp->if_softc; + STE_LOCK(sc); - if (!sc->ste_link) + if (!sc->ste_link) { + STE_UNLOCK(sc); return; + } - if (ifp->if_flags & IFF_OACTIVE) + if (ifp->if_flags & IFF_OACTIVE) { + STE_UNLOCK(sc); return; + } idx = sc->ste_cdata.ste_tx_prod; start_tx = &sc->ste_cdata.ste_tx_chain[idx]; @@ -1530,8 +1541,10 @@ static void ste_start(ifp) sc->ste_cdata.ste_tx_cnt++; } - if (cur_tx == NULL) + if (cur_tx == NULL) { + STE_UNLOCK(sc); return; + } cur_tx->ste_ptr->ste_ctl |= STE_TXCTL_DMAINTR; @@ -1540,6 +1553,7 @@ static void ste_start(ifp) start_tx->ste_prev->ste_ptr->ste_next = start_tx->ste_phys; ifp->if_timer = 5; + STE_UNLOCK(sc); return; } @@ -1550,6 +1564,7 @@ static void ste_watchdog(ifp) struct ste_softc *sc; sc = ifp->if_softc; + STE_LOCK(sc); ifp->if_oerrors++; printf("ste%d: watchdog timeout\n", sc->ste_unit); @@ -1562,6 +1577,7 @@ static void ste_watchdog(ifp) if (ifp->if_snd.ifq_head != NULL) ste_start(ifp); + STE_UNLOCK(sc); return; } diff --git a/sys/pci/if_stereg.h b/sys/pci/if_stereg.h index 7a0b487..7a5ad7a 100644 --- a/sys/pci/if_stereg.h +++ b/sys/pci/if_stereg.h @@ -514,8 +514,12 @@ struct ste_softc { struct ste_list_data *ste_ldata; struct ste_chain_data ste_cdata; struct callout_handle ste_stat_ch; + struct mtx ste_mtx; }; +#define STE_LOCK(_sc) mtx_enter(&(_sc)->ste_mtx, MTX_DEF) +#define STE_UNLOCK(_sc) mtx_exit(&(_sc)->ste_mtx, MTX_DEF) + struct ste_mii_frame { u_int8_t mii_stdelim; u_int8_t mii_opcode; diff --git a/sys/pci/if_ti.c b/sys/pci/if_ti.c index 04ec29d..1afd6ed 100644 --- a/sys/pci/if_ti.c +++ b/sys/pci/if_ti.c @@ -1537,7 +1537,7 @@ static int ti_attach(dev) goto fail; } - mtx_init(&sc->ti_mtx, "ti", MTX_DEF); + mtx_init(&sc->ti_mtx, device_get_nameunit(dev), MTX_DEF); TI_LOCK(sc); sc->ti_unit = unit; diff --git a/sys/pci/if_tl.c b/sys/pci/if_tl.c index 0d5a286..06504c3 100644 --- a/sys/pci/if_tl.c +++ b/sys/pci/if_tl.c @@ -1245,7 +1245,7 @@ static int tl_attach(dev) if (t->tl_vid == OLICOM_VENDORID) sc->tl_eeaddr = TL_EEPROM_EADDR_OC; - mtx_init(&sc->tl_mtx, "tl", MTX_DEF); + mtx_init(&sc->tl_mtx, device_get_nameunit(dev), MTX_DEF); TL_LOCK(sc); /* Reset the adapter. */ diff --git a/sys/pci/if_vr.c b/sys/pci/if_vr.c index 10b9942..7430a8c 100644 --- a/sys/pci/if_vr.c +++ b/sys/pci/if_vr.c @@ -729,7 +729,7 @@ static int vr_attach(dev) goto fail; } - mtx_init(&sc->vr_mtx, "vr", MTX_DEF); + mtx_init(&sc->vr_mtx, device_get_nameunit(dev), MTX_DEF); VR_LOCK(sc); /* Reset the adapter. */ vr_reset(sc); diff --git a/sys/pci/if_wb.c b/sys/pci/if_wb.c index 55316e3..8fe210c 100644 --- a/sys/pci/if_wb.c +++ b/sys/pci/if_wb.c @@ -907,7 +907,7 @@ static int wb_attach(dev) /* Save the cache line size. */ sc->wb_cachesize = pci_read_config(dev, WB_PCI_CACHELEN, 4) & 0xFF; - mtx_init(&sc->wb_mtx, "wb", MTX_DEF); + mtx_init(&sc->wb_mtx, device_get_nameunit(dev), MTX_DEF); WB_LOCK(sc); /* Reset the adapter. */ diff --git a/sys/pci/if_xl.c b/sys/pci/if_xl.c index 7e1f64b..94ba480 100644 --- a/sys/pci/if_xl.c +++ b/sys/pci/if_xl.c @@ -1348,7 +1348,7 @@ static int xl_attach(dev) goto fail; } - mtx_init(&sc->xl_mtx, "xl", MTX_DEF); + mtx_init(&sc->xl_mtx, device_get_nameunit(dev), MTX_DEF); XL_LOCK(sc); /* Reset the adapter. */ |