Module Name: src
Committed By: riastradh
Date: Tue Aug 23 01:05:50 UTC 2022
Modified Files:
src/sys/dev/mii: mii_physubr.c
Log Message:
mii(9): Make mii_phy_down clear the flag if it prevented the callout.
This fixes a bug in the previous change to make mii_down wait for the
mii auto timeout to complete.
To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/sys/dev/mii/mii_physubr.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/mii/mii_physubr.c
diff -u src/sys/dev/mii/mii_physubr.c:1.100 src/sys/dev/mii/mii_physubr.c:1.101
--- src/sys/dev/mii/mii_physubr.c:1.100 Sat Aug 20 11:12:46 2022
+++ src/sys/dev/mii/mii_physubr.c Tue Aug 23 01:05:50 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: mii_physubr.c,v 1.100 2022/08/20 11:12:46 riastradh Exp $ */
+/* $NetBSD: mii_physubr.c,v 1.101 2022/08/23 01:05:50 riastradh Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mii_physubr.c,v 1.100 2022/08/20 11:12:46 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mii_physubr.c,v 1.101 2022/08/23 01:05:50 riastradh Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -441,9 +441,15 @@ mii_phy_down(struct mii_softc *sc)
sc->mii_pdata->mii_media.ifm_lock);
}
} else {
- if (sc->mii_flags & MIIF_DOINGAUTO) {
- callout_halt(&sc->mii_nway_ch,
- sc->mii_pdata->mii_media.ifm_lock);
+ if ((sc->mii_flags & MIIF_DOINGAUTO) != 0 &&
+ callout_halt(&sc->mii_nway_ch,
+ sc->mii_pdata->mii_media.ifm_lock) == 0) {
+ /*
+ * The callout was scheduled, and we prevented
+ * it from running before it expired, so we are
+ * now responsible for clearing the flag.
+ */
+ sc->mii_flags &= ~MIIF_DOINGAUTO;
}
}
KASSERT((sc->mii_flags & MIIF_DOINGAUTO) == 0);