Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/marvell Fix a bug that kernel panics when the system...



details:   https://anonhg.NetBSD.org/src/rev/c6ba7e580ac3
branches:  trunk
changeset: 782121:c6ba7e580ac3
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Wed Oct 17 18:12:59 2012 +0000

description:
Fix a bug that kernel panics when the system get a packet while calling
mvgbe_stop (via ifconfig down).

diffstat:

 sys/dev/marvell/if_mvgbe.c |  19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)

diffs (54 lines):

diff -r 0a628ccd8cd3 -r c6ba7e580ac3 sys/dev/marvell/if_mvgbe.c
--- a/sys/dev/marvell/if_mvgbe.c        Wed Oct 17 17:48:48 2012 +0000
+++ b/sys/dev/marvell/if_mvgbe.c        Wed Oct 17 18:12:59 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_mvgbe.c,v 1.25 2012/10/16 19:49:41 msaitoh Exp $    */
+/*     $NetBSD: if_mvgbe.c,v 1.26 2012/10/17 18:12:59 msaitoh Exp $    */
 /*
  * Copyright (c) 2007, 2008 KIYOHARA Takashi
  * All rights reserved.
@@ -25,7 +25,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_mvgbe.c,v 1.25 2012/10/16 19:49:41 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_mvgbe.c,v 1.26 2012/10/17 18:12:59 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -885,6 +885,9 @@
 
                claimed = 1;
 
+               if (!(ifp->if_flags & IFF_RUNNING))
+                       break;
+
                if (ice & MVGBE_ICE_LINKCHG) {
                        if (MVGBE_READ(sc, MVGBE_PS) & MVGBE_PS_LINKUP) {
                                /* Enable port RX and TX. */
@@ -1127,6 +1130,7 @@
 mvgbe_stop(struct ifnet *ifp, int disable)
 {
        struct mvgbe_softc *sc = ifp->if_softc;
+       struct mvgbec_softc *csc = device_private(device_parent(sc->sc_dev));
        struct mvgbe_chain_data *cdata = &sc->sc_cdata;
        uint32_t reg;
        int i, cnt;
@@ -1199,7 +1203,16 @@
        reg = MVGBE_READ(sc, MVGBE_PSC);
        MVGBE_WRITE(sc, MVGBE_PSC, reg & ~MVGBE_PSC_PORTEN);
 
-       /* Disable interrupts */
+       /*
+        * Disable and clear interrupts
+        * 0) controller interrupt
+        * 1) port interrupt cause
+        * 2) port interrupt mask
+        */
+       MVGBE_WRITE(csc, MVGBE_EUIM, 0);
+       MVGBE_WRITE(csc, MVGBE_EUIC, 0);
+       MVGBE_WRITE(sc, MVGBE_IC, 0);
+       MVGBE_WRITE(sc, MVGBE_ICE, 0);
        MVGBE_WRITE(sc, MVGBE_PIM, 0);
        MVGBE_WRITE(sc, MVGBE_PEIM, 0);
 



Home | Main Index | Thread Index | Old Index