PERFORCE change 221567 for review
Bjoern A. Zeeb
bz at FreeBSD.org
Mon Jan 28 14:08:17 UTC 2013
http://p4web.freebsd.org/@@221567?ac=10
Change 221567 by bz at bz_zenith on 2013/01/28 14:07:29
Make sure we hold the lock for callout_stop() even in early
error cases. This fixes panics previously seen if there is a
MAC+PHY configured in hints but not present:
panic: mutex atse<n> not owned at /sys/kern/kern_mutex.c:153
Reported also by: brooks, rwatson (presumably on old bitfiles)
Affected files ...
.. //depot/projects/ctsrd/beribsd/src/sys/dev/altera/atse/if_atse.c#2 edit
Differences ...
==== //depot/projects/ctsrd/beribsd/src/sys/dev/altera/atse/if_atse.c#2 (text+ko) ====
@@ -37,6 +37,8 @@
*/
/*
* XXX-BZ NOTES:
+ * - brooks, rwatson report:
+ * - buffered packet data as SOP arrives
* - ifOutBroadcastPkts are only counted if both ether dst and src are all-1s;
* seems an IP core bug, they count ether broadcasts as multicast. Is this
* still the case?
@@ -47,8 +49,6 @@
* hints anymore.
* - read ethernet address depending on device unit until loader will do all
* magic for us.
- * - there is a case when atse_attach fails, that atse_detach is triggering
- * a mtx locked assertion.
* - resolve all XXX, left as reminders to shake out details later
*/
@@ -554,18 +554,6 @@
return (0);
}
-static int
-atse_stop(struct atse_softc *sc)
-{
- int error;
-
- ATSE_LOCK(sc);
- error = atse_stop_locked(sc);
- ATSE_UNLOCK(sc);
-
- return (error);
-}
-
static uint8_t
atse_mchash(struct atse_softc *sc __unused, const uint8_t *addr)
{
@@ -1590,11 +1578,12 @@
if (ifp->if_capenable & IFCAP_POLLING)
ether_poll_deregister(ifp);
#endif
- callout_stop(&sc->atse_tick);
/* Only cleanup if attach succeeded. */
if (device_is_attached(dev)) {
- atse_stop(sc);
+ ATSE_LOCK(sc);
+ atse_stop_locked(sc);
+ ATSE_UNLOCK(sc);
callout_drain(&sc->atse_tick);
ether_ifdetach(ifp);
}
@@ -1700,27 +1689,41 @@
sc = device_get_softc(dev);
- if (sc->atse_txc_mem_res != NULL)
+ if (sc->atse_txc_mem_res != NULL) {
bus_release_resource(dev, SYS_RES_MEMORY, sc->atse_txc_mem_rid,
sc->atse_txc_mem_res);
- if (sc->atse_tx_mem_res != NULL)
+ sc->atse_txc_mem_res = NULL;
+ }
+ if (sc->atse_tx_mem_res != NULL) {
bus_release_resource(dev, SYS_RES_MEMORY, sc->atse_tx_mem_rid,
sc->atse_tx_mem_res);
- if (sc->atse_tx_irq_res != NULL)
+ sc->atse_tx_mem_res = NULL;
+ }
+ if (sc->atse_tx_irq_res != NULL) {
bus_release_resource(dev, SYS_RES_IRQ, sc->atse_tx_irq_rid,
sc->atse_tx_irq_res);
- if (sc->atse_rxc_mem_res != NULL)
+ sc->atse_tx_irq_res = NULL;
+ }
+ if (sc->atse_rxc_mem_res != NULL) {
bus_release_resource(dev, SYS_RES_MEMORY, sc->atse_rxc_mem_rid,
sc->atse_rxc_mem_res);
- if (sc->atse_rx_mem_res != NULL)
+ sc->atse_rxc_mem_res = NULL;
+ }
+ if (sc->atse_rx_mem_res != NULL) {
bus_release_resource(dev, SYS_RES_MEMORY, sc->atse_rx_mem_rid,
sc->atse_rx_mem_res);
- if (sc->atse_rx_irq_res != NULL)
+ sc->atse_rx_mem_res = NULL;
+ }
+ if (sc->atse_rx_irq_res != NULL) {
bus_release_resource(dev, SYS_RES_IRQ, sc->atse_rx_irq_rid,
sc->atse_rx_irq_res);
- if (sc->atse_mem_res != NULL)
+ sc->atse_rx_irq_res = NULL;
+ }
+ if (sc->atse_mem_res != NULL) {
bus_release_resource(dev, SYS_RES_MEMORY, sc->atse_mem_rid,
sc->atse_mem_res);
+ sc->atse_mem_res = NULL;
+ }
}
static int
More information about the p4-projects
mailing list