Module Name: src Committed By: mrg Date: Fri May 22 03:51:30 UTC 2009
Modified Files: src/sys/arch/sparc/dev: zs.c src/sys/arch/sparc64/dev: zs.c src/sys/dev/ic: z8530sc.c z8530sc.h z8530tty.c Log Message: add two new functions for z8530tty: zs_chan_lock() and zs_chan_unlock(), and use them instead of various spl's in the zs.c's. reviewed by ad and martin. To generate a diff of this commit: cvs rdiff -u -r1.114 -r1.115 src/sys/arch/sparc/dev/zs.c cvs rdiff -u -r1.67 -r1.68 src/sys/arch/sparc64/dev/zs.c cvs rdiff -u -r1.29 -r1.30 src/sys/dev/ic/z8530sc.c cvs rdiff -u -r1.25 -r1.26 src/sys/dev/ic/z8530sc.h cvs rdiff -u -r1.126 -r1.127 src/sys/dev/ic/z8530tty.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/sparc/dev/zs.c diff -u src/sys/arch/sparc/dev/zs.c:1.114 src/sys/arch/sparc/dev/zs.c:1.115 --- src/sys/arch/sparc/dev/zs.c:1.114 Sat May 16 16:55:24 2009 +++ src/sys/arch/sparc/dev/zs.c Fri May 22 03:51:30 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: zs.c,v 1.114 2009/05/16 16:55:24 cegger Exp $ */ +/* $NetBSD: zs.c,v 1.115 2009/05/22 03:51:30 mrg Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.114 2009/05/16 16:55:24 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.115 2009/05/22 03:51:30 mrg Exp $"); #include "opt_ddb.h" #include "opt_kgdb.h" @@ -395,7 +395,7 @@ { struct zsc_attach_args zsc_args; struct zs_chanstate *cs; - int s, channel; + int channel; static int didintr, prevpri; #if (NKBD > 0) || (NMS > 0) int ch0_is_cons = 0; @@ -507,9 +507,9 @@ /* No sub-driver. Just reset it. */ uint8_t reset = (channel == 0) ? ZSWR9_A_RESET : ZSWR9_B_RESET; - s = splzs(); + zs_lock_chan(cs); zs_write_reg(cs, 9, reset); - splx(s); + zs_unlock_chan(cs); } #if (NKBD > 0) || (NMS > 0) /* @@ -569,12 +569,12 @@ * (common to both channels, do it on A) */ cs = zsc->zsc_cs[0]; - s = splhigh(); + zs_lock_chan(cs); /* interrupt vector */ zs_write_reg(cs, 2, zs_init_reg[2]); /* master interrupt control (enable) */ zs_write_reg(cs, 9, zs_init_reg[9]); - splx(s); + zs_unlock_chan(cs); #if 0 /* @@ -651,7 +651,7 @@ zssoft(void *arg) { struct zsc_softc *zsc; - int s, unit; + int unit; /* This is not the only ISR on this IPL. */ if (zssoftpending == 0) @@ -666,15 +666,19 @@ /* ienab_bic(IE_ZSSOFT); */ zssoftpending = 0; - /* Make sure we call the tty layer at spltty. */ - s = spltty(); +#if 0 /* not yet */ + /* Make sure we call the tty layer with tty_lock held. */ + mutex_spin_enter(&tty_lock); +#endif for (unit = 0; unit < zs_cd.cd_ndevs; unit++) { zsc = device_lookup_private(&zs_cd, unit); if (zsc == NULL) continue; (void)zsc_intr_soft(zsc); } - splx(s); +#if 0 /* not yet */ + mutex_spin_exit(&tty_lock); +#endif } @@ -729,7 +733,6 @@ int zs_set_modes(struct zs_chanstate *cs, int cflag) { - int s; /* * Output hardware flow control on the chip is horrendous: @@ -738,7 +741,7 @@ * Therefore, NEVER set the HFC bit, and instead use the * status interrupt to detect CTS changes. */ - s = splzs(); + zs_lock_chan(cs); cs->cs_rr0_pps = 0; if ((cflag & (CLOCAL | MDMBUF)) != 0) { cs->cs_rr0_dcd = 0; @@ -763,7 +766,7 @@ cs->cs_wr5_rts = 0; cs->cs_rr0_cts = 0; } - splx(s); + zs_unlock_chan(cs); /* Caller will stuff the pending registers. */ return (0); Index: src/sys/arch/sparc64/dev/zs.c diff -u src/sys/arch/sparc64/dev/zs.c:1.67 src/sys/arch/sparc64/dev/zs.c:1.68 --- src/sys/arch/sparc64/dev/zs.c:1.67 Fri Jun 13 13:10:49 2008 +++ src/sys/arch/sparc64/dev/zs.c Fri May 22 03:51:30 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: zs.c,v 1.67 2008/06/13 13:10:49 cegger Exp $ */ +/* $NetBSD: zs.c,v 1.68 2009/05/22 03:51:30 mrg Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.67 2008/06/13 13:10:49 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.68 2009/05/22 03:51:30 mrg Exp $"); #include "opt_ddb.h" #include "opt_kgdb.h" @@ -254,7 +254,7 @@ { struct zsc_attach_args zsc_args; struct zs_chanstate *cs; - int s, channel; + int channel; if (zsd == NULL) { aprint_error(": configuration incomplete\n"); @@ -333,9 +333,9 @@ /* No sub-driver. Just reset it. */ uint8_t reset = (channel == 0) ? ZSWR9_A_RESET : ZSWR9_B_RESET; - s = splzs(); + zs_lock_chan(cs); zs_write_reg(cs, 9, reset); - splx(s); + zs_unlock_chan(cs); } #if (NKBD > 0) || (NMS > 0) /* @@ -388,13 +388,12 @@ * (common to both channels, do it on A) */ cs = zsc->zsc_cs[0]; - s = splhigh(); + zs_lock_chan(cs); /* interrupt vector */ zs_write_reg(cs, 2, zs_init_reg[2]); /* master interrupt control (enable) */ zs_write_reg(cs, 9, zs_init_reg[9]); - splx(s); - + zs_unlock_chan(cs); } static int @@ -460,10 +459,11 @@ zssoft(void *arg) { struct zsc_softc *zsc = arg; - int s; - /* Make sure we call the tty layer at spltty. */ - s = spltty(); +#if 0 /* not yet */ + /* Make sure we call the tty layer with tty_lock held. */ + mutex_spin_enter(&tty_lock); +#endif zssoftpending = 0; (void)zsc_intr_soft(zsc); #ifdef TTY_DEBUG @@ -478,7 +478,9 @@ } } #endif - splx(s); +#if 0 /* not yet */ + mutex_spin_exit(&tty_lock); +#endif } @@ -532,7 +534,6 @@ int zs_set_modes(struct zs_chanstate *cs, int cflag) { - int s; /* * Output hardware flow control on the chip is horrendous: @@ -541,7 +542,7 @@ * Therefore, NEVER set the HFC bit, and instead use the * status interrupt to detect CTS changes. */ - s = splzs(); + zs_lock_chan(cs); cs->cs_rr0_pps = 0; if ((cflag & (CLOCAL | MDMBUF)) != 0) { cs->cs_rr0_dcd = 0; @@ -566,7 +567,7 @@ cs->cs_wr5_rts = 0; cs->cs_rr0_cts = 0; } - splx(s); + zs_unlock_chan(cs); /* Caller will stuff the pending registers. */ return (0); Index: src/sys/dev/ic/z8530sc.c diff -u src/sys/dev/ic/z8530sc.c:1.29 src/sys/dev/ic/z8530sc.c:1.30 --- src/sys/dev/ic/z8530sc.c:1.29 Fri Mar 20 16:28:57 2009 +++ src/sys/dev/ic/z8530sc.c Fri May 22 03:51:30 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: z8530sc.c,v 1.29 2009/03/20 16:28:57 tsutsui Exp $ */ +/* $NetBSD: z8530sc.c,v 1.30 2009/05/22 03:51:30 mrg Exp $ */ /* * Copyright (c) 1992, 1993 @@ -91,7 +91,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: z8530sc.c,v 1.29 2009/03/20 16:28:57 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: z8530sc.c,v 1.30 2009/05/22 03:51:30 mrg Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -274,6 +274,20 @@ mutex_init(&cs->cs_lock, MUTEX_NODEBUG, IPL_ZS); } +void +zs_lock_chan(struct zs_chanstate *cs) +{ + + mutex_spin_enter(&cs->cs_lock); +} + +void +zs_unlock_chan(struct zs_chanstate *cs) +{ + + mutex_spin_exit(&cs->cs_lock); +} + /* * ZS hardware interrupt. Scan all ZS channels. NB: we know here that * channels are kept in (A,B) pairs. Index: src/sys/dev/ic/z8530sc.h diff -u src/sys/dev/ic/z8530sc.h:1.25 src/sys/dev/ic/z8530sc.h:1.26 --- src/sys/dev/ic/z8530sc.h:1.25 Sun Apr 20 15:42:47 2008 +++ src/sys/dev/ic/z8530sc.h Fri May 22 03:51:30 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: z8530sc.h,v 1.25 2008/04/20 15:42:47 tsutsui Exp $ */ +/* $NetBSD: z8530sc.h,v 1.26 2009/05/22 03:51:30 mrg Exp $ */ /* * Copyright (c) 1992, 1993 @@ -203,6 +203,8 @@ int zs_set_speed(struct zs_chanstate *, int); int zs_set_modes(struct zs_chanstate *, int); void zs_lock_init(struct zs_chanstate *); +void zs_lock_chan(struct zs_chanstate *); +void zs_unlock_chan(struct zs_chanstate *); int zs_check_kgdb(struct zs_chanstate *, int); Index: src/sys/dev/ic/z8530tty.c diff -u src/sys/dev/ic/z8530tty.c:1.126 src/sys/dev/ic/z8530tty.c:1.127 --- src/sys/dev/ic/z8530tty.c:1.126 Tue May 12 14:25:18 2009 +++ src/sys/dev/ic/z8530tty.c Fri May 22 03:51:30 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: z8530tty.c,v 1.126 2009/05/12 14:25:18 cegger Exp $ */ +/* $NetBSD: z8530tty.c,v 1.127 2009/05/22 03:51:30 mrg Exp $ */ /*- * Copyright (c) 1993, 1994, 1995, 1996, 1997, 1998, 1999 @@ -137,7 +137,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: z8530tty.c,v 1.126 2009/05/12 14:25:18 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: z8530tty.c,v 1.127 2009/05/22 03:51:30 mrg Exp $"); #include "opt_kgdb.h" #include "opt_ntp.h" @@ -930,11 +930,10 @@ zsstop(struct tty *tp, int flag) { struct zstty_softc *zst; - int s; zst = device_lookup_private(&zstty_cd, ZSUNIT(tp->t_dev)); - s = splzs(); + mutex_spin_enter(&zst->zst_cs->cs_lock); if (ISSET(tp->t_state, TS_BUSY)) { /* Stop transmitting at the next chunk. */ zst->zst_tbc = 0; @@ -942,7 +941,7 @@ if (!ISSET(tp->t_state, TS_TTSTOP)) SET(tp->t_state, TS_FLUSH); } - splx(s); + mutex_spin_exit(&zst->zst_cs->cs_lock); } /* @@ -1508,15 +1507,14 @@ { struct zstty_softc *zst = arg; int overflows, floods; - int s; - s = splzs(); + mutex_spin_enter(&zst->zst_cs->cs_lock); overflows = zst->zst_overflows; zst->zst_overflows = 0; floods = zst->zst_floods; zst->zst_floods = 0; zst->zst_errors = 0; - splx(s); + mutex_spin_exit(&zst->zst_cs->cs_lock); log(LOG_WARNING, "%s: %d silo overflow%s, %d ibuf flood%s\n", device_xname(zst->zst_dev),