summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorriastradh <riastradh@NetBSD.org>2022-08-23 01:05:50 +0000
committerriastradh <riastradh@NetBSD.org>2022-08-23 01:05:50 +0000
commit6d75fda3b77b28658231f45c366ab15e6871d837 (patch)
tree09c809509b9b3d6f91ee0de7c64f5093d09b5fbe /sys/dev
parent49fbc5f1fad90423ab84fe54b912d297778ee98f (diff)
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.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/mii/mii_physubr.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/sys/dev/mii/mii_physubr.c b/sys/dev/mii/mii_physubr.c
index 7e0bc547c01..f29a8a22bde 100644
--- a/sys/dev/mii/mii_physubr.c
+++ b/sys/dev/mii/mii_physubr.c
@@ -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);