Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci Add some KASSERTs around the locking protocol.



details:   https://anonhg.NetBSD.org/src/rev/0ed3b0eb794d
branches:  trunk
changeset: 368762:0ed3b0eb794d
user:      skrll <skrll%NetBSD.org@localhost>
date:      Wed Aug 03 05:23:30 2022 +0000

description:
Add some KASSERTs around the locking protocol.

Discussed with msaitoh@, knakahara@ and riastradh@

diffstat:

 sys/dev/pci/if_wm.c |  19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)

diffs (75 lines):

diff -r 6e2156bd1703 -r 0ed3b0eb794d sys/dev/pci/if_wm.c
--- a/sys/dev/pci/if_wm.c       Wed Aug 03 01:53:06 2022 +0000
+++ b/sys/dev/pci/if_wm.c       Wed Aug 03 05:23:30 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_wm.c,v 1.749 2022/07/29 15:30:42 skrll Exp $        */
+/*     $NetBSD: if_wm.c,v 1.750 2022/08/03 05:23:30 skrll Exp $        */
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.749 2022/07/29 15:30:42 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.750 2022/08/03 05:23:30 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -3872,6 +3872,7 @@
        DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n",
                device_xname(sc->sc_dev), __func__));
 
+       KASSERT(IFNET_LOCKED(ifp));
        WM_CORE_LOCK(sc);
 
        /*
@@ -6470,6 +6471,8 @@
        struct wm_softc *sc = ifp->if_softc;
        int ret;
 
+       KASSERT(IFNET_LOCKED(ifp));
+
        WM_CORE_LOCK(sc);
        ret = wm_init_locked(ifp);
        WM_CORE_UNLOCK(sc);
@@ -6487,6 +6490,7 @@
 
        DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n",
                device_xname(sc->sc_dev), __func__));
+       KASSERT(IFNET_LOCKED(ifp));
        KASSERT(WM_CORE_LOCKED(sc));
 
        /*
@@ -7042,7 +7046,9 @@
        /* Start the one second link check clock. */
        callout_schedule(&sc->sc_tick_ch, hz);
 
-       /* ...all done! */
+       /*
+        * ...all done! (IFNET_LOCKED asserted above.)
+        */
        ifp->if_flags |= IFF_RUNNING;
 
  out:
@@ -11299,7 +11305,10 @@
 
        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 */
@@ -11372,6 +11381,8 @@
 {
        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;



Home | Main Index | Thread Index | Old Index