Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/mii mii(9): Fix callout race between mii_phy_down an...
details: https://anonhg.NetBSD.org/src/rev/aa214ada3f52
branches: trunk
changeset: 1029237:aa214ada3f52
user: riastradh <riastradh%NetBSD.org@localhost>
date: Tue Dec 28 12:00:48 2021 +0000
description:
mii(9): Fix callout race between mii_phy_down and mii_phy_detach.
diffstat:
sys/dev/mii/mii_physubr.c | 20 ++++++++++++++++----
1 files changed, 16 insertions(+), 4 deletions(-)
diffs (41 lines):
diff -r 724e5f09cdcb -r aa214ada3f52 sys/dev/mii/mii_physubr.c
--- a/sys/dev/mii/mii_physubr.c Tue Dec 28 10:47:00 2021 +0000
+++ b/sys/dev/mii/mii_physubr.c Tue Dec 28 12:00:48 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mii_physubr.c,v 1.96 2021/12/15 08:28:22 msaitoh Exp $ */
+/* $NetBSD: mii_physubr.c,v 1.97 2021/12/28 12:00:48 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.96 2021/12/15 08:28:22 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mii_physubr.c,v 1.97 2021/12/28 12:00:48 riastradh Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -429,8 +429,20 @@
KASSERT(mii_locked(sc->mii_pdata));
if (sc->mii_flags & MIIF_DOINGAUTO) {
- sc->mii_flags &= ~MIIF_DOINGAUTO;
- callout_stop(&sc->mii_nway_ch);
+ /*
+ * Try to stop it.
+ *
+ * - If we stopped it before it expired, callout_stop
+ * returns 0, and it is our responsibility to clear
+ * MIIF_DOINGAUTO.
+ *
+ * - Otherwise, we're too late -- the callout has
+ * already begun, and we must leave MIIF_DOINGAUTO
+ * set so mii_phy_detach will wait for it to
+ * complete.
+ */
+ if (!callout_stop(&sc->mii_nway_ch))
+ sc->mii_flags &= ~MIIF_DOINGAUTO;
}
}
Home |
Main Index |
Thread Index |
Old Index