svn commit: r212981 - user/weongyo/usb/sys/dev/usb/net
Weongyo Jeong
weongyo at FreeBSD.org
Tue Sep 21 23:08:13 UTC 2010
Author: weongyo
Date: Tue Sep 21 23:08:12 2010
New Revision: 212981
URL: http://svn.freebsd.org/changeset/base/212981
Log:
Fixes a regression that [devname]_start API could be called without
holding the device lock if it's called from ifp->if_start().
Modified:
user/weongyo/usb/sys/dev/usb/net/if_aue.c
user/weongyo/usb/sys/dev/usb/net/if_axe.c
user/weongyo/usb/sys/dev/usb/net/if_cdce.c
user/weongyo/usb/sys/dev/usb/net/if_cue.c
user/weongyo/usb/sys/dev/usb/net/if_kue.c
user/weongyo/usb/sys/dev/usb/net/if_rue.c
user/weongyo/usb/sys/dev/usb/net/if_udav.c
Modified: user/weongyo/usb/sys/dev/usb/net/if_aue.c
==============================================================================
--- user/weongyo/usb/sys/dev/usb/net/if_aue.c Tue Sep 21 22:42:14 2010 (r212980)
+++ user/weongyo/usb/sys/dev/usb/net/if_aue.c Tue Sep 21 23:08:12 2010 (r212981)
@@ -223,6 +223,7 @@ static int aue_ifmedia_upd(struct ifnet
static void aue_ifmedia_sts(struct ifnet *, struct ifmediareq *);
static int aue_ioctl(struct ifnet *, u_long, caddr_t);
static void aue_start(struct ifnet *);
+static void aue_start_locked(struct ifnet *);
static void aue_init(void *);
static void aue_setmulti(void *, int);
static void aue_setmulti_locked(struct aue_softc *);
@@ -985,7 +986,7 @@ aue_tick(struct aue_softc *sc)
&& mii->mii_media_status & IFM_ACTIVE &&
IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) {
sc->sc_flags |= AUE_FLAG_LINK;
- aue_start(sc->sc_ifp);
+ aue_start_locked(sc->sc_ifp);
}
}
@@ -994,6 +995,18 @@ aue_start(struct ifnet *ifp)
{
struct aue_softc *sc = ifp->if_softc;
+ AUE_LOCK(sc);
+ aue_start_locked(ifp);
+ AUE_UNLOCK(sc);
+}
+
+static void
+aue_start_locked(struct ifnet *ifp)
+{
+ struct aue_softc *sc = ifp->if_softc;
+
+ AUE_LOCK_ASSERT(sc, MA_OWNED);
+
/*
* start the USB transfers, if not already started:
*/
@@ -1044,7 +1057,7 @@ aue_init_locked(struct aue_softc *sc)
ifp->if_drv_flags |= IFF_DRV_RUNNING;
sleepout_reset(&sc->sc_watchdog, hz, aue_watchdog, sc);
- aue_start(sc->sc_ifp);
+ aue_start_locked(sc->sc_ifp);
}
static void
Modified: user/weongyo/usb/sys/dev/usb/net/if_axe.c
==============================================================================
--- user/weongyo/usb/sys/dev/usb/net/if_axe.c Tue Sep 21 22:42:14 2010 (r212980)
+++ user/weongyo/usb/sys/dev/usb/net/if_axe.c Tue Sep 21 23:08:12 2010 (r212981)
@@ -202,6 +202,7 @@ static void axe_init(void *);
static void axe_init_locked(struct axe_softc *);
static int axe_ioctl(struct ifnet *, u_long, caddr_t);
static void axe_start(struct ifnet *);
+static void axe_start_locked(struct ifnet *);
static void axe_tick(struct axe_softc *);
static void axe_stop(struct axe_softc *);
static void axe_setmulti_locked(struct axe_softc *);
@@ -1140,7 +1141,7 @@ axe_tick(struct axe_softc *sc)
if ((sc->sc_flags & AXE_FLAG_LINK) == 0) {
axe_miibus_statchg(sc->sc_dev);
if ((sc->sc_flags & AXE_FLAG_LINK) != 0)
- axe_start(sc->sc_ifp);
+ axe_start_locked(sc->sc_ifp);
}
}
@@ -1149,6 +1150,18 @@ axe_start(struct ifnet *ifp)
{
struct axe_softc *sc = ifp->if_softc;
+ AXE_LOCK(sc);
+ axe_start_locked(ifp);
+ AXE_UNLOCK(sc);
+}
+
+static void
+axe_start_locked(struct ifnet *ifp)
+{
+ struct axe_softc *sc = ifp->if_softc;
+
+ AXE_LOCK_ASSERT(sc, MA_OWNED);
+
/*
* start the USB transfers, if not already started:
*/
@@ -1226,7 +1239,7 @@ axe_init_locked(struct axe_softc *sc)
ifp->if_drv_flags |= IFF_DRV_RUNNING;
sleepout_reset(&sc->sc_watchdog, hz, axe_watchdog, sc);
- axe_start(sc->sc_ifp);
+ axe_start_locked(sc->sc_ifp);
}
static void
Modified: user/weongyo/usb/sys/dev/usb/net/if_cdce.c
==============================================================================
--- user/weongyo/usb/sys/dev/usb/net/if_cdce.c Tue Sep 21 22:42:14 2010 (r212980)
+++ user/weongyo/usb/sys/dev/usb/net/if_cdce.c Tue Sep 21 23:08:12 2010 (r212981)
@@ -108,6 +108,7 @@ static usb_callback_t cdce_ncm_bulk_read
static uint32_t cdce_m_crc32(struct mbuf *, uint32_t, uint32_t);
static int cdce_ioctl(struct ifnet *, u_long, caddr_t);
static void cdce_start(struct ifnet *);
+static void cdce_start_locked(struct ifnet *);
static void cdce_init(void *);
static void cdce_init_locked(struct cdce_softc *);
static int cdce_rxmbuf(struct cdce_softc *, struct mbuf *, unsigned int);
@@ -633,6 +634,18 @@ cdce_start(struct ifnet *ifp)
{
struct cdce_softc *sc = ifp->if_softc;
+ CDCE_LOCK(sc);
+ cdce_start_locked(ifp);
+ CDCE_UNLOCK(sc);
+}
+
+static void
+cdce_start_locked(struct ifnet *ifp)
+{
+ struct cdce_softc *sc = ifp->if_softc;
+
+ CDCE_LOCK_ASSERT(sc, MA_OWNED);
+
/*
* Start the USB transfers, if not already started:
*/
@@ -795,7 +808,7 @@ cdce_init_locked(struct cdce_softc *sc)
usbd_xfer_set_stall(sc->sc_xfer[CDCE_BULK_TX]);
/* start data transfers */
- cdce_start(sc->sc_ifp);
+ cdce_start_locked(sc->sc_ifp);
}
static void
Modified: user/weongyo/usb/sys/dev/usb/net/if_cue.c
==============================================================================
--- user/weongyo/usb/sys/dev/usb/net/if_cue.c Tue Sep 21 22:42:14 2010 (r212980)
+++ user/weongyo/usb/sys/dev/usb/net/if_cue.c Tue Sep 21 23:08:12 2010 (r212981)
@@ -127,6 +127,7 @@ static void cue_init(void *);
static void cue_init_locked(struct cue_softc *);
static int cue_ioctl(struct ifnet *, u_long, caddr_t);
static void cue_start(struct ifnet *);
+static void cue_start_locked(struct ifnet *);
static int cue_rxbuf(struct cue_softc *, struct usb_page_cache *,
unsigned int, unsigned int);
static void cue_rxflush(struct cue_softc *);
@@ -599,6 +600,18 @@ cue_start(struct ifnet *ifp)
{
struct cue_softc *sc = ifp->if_softc;
+ CUE_LOCK(sc);
+ cue_start_locked(ifp);
+ CUE_UNLOCK(sc);
+}
+
+static void
+cue_start_locked(struct ifnet *ifp)
+{
+ struct cue_softc *sc = ifp->if_softc;
+
+ CUE_LOCK_ASSERT(sc, MA_OWNED);
+
/*
* start the USB transfers, if not already started:
*/
@@ -659,7 +672,7 @@ cue_init_locked(struct cue_softc *sc)
ifp->if_drv_flags |= IFF_DRV_RUNNING;
sleepout_reset(&sc->sc_watchdog, hz, cue_watchdog, sc);
- cue_start(sc->sc_ifp);
+ cue_start_locked(sc->sc_ifp);
}
/*
Modified: user/weongyo/usb/sys/dev/usb/net/if_kue.c
==============================================================================
--- user/weongyo/usb/sys/dev/usb/net/if_kue.c Tue Sep 21 22:42:14 2010 (r212980)
+++ user/weongyo/usb/sys/dev/usb/net/if_kue.c Tue Sep 21 23:08:12 2010 (r212981)
@@ -168,6 +168,7 @@ static void kue_init(void *);
static void kue_init_locked(struct kue_softc *);
static int kue_ioctl(struct ifnet *, u_long, caddr_t);
static void kue_start(struct ifnet *);
+static void kue_start_locked(struct ifnet *);
#ifdef USB_DEBUG
static int kue_debug = 0;
@@ -734,6 +735,18 @@ kue_start(struct ifnet *ifp)
{
struct kue_softc *sc = ifp->if_softc;
+ KUE_LOCK(sc);
+ kue_start_locked(ifp);
+ KUE_UNLOCK(sc);
+}
+
+static void
+kue_start_locked(struct ifnet *ifp)
+{
+ struct kue_softc *sc = ifp->if_softc;
+
+ KUE_LOCK_ASSERT(sc, MA_OWNED);
+
/*
* start the USB transfers, if not already started:
*/
@@ -778,7 +791,7 @@ kue_init_locked(struct kue_softc *sc)
usbd_xfer_set_stall(sc->sc_xfer[KUE_BULK_DT_WR]);
ifp->if_drv_flags |= IFF_DRV_RUNNING;
- kue_start(sc->sc_ifp);
+ kue_start_locked(sc->sc_ifp);
}
static void
Modified: user/weongyo/usb/sys/dev/usb/net/if_rue.c
==============================================================================
--- user/weongyo/usb/sys/dev/usb/net/if_rue.c Tue Sep 21 22:42:14 2010 (r212980)
+++ user/weongyo/usb/sys/dev/usb/net/if_rue.c Tue Sep 21 23:08:12 2010 (r212981)
@@ -157,6 +157,7 @@ static void rue_init(void *);
static void rue_init_locked(struct rue_softc *);
static int rue_ioctl(struct ifnet *, u_long, caddr_t);
static void rue_start(struct ifnet *);
+static void rue_start_locked(struct ifnet *);
static void rue_stop(struct rue_softc *);
static void rue_watchdog(void *);
@@ -901,7 +902,7 @@ rue_tick(struct rue_softc *sc)
&& mii->mii_media_status & IFM_ACTIVE &&
IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) {
sc->sc_flags |= RUE_FLAG_LINK;
- rue_start(sc->sc_ifp);
+ rue_start_locked(sc->sc_ifp);
}
}
@@ -910,6 +911,18 @@ rue_start(struct ifnet *ifp)
{
struct rue_softc *sc = ifp->if_softc;
+ RUE_LOCK(sc);
+ rue_start_locked(ifp);
+ RUE_UNLOCK(sc);
+}
+
+static void
+rue_start_locked(struct ifnet *ifp)
+{
+ struct rue_softc *sc = ifp->if_softc;
+
+ RUE_LOCK_ASSERT(sc, MA_OWNED);
+
/*
* start the USB transfers, if not already started:
*/
@@ -963,7 +976,7 @@ rue_init_locked(struct rue_softc *sc)
ifp->if_drv_flags |= IFF_DRV_RUNNING;
sleepout_reset(&sc->sc_watchdog, hz, rue_watchdog, sc);
- rue_start(sc->sc_ifp);
+ rue_start_locked(sc->sc_ifp);
}
/*
Modified: user/weongyo/usb/sys/dev/usb/net/if_udav.c
==============================================================================
--- user/weongyo/usb/sys/dev/usb/net/if_udav.c Tue Sep 21 22:42:14 2010 (r212980)
+++ user/weongyo/usb/sys/dev/usb/net/if_udav.c Tue Sep 21 23:08:12 2010 (r212981)
@@ -113,6 +113,7 @@ static void udav_init(void *);
static void udav_init_locked(struct udav_softc *);
static int udav_ioctl(struct ifnet *, u_long, caddr_t);
static void udav_start(struct ifnet *);
+static void udav_start_locked(struct ifnet *);
static void udav_setmulti(void *, int);
static void udav_stop(struct udav_softc *);
static void udav_setpromisc(struct udav_softc *);
@@ -481,7 +482,7 @@ udav_init_locked(struct udav_softc *sc)
ifp->if_drv_flags |= IFF_DRV_RUNNING;
sleepout_reset(&sc->sc_watchdog, hz, udav_watchdog, sc);
- udav_start(sc->sc_ifp);
+ udav_start_locked(sc->sc_ifp);
}
static void
@@ -578,6 +579,18 @@ udav_start(struct ifnet *ifp)
{
struct udav_softc *sc = ifp->if_softc;
+ UDAV_LOCK(sc);
+ udav_start_locked(ifp);
+ UDAV_UNLOCK(sc);
+}
+
+static void
+udav_start_locked(struct ifnet *ifp)
+{
+ struct udav_softc *sc = ifp->if_softc;
+
+ UDAV_LOCK_ASSERT(sc, MA_OWNED);
+
/*
* start the USB transfers, if not already started:
*/
@@ -873,7 +886,7 @@ udav_tick(struct udav_softc *sc)
&& mii->mii_media_status & IFM_ACTIVE &&
IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) {
sc->sc_flags |= UDAV_FLAG_LINK;
- udav_start(sc->sc_ifp);
+ udav_start_locked(sc->sc_ifp);
}
}
More information about the svn-src-user
mailing list