Module Name:    src
Committed By:   riastradh
Date:           Thu Nov  2 13:49:37 UTC 2023

Modified Files:
        src/sys/dev/ic: dwc_eqos.c dwc_eqos_var.h

Log Message:
eqos(4): Wait for callout to halt and make sure it stays halted.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/dev/ic/dwc_eqos.c
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/ic/dwc_eqos_var.h

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/dwc_eqos.c
diff -u src/sys/dev/ic/dwc_eqos.c:1.29 src/sys/dev/ic/dwc_eqos.c:1.30
--- src/sys/dev/ic/dwc_eqos.c:1.29	Thu Nov  2 02:32:41 2023
+++ src/sys/dev/ic/dwc_eqos.c	Thu Nov  2 13:49:37 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_eqos.c,v 1.29 2023/11/02 02:32:41 msaitoh Exp $ */
+/* $NetBSD: dwc_eqos.c,v 1.30 2023/11/02 13:49:37 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2022 Jared McNeill <jmcne...@invisible.ca>
@@ -38,7 +38,7 @@
 #include "opt_net_mpsafe.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dwc_eqos.c,v 1.29 2023/11/02 02:32:41 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwc_eqos.c,v 1.30 2023/11/02 13:49:37 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -468,7 +468,8 @@ eqos_tick(void *softc)
 
 	EQOS_LOCK(sc);
 	mii_tick(mii);
-	callout_schedule(&sc->sc_stat_ch, hz);
+	if (sc->sc_running)
+		callout_schedule(&sc->sc_stat_ch, hz);
 	EQOS_UNLOCK(sc);
 
 #ifndef EQOS_MPSAFE
@@ -697,6 +698,7 @@ eqos_init_locked(struct eqos_softc *sc)
 	/* Enable interrupts */
 	eqos_enable_intr(sc);
 
+	sc->sc_running = true;
 	ifp->if_flags |= IFF_RUNNING;
 
 	mii_mediachg(mii);
@@ -729,7 +731,8 @@ eqos_stop_locked(struct eqos_softc *sc, 
 
 	EQOS_ASSERT_LOCKED(sc);
 
-	callout_stop(&sc->sc_stat_ch);
+	sc->sc_running = false;
+	callout_halt(&sc->sc_stat_ch, &sc->sc_lock);
 
 	mii_down(&sc->sc_mii);
 

Index: src/sys/dev/ic/dwc_eqos_var.h
diff -u src/sys/dev/ic/dwc_eqos_var.h:1.6 src/sys/dev/ic/dwc_eqos_var.h:1.7
--- src/sys/dev/ic/dwc_eqos_var.h:1.6	Thu Oct 26 18:02:50 2023
+++ src/sys/dev/ic/dwc_eqos_var.h	Thu Nov  2 13:49:37 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_eqos_var.h,v 1.6 2023/10/26 18:02:50 msaitoh Exp $ */
+/* $NetBSD: dwc_eqos_var.h,v 1.7 2023/11/02 13:49:37 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2022 Jared McNeill <jmcne...@invisible.ca>
@@ -70,6 +70,7 @@ struct eqos_softc {
 	callout_t		sc_stat_ch;
 	kmutex_t		sc_lock;
 	kmutex_t		sc_txlock;
+	bool			sc_running;
 
 	struct eqos_ring	sc_tx;
 	struct eqos_ring	sc_rx;

Reply via email to