PERFORCE change 133527 for review
Kip Macy
kmacy at FreeBSD.org
Thu Jan 17 21:57:57 PST 2008
http://perforce.freebsd.org/chv.cgi?CH=133527
Change 133527 by kmacy at 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
More information about the p4-projects
mailing list