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 wi panics on card ejection in Powerbook in b...



details:   https://anonhg.NetBSD.org/src/rev/21333bccdf45
branches:  trunk
changeset: 547461:21333bccdf45
user:      dyoung <dyoung%NetBSD.org@localhost>
date:      Tue May 20 01:29:35 2003 +0000

description:
Stop wi panics on card ejection in Powerbook in both the enabled
and disabled states. This should fix an x86 panic somebody reported
on icb.

diffstat:

 sys/dev/ic/wi.c    |  42 ++++++++++++++++++++----------------------
 sys/dev/ic/wivar.h |   3 ++-
 2 files changed, 22 insertions(+), 23 deletions(-)

diffs (121 lines):

diff -r fe1d50af0f58 -r 21333bccdf45 sys/dev/ic/wi.c
--- a/sys/dev/ic/wi.c   Mon May 19 23:24:55 2003 +0000
+++ b/sys/dev/ic/wi.c   Tue May 20 01:29:35 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wi.c,v 1.126 2003/05/17 16:46:03 christos Exp $        */
+/*     $NetBSD: wi.c,v 1.127 2003/05/20 01:29:35 dyoung Exp $  */
 
 /*
  * Copyright (c) 1997, 1998, 1999
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wi.c,v 1.126 2003/05/17 16:46:03 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wi.c,v 1.127 2003/05/20 01:29:35 dyoung Exp $");
 
 #define WI_HERMES_AUTOINC_WAR  /* Work around data write autoinc bug. */
 #define WI_HERMES_STATS_WAR    /* Work around stats counter bug. */
@@ -222,8 +222,11 @@
        CSR_WRITE_2(sc, WI_INT_EN, 0);
        CSR_WRITE_2(sc, WI_EVENT_ACK, ~0);
 
+       sc->sc_invalid = 0;
+
        /* Reset the NIC. */
        if (wi_reset(sc) != 0) {
+               sc->sc_invalid = 1;
                splx(s);
                return 1;
        }
@@ -414,16 +417,14 @@
 
        s = splnet();
 
+       sc->sc_invalid = 1;
+       wi_stop(ifp, 1);
+
        /* Delete all remaining media. */
        ifmedia_delete_instance(&sc->sc_media, IFM_INST_ANY);
 
        ieee80211_ifdetach(ifp);
        if_detach(ifp);
-       if (sc->sc_enabled) {
-               if (sc->sc_disable)
-                       (*sc->sc_disable)(sc);
-               sc->sc_enabled = 0;
-       }
        splx(s);
        return 0;
 }
@@ -717,26 +718,18 @@
        struct wi_softc *sc = ifp->if_softc;
        int s;
 
+       if (!sc->sc_enabled)
+               return;
+
        s = splnet();
 
        DPRINTF(("wi_stop: disable %d\n", disable));
-       /* Writing registers of a detached wi provokes an
-        * MCHK on PowerPC, but disabling keeps wi from writing
-        * registers, so disable before doing anything else.
-        */
-       if (sc->sc_attached)
-               ieee80211_new_state(ifp, IEEE80211_S_INIT, -1);
-       if (sc->sc_enabled) {
+
+       ieee80211_new_state(ifp, IEEE80211_S_INIT, -1);
+       if (!sc->sc_invalid) {
                CSR_WRITE_2(sc, WI_INT_EN, 0);
                wi_cmd(sc, WI_CMD_DISABLE | sc->sc_portnum, 0, 0, 0);
-               if (disable) {
-                       if (sc->sc_disable)
-                               (*sc->sc_disable)(sc);
-                       sc->sc_enabled = 0;
-               }
        }
-       if (!sc->sc_attached)
-               ieee80211_new_state(ifp, IEEE80211_S_INIT, -1);
 
        sc->sc_tx_timer = 0;
        sc->sc_scan_timer = 0;
@@ -746,6 +739,11 @@
        ifp->if_flags &= ~(IFF_OACTIVE | IFF_RUNNING);
        ifp->if_timer = 0;
 
+       if (disable) {
+               if (sc->sc_disable)
+                       (*sc->sc_disable)(sc);
+               sc->sc_enabled = 0;
+       }
        splx(s);
 }
 
@@ -760,7 +758,7 @@
        struct wi_frame frmhdr;
        int cur, fid, off;
 
-       if (ifp->if_flags & IFF_OACTIVE)
+       if (!sc->sc_enabled || sc->sc_invalid)
                return;
        if (sc->sc_flags & WI_FLAGS_OUTRANGE)
                return;
diff -r fe1d50af0f58 -r 21333bccdf45 sys/dev/ic/wivar.h
--- a/sys/dev/ic/wivar.h        Mon May 19 23:24:55 2003 +0000
+++ b/sys/dev/ic/wivar.h        Tue May 20 01:29:35 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wivar.h,v 1.33 2003/05/16 01:26:18 dyoung Exp $        */
+/*     $NetBSD: wivar.h,v 1.34 2003/05/20 01:29:35 dyoung Exp $        */
 
 /*
  * Copyright (c) 1997, 1998, 1999
@@ -46,6 +46,7 @@
 
        int                     sc_attached;
        int                     sc_enabled;
+       int                     sc_invalid;
        int                     sc_firmware_type;
 #define        WI_NOTYPE       0
 #define        WI_LUCENT       1



Home | Main Index | Thread Index | Old Index