Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F160220941
D56138.id179319.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D56138.id179319.diff
View Options
diff --git a/sys/dev/usb/net/if_ure.c b/sys/dev/usb/net/if_ure.c
--- a/sys/dev/usb/net/if_ure.c
+++ b/sys/dev/usb/net/if_ure.c
@@ -34,6 +34,7 @@
#include <sys/lock.h>
#include <sys/module.h>
#include <sys/mutex.h>
+#include <sys/sx.h>
#include <sys/sbuf.h>
#include <sys/socket.h>
#include <sys/sysctl.h>
@@ -591,6 +592,7 @@
sc->sc_flags = USB_GET_DRIVER_INFO(uaa);
device_set_usb_desc(dev);
mtx_init(&sc->sc_mtx, device_get_nameunit(dev), NULL, MTX_DEF);
+ sx_init(&sc->sc_mii_lock, "uremii");
iface_index = URE_IFACE_IDX;
@@ -665,6 +667,7 @@
usbd_transfer_unsetup(sc->sc_tx_xfer, URE_MAX_TX);
usbd_transfer_unsetup(sc->sc_rx_xfer, URE_MAX_RX);
uether_ifdetach(ue);
+ sx_destroy(&sc->sc_mii_lock);
mtx_destroy(&sc->sc_mtx);
return (0);
@@ -1242,6 +1245,13 @@
if (sc->sc_flags & (URE_FLAG_8156 | URE_FLAG_8156B)) {
ure_link_state(sc);
} else {
+ URE_UNLOCK(sc);
+ if (!URE_MII_TRYLOCK(sc)) {
+ URE_LOCK(sc);
+ return;
+ }
+ URE_LOCK(sc);
+
mii = GET_MII(sc);
mii_tick(mii);
if ((sc->sc_flags & URE_FLAG_LINK) == 0
@@ -1251,6 +1261,10 @@
sc->sc_rxstarted = 0;
ure_start(ue);
}
+
+ URE_UNLOCK(sc);
+ URE_MII_UNLOCK(sc);
+ URE_LOCK(sc);
}
}
@@ -1417,9 +1431,18 @@
mii = GET_MII(sc);
URE_LOCK_ASSERT(sc, MA_OWNED);
+
+ URE_UNLOCK(sc);
+ URE_MII_LOCK(sc);
+ URE_LOCK(sc);
+
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
PHY_RESET(miisc);
error = mii_mediachg(mii);
+
+ URE_UNLOCK(sc);
+ URE_MII_UNLOCK(sc);
+ URE_LOCK(sc);
return (error);
}
@@ -1461,11 +1484,13 @@
mii = GET_MII(sc);
+ URE_MII_LOCK(sc);
URE_LOCK(sc);
mii_pollstat(mii);
ifmr->ifm_active = mii->mii_media_active;
ifmr->ifm_status = mii->mii_media_status;
URE_UNLOCK(sc);
+ URE_MII_UNLOCK(sc);
}
static void
diff --git a/sys/dev/usb/net/if_urereg.h b/sys/dev/usb/net/if_urereg.h
--- a/sys/dev/usb/net/if_urereg.h
+++ b/sys/dev/usb/net/if_urereg.h
@@ -581,6 +581,7 @@
struct usb_ether sc_ue;
struct ifmedia sc_ifmedia;
struct mtx sc_mtx;
+ struct sx sc_mii_lock;
struct usb_xfer *sc_rx_xfer[URE_MAX_RX];
struct usb_xfer *sc_tx_xfer[URE_MAX_TX];
@@ -616,5 +617,8 @@
#define URE_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx)
#define URE_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx)
#define URE_LOCK_ASSERT(_sc, t) mtx_assert(&(_sc)->sc_mtx, t)
+#define URE_MII_LOCK(_sc) sx_xlock(&(_sc)->sc_mii_lock)
+#define URE_MII_UNLOCK(_sc) sx_xunlock(&(_sc)->sc_mii_lock)
+#define URE_MII_TRYLOCK(_sc) sx_try_xlock(&(_sc)->sc_mii_lock)
#endif /* _IF_UREREG_H_ */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Jun 23, 7:48 AM (14 h, 49 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
34236003
Default Alt Text
D56138.id179319.diff (2 KB)
Attached To
Mode
D56138: ure: lock MII bus operations
Attached
Detach File
Event Timeline
Log In to Comment