Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/newsmips Pull a similar fix from sparc/dev/zs.c rev...



details:   https://anonhg.NetBSD.org/src/rev/6d3477000661
branches:  trunk
changeset: 755871:6d3477000661
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sat Jun 26 03:44:49 2010 +0000

description:
Pull a similar fix from sparc/dev/zs.c rev 1.119:
 Establish interrupt handlers with proper softc per each zs device
 rather than sharing them among all zs devices and searching softc
 in handlers, to avoid possible recursive lock.

diffstat:

 sys/arch/newsmips/apbus/zs_ap.c |  23 ++++++-------------
 sys/arch/newsmips/dev/zs.c      |  47 ++++++++--------------------------------
 sys/arch/newsmips/dev/zs_hb.c   |  15 ++++--------
 3 files changed, 22 insertions(+), 63 deletions(-)

diffs (173 lines):

diff -r 2176d0fa99ea -r 6d3477000661 sys/arch/newsmips/apbus/zs_ap.c
--- a/sys/arch/newsmips/apbus/zs_ap.c   Sat Jun 26 03:39:53 2010 +0000
+++ b/sys/arch/newsmips/apbus/zs_ap.c   Sat Jun 26 03:44:49 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: zs_ap.c,v 1.25 2008/04/28 20:23:30 martin Exp $        */
+/*     $NetBSD: zs_ap.c,v 1.26 2010/06/26 03:44:49 tsutsui Exp $       */
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: zs_ap.c,v 1.25 2008/04/28 20:23:30 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zs_ap.c,v 1.26 2010/06/26 03:44:49 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -213,7 +213,6 @@
        volatile u_int *portBctl = (void *)(apa->apa_hwbase + PORTB_OFFSET);
        volatile u_int *portActl = (void *)(apa->apa_hwbase + PORTA_OFFSET);
        volatile u_int *esccregs = (void *)(apa->apa_hwbase + ESCC_REG);
-       static int didintr;
 
        zsc->zsc_dev = self;
        zs_unit = device_unit(self);
@@ -295,20 +294,12 @@
        }
 
        /*
-        * Now safe to install interrupt handlers.  Note the arguments
-        * to the interrupt handlers aren't used.  Note, we only do this
-        * once since both SCCs interrupt at the same level and vector.
+        * Now safe to install interrupt handlers.
         */
-       if (!didintr) {
-               didintr = 1;
-
-               zsc->zsc_si = softint_establish(SOFTINT_SERIAL, zssoft, zsc);
-               apbus_intr_establish(1, /* interrupt level ( 0 or 1 ) */
-                                    NEWS5000_INT1_SCC,
-                                    0, /* priority */
-                                    zshard_ap, zsc,
-                                    apa->apa_name, apa->apa_ctlnum);
-       }
+       zsc->zsc_si = softint_establish(SOFTINT_SERIAL, zssoft, zsc);
+       apbus_intr_establish(1, /* interrupt level ( 0 or 1 ) */
+           NEWS5000_INT1_SCC, 0, /* priority */
+           zshard_ap, zsc, apa->apa_name, apa->apa_ctlnum);
        /* XXX; evcnt_attach() ? */
 
 #if 0
diff -r 2176d0fa99ea -r 6d3477000661 sys/arch/newsmips/dev/zs.c
--- a/sys/arch/newsmips/dev/zs.c        Sat Jun 26 03:39:53 2010 +0000
+++ b/sys/arch/newsmips/dev/zs.c        Sat Jun 26 03:44:49 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: zs.c,v 1.25 2008/06/13 12:26:35 cegger Exp $   */
+/*     $NetBSD: zs.c,v 1.26 2010/06/26 03:44:49 tsutsui Exp $  */
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.25 2008/06/13 12:26:35 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.26 2010/06/26 03:44:49 tsutsui Exp $");
 
 #include "opt_ddb.h"
 
@@ -80,51 +80,24 @@
 }
 
 /*
- * Our ZS chips all share a common, autovectored interrupt,
- * so we have to look at all of them on each interrupt.
+ * Our ZS chips all share a common interrupt level,
+ * but we establish zshard handler per each ZS chips
+ * to avoid holding unnecessary locks in interrupt context.
  */
 int
 zshard(void *arg)
 {
-       struct zsc_softc *zsc;
-       int unit, rval, softreq;
+       struct zsc_softc *zsc = arg;
+       int rval;
 
-       rval = 0;
-       for (unit = 0; unit < zsc_cd.cd_ndevs; unit++) {
-               zsc = device_lookup_private(&zsc_cd, unit);
-               if (zsc == NULL)
-                       continue;
-               rval |= zsc_intr_hard(zsc);
-               softreq =  zsc->zsc_cs[0]->cs_softreq;
-               softreq |= zsc->zsc_cs[1]->cs_softreq;
-               if (softreq)
-                       softint_schedule(zsc->zsc_si);
-       }
+       rval = zsc_intr_hard(zsc);
+       if (zsc->zsc_cs[0]->cs_softreq || zsc->zsc_cs[1]->cs_softreq)
+               softint_schedule(zsc->zsc_si);
 
        return rval;
 }
 
 /*
- * Similar scheme as for zshard (look at all of them)
- */
-void
-zssoft(void *arg)
-{
-       struct zsc_softc *zsc;
-       int s, unit;
-
-       /* Make sure we call the tty layer at spltty. */
-       s = spltty();
-       for (unit = 0; unit < zsc_cd.cd_ndevs; unit++) {
-               zsc = device_lookup_private(&zsc_cd, unit);
-               if (zsc == NULL)
-                       continue;
-               (void)zsc_intr_soft(zsc);
-       }
-       splx(s);
-}
-
-/*
  * Compute the current baud rate given a ZS channel.
  */
 int
diff -r 2176d0fa99ea -r 6d3477000661 sys/arch/newsmips/dev/zs_hb.c
--- a/sys/arch/newsmips/dev/zs_hb.c     Sat Jun 26 03:39:53 2010 +0000
+++ b/sys/arch/newsmips/dev/zs_hb.c     Sat Jun 26 03:44:49 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: zs_hb.c,v 1.25 2008/04/28 20:23:30 martin Exp $        */
+/*     $NetBSD: zs_hb.c,v 1.26 2010/06/26 03:44:49 tsutsui Exp $       */
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: zs_hb.c,v 1.25 2008/04/28 20:23:30 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zs_hb.c,v 1.26 2010/06/26 03:44:49 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -196,7 +196,6 @@
        volatile struct zschan *zc;
        struct zs_chanstate *cs;
        int s, zs_unit, channel, intlevel;
-       static int didintr;
 
        zsc->zsc_dev = self;
        zs_unit = device_unit(self);
@@ -284,13 +283,9 @@
         * to the interrupt handlers aren't used.  Note, we only do this
         * once since both SCCs interrupt at the same level and vector.
         */
-       if (!didintr) {
-               didintr = 1;
-
-               zsc->zsc_si = softint_establish(SOFTINT_SERIAL, zssoft, zsc);
-               hb_intr_establish(intlevel, INTST1_SCC, IPL_SERIAL,
-                   zshard_hb, NULL);
-       }
+       zsc->zsc_si = softint_establish(SOFTINT_SERIAL,
+           (void (*)(void *))zsc_intr_soft, zsc);
+       hb_intr_establish(intlevel, INTST1_SCC, IPL_SERIAL, zshard_hb, zsc);
        /* XXX; evcnt_attach() ? */
 
        /*



Home | Main Index | Thread Index | Old Index