From 0b030332fca72ee2424693db34f254a52211cd03 Mon Sep 17 00:00:00 2001 From: Nick Hudson Date: Tue, 19 Jul 2022 07:44:23 +0100 Subject: [PATCH 04/67] wm: fixes --- sys/dev/pci/if_wm.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/sys/dev/pci/if_wm.c b/sys/dev/pci/if_wm.c index ce60e7b59c74..6b57d5c3b6f6 100644 --- a/sys/dev/pci/if_wm.c +++ b/sys/dev/pci/if_wm.c @@ -3872,6 +3872,7 @@ wm_ifflags_cb(struct ethercom *ec) DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); + KASSERT(IFNET_LOCKED(ifp)); WM_CORE_LOCK(sc); /* @@ -3971,6 +3972,14 @@ wm_ioctl(struct ifnet *ifp, u_long cmd, void *data) DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); + switch (cmd) { + case SIOCADDMULTI: + case SIOCDELMULTI: + break; + default: + KASSERT(IFNET_LOCKED(ifp)); + } + #ifndef WM_MPSAFE s = splnet(); #endif @@ -4039,15 +4048,15 @@ wm_ioctl(struct ifnet *ifp, u_long cmd, void *data) if (cmd == SIOCSIFCAP) error = if_init(ifp); - else if (cmd != SIOCADDMULTI && cmd != SIOCDELMULTI) - ; - else if (ifp->if_flags & IFF_RUNNING) { - /* - * Multicast list has changed; set the hardware filter - * accordingly. - */ + else if (cmd == SIOCADDMULTI || cmd == SIOCDELMULTI) { WM_CORE_LOCK(sc); - wm_set_filter(sc); + if (sc->sc_if_flags & IFF_RUNNING) { + /* + * Multicast list has changed; set the hardware filter + * accordingly. + */ + wm_set_filter(sc); + } WM_CORE_UNLOCK(sc); } break; @@ -11304,7 +11313,10 @@ wm_gmii_mediachange(struct ifnet *ifp) DPRINTF(sc, WM_DEBUG_GMII, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); - if ((ifp->if_flags & IFF_UP) == 0) + + KASSERT(WM_CORE_LOCKED(sc)); + + if ((sc->sc_if_flags & IFF_UP) == 0) return 0; /* XXX Not for I354? FreeBSD's e1000_82575.c doesn't include it */ @@ -11377,6 +11389,8 @@ wm_gmii_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr) { struct wm_softc *sc = ifp->if_softc; + KASSERT(WM_CORE_LOCKED(sc)); + ether_mediastatus(ifp, ifmr); ifmr->ifm_active = (ifmr->ifm_active & ~IFM_ETH_FMASK) | sc->sc_flowflags; -- 2.25.1