Module Name: src
Committed By: mrg
Date: Tue Sep 15 08:33:40 UTC 2020
Modified Files:
src/sys/dev/ic: gem.c
src/sys/dev/pci: if_cas.c
Log Message:
mii_detach() must come before ifmedia_fini(), otherwise mii_detach()
will have a NULL mutex and fault.
this appears to have been introduced in february, and may be a problem
in other drivers converted to use ifmedia_fini(). i've only fixed the
two that were faulting for me on sunblade 2000 during reboot.
To generate a diff of this commit:
cvs rdiff -u -r1.131 -r1.132 src/sys/dev/ic/gem.c
cvs rdiff -u -r1.43 -r1.44 src/sys/dev/pci/if_cas.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/ic/gem.c
diff -u src/sys/dev/ic/gem.c:1.131 src/sys/dev/ic/gem.c:1.132
--- src/sys/dev/ic/gem.c:1.131 Wed Jul 15 01:42:27 2020
+++ src/sys/dev/ic/gem.c Tue Sep 15 08:33:40 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: gem.c,v 1.131 2020/07/15 01:42:27 msaitoh Exp $ */
+/* $NetBSD: gem.c,v 1.132 2020/09/15 08:33:40 mrg Exp $ */
/*
*
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gem.c,v 1.131 2020/07/15 01:42:27 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gem.c,v 1.132 2020/09/15 08:33:40 mrg Exp $");
#include "opt_inet.h"
@@ -175,7 +175,6 @@ gem_detach(struct gem_softc *sc, int fla
rnd_detach_source(&sc->rnd_source);
ether_ifdetach(ifp);
if_detach(ifp);
- ifmedia_fini(&sc->sc_mii.mii_media);
callout_destroy(&sc->sc_tick_ch);
callout_destroy(&sc->sc_rx_watchdog);
@@ -184,6 +183,8 @@ gem_detach(struct gem_softc *sc, int fla
case GEM_ATT_MII:
sc->sc_att_stage = GEM_ATT_MII;
mii_detach(&sc->sc_mii, MII_PHY_ANY, MII_OFFSET_ANY);
+ ifmedia_fini(&sc->sc_mii.mii_media);
+
/*FALLTHROUGH*/
case GEM_ATT_7:
for (i = 0; i < GEM_NRXDESC; i++) {
Index: src/sys/dev/pci/if_cas.c
diff -u src/sys/dev/pci/if_cas.c:1.43 src/sys/dev/pci/if_cas.c:1.44
--- src/sys/dev/pci/if_cas.c:1.43 Thu Jul 2 09:02:04 2020
+++ src/sys/dev/pci/if_cas.c Tue Sep 15 08:33:40 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: if_cas.c,v 1.43 2020/07/02 09:02:04 msaitoh Exp $ */
+/* $NetBSD: if_cas.c,v 1.44 2020/09/15 08:33:40 mrg Exp $ */
/* $OpenBSD: if_cas.c,v 1.29 2009/11/29 16:19:38 kettenis Exp $ */
/*
@@ -44,7 +44,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_cas.c,v 1.43 2020/07/02 09:02:04 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cas.c,v 1.44 2020/09/15 08:33:40 mrg Exp $");
#ifndef _MODULE
#include "opt_inet.h"
@@ -765,12 +765,13 @@ cas_detach(device_t self, int flags)
ether_ifdetach(ifp);
if_detach(ifp);
- ifmedia_fini(&sc->sc_mii.mii_media);
callout_destroy(&sc->sc_tick_ch);
mii_detach(&sc->sc_mii, MII_PHY_ANY, MII_OFFSET_ANY);
+ ifmedia_fini(&sc->sc_mii.mii_media);
+
/*FALLTHROUGH*/
case CAS_ATT_MII:
case CAS_ATT_7: