From owner-p4-projects@FreeBSD.ORG Fri Jan 18 05:57:57 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id E137C16A41B; Fri, 18 Jan 2008 05:57:56 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8E53B16A419 for ; Fri, 18 Jan 2008 05:57:56 +0000 (UTC) (envelope-from kmacy@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 59F2813C47E for ; Fri, 18 Jan 2008 05:57:56 +0000 (UTC) (envelope-from kmacy@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m0I5vu4m050898 for ; Fri, 18 Jan 2008 05:57:56 GMT (envelope-from kmacy@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m0I5vuWc050895 for perforce@freebsd.org; Fri, 18 Jan 2008 05:57:56 GMT (envelope-from kmacy@freebsd.org) Date: Fri, 18 Jan 2008 05:57:56 GMT Message-Id: <200801180557.m0I5vuWc050895@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to kmacy@freebsd.org using -f From: Kip Macy To: Perforce Change Reviews Cc: Subject: PERFORCE change 133527 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Jan 2008 05:57:57 -0000 http://perforce.freebsd.org/chv.cgi?CH=133527 Change 133527 by kmacy@pandemonium:kmacy:xen31 on 2008/01/18 05:57:33 convert console lock to spin mutex as the output routines can be called from interrupt context Affected files ... .. //depot/projects/xen31/sys/dev/xen/console/console.c#7 edit Differences ... ==== //depot/projects/xen31/sys/dev/xen/console/console.c#7 (text+ko) ==== @@ -76,9 +76,10 @@ #define XCUNIT(x) (minor(x)) #define ISTTYOPEN(tp) ((tp) && ((tp)->t_state & TS_ISOPEN)) #define CN_LOCK_INIT(x, _name) \ - mtx_init(&x, _name, NULL, MTX_DEF|MTX_RECURSE) -#define CN_LOCK(l) mtx_lock(&(l)) -#define CN_UNLOCK(l) mtx_unlock(&(l)) + mtx_init(&x, _name, NULL, MTX_SPIN|MTX_RECURSE) + +#define CN_LOCK(l) mtx_lock_spin(&(l)) +#define CN_UNLOCK(l) mtx_unlock_spin(&(l)) #define CN_LOCK_ASSERT(x) mtx_assert(&x, MA_OWNED) #define CN_LOCK_DESTROY(x) mtx_destroy(&x) @@ -162,9 +163,7 @@ static void xccnputc(struct consdev *dev, int c) { - CN_LOCK(cn_mtx); xcons_putc(c); - CN_UNLOCK(cn_mtx); } static void @@ -288,20 +287,20 @@ int i; struct tty *tp = xccons; - CN_LOCK(cn_mtx); for (i = 0; i < len; i++) { - if (xen_console_up) + if (xen_console_up) (*linesw[tp->t_line]->l_rint)(buf[i], tp); else rbuf[RBUF_MASK(rp++)] = buf[i]; } - CN_UNLOCK(cn_mtx); } static void __xencons_tx_flush(void) { int sz, work_done = 0; + + CN_LOCK(cn_mtx); while (wc != wp) { int sent; sz = wp - wc; @@ -318,7 +317,8 @@ } work_done = 1; } - + CN_UNLOCK(cn_mtx); + if (work_done && xen_console_up) ttwakeup(xccons); } @@ -326,9 +326,7 @@ void xencons_tx(void) { - CN_LOCK(cn_mtx); __xencons_tx_flush(); - CN_UNLOCK(cn_mtx); } static void @@ -432,31 +430,33 @@ static void xcstart(struct tty *tp) { - int s; boolean_t cons_full = FALSE; - s = spltty(); CN_LOCK(cn_mtx); if (tp->t_state & (TS_TIMEOUT | TS_TTSTOP)) { + CN_UNLOCK(cn_mtx); + ttwwakeup(tp); - CN_UNLOCK(cn_mtx); return; } tp->t_state |= TS_BUSY; + CN_UNLOCK(cn_mtx); + while (tp->t_outq.c_cc != 0 && !cons_full) cons_full = xcons_putc(getc(&tp->t_outq)); /* if the console is close to full leave our state as busy */ if (!cons_full) { - tp->t_state &= ~TS_BUSY; - ttwwakeup(tp); + CN_LOCK(cn_mtx); + tp->t_state &= ~TS_BUSY; + CN_UNLOCK(cn_mtx); + ttwwakeup(tp); } else { /* let the timeout kick us in a bit */ xc_start_needed = TRUE; } - CN_UNLOCK(cn_mtx); - splx(s); + } static void