Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ic Stop the interface before detaching to avoid the ...



details:   https://anonhg.NetBSD.org/src/rev/d7a1324c4ea4
branches:  trunk
changeset: 336352:d7a1324c4ea4
user:      nakayama <nakayama%NetBSD.org@localhost>
date:      Thu Feb 26 16:07:10 2015 +0000

description:
Stop the interface before detaching to avoid the race between
tlp_detach() and tlp_intr().

While there, add missing callout_destroy()s.

diffstat:

 sys/dev/ic/tulip.c |  17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diffs (45 lines):

diff -r 585e857ec31f -r d7a1324c4ea4 sys/dev/ic/tulip.c
--- a/sys/dev/ic/tulip.c        Thu Feb 26 15:01:53 2015 +0000
+++ b/sys/dev/ic/tulip.c        Thu Feb 26 16:07:10 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tulip.c,v 1.184 2014/08/10 16:44:35 tls Exp $  */
+/*     $NetBSD: tulip.c,v 1.185 2015/02/26 16:07:10 nakayama Exp $     */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2002 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tulip.c,v 1.184 2014/08/10 16:44:35 tls Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tulip.c,v 1.185 2015/02/26 16:07:10 nakayama Exp $");
 
 
 #include <sys/param.h>
@@ -592,7 +592,7 @@
        struct tulip_rxsoft *rxs;
        struct tulip_txsoft *txs;
        device_t self = sc->sc_dev;
-       int i;
+       int i, s;
 
        /*
         * Succeed now if there isn't any work to do.
@@ -600,9 +600,14 @@
        if ((sc->sc_flags & TULIPF_ATTACHED) == 0)
                return (0);
 
-       /* Unhook our tick handler. */
-       if (sc->sc_tick)
-               callout_stop(&sc->sc_tick_callout);
+       s = splnet();
+       /* Stop the interface. Callouts are stopped in it. */
+       tlp_stop(ifp, 1);
+       splx(s);
+
+       /* Destroy our callouts. */
+       callout_destroy(&sc->sc_nway_callout);
+       callout_destroy(&sc->sc_tick_callout);
 
        if (sc->sc_flags & TULIPF_HAS_MII) {
                /* Detach all PHYs */



Home | Main Index | Thread Index | Old Index