summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2023-08-12 13:24:29 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2023-08-12 23:29:30 +0200
commitdd2ffd2ed67f2a867f62d30b8ff38516a80ea8e6 (patch)
tree468336428c4f9fc1a2c2b5cfa41a7d98e464621e
parent34890b4939c1ee8190a103b8693e94ddffe13ffa (diff)
tty: Convert t_lock to using simple_lock_irq
-rw-r--r--device/chario.c98
-rw-r--r--device/tty.h2
-rw-r--r--i386/i386at/kd.c17
-rw-r--r--xen/console.c17
4 files changed, 51 insertions, 83 deletions
diff --git a/device/chario.c b/device/chario.c
index 64640981..3fe93ccb 100644
--- a/device/chario.c
+++ b/device/chario.c
@@ -157,8 +157,7 @@ io_return_t char_open(
spl_t s;
io_return_t rc = D_SUCCESS;
- s = spltty();
- simple_lock(&tp->t_lock);
+ s = simple_lock_irq(&tp->t_lock);
tp->t_dev = dev;
@@ -192,8 +191,7 @@ io_return_t char_open(
if (tp->t_mctl)
(*tp->t_mctl)(tp, TM_RTS, DMBIS);
out:
- simple_unlock(&tp->t_lock);
- splx(s);
+ simple_unlock_irq(s, &tp->t_lock);
return rc;
}
@@ -206,13 +204,12 @@ boolean_t char_open_done(
io_req_t ior)
{
struct tty *tp = (struct tty *)ior->io_dev_ptr;
- spl_t s = spltty();
+ spl_t s;
- simple_lock(&tp->t_lock);
+ s = simple_lock_irq(&tp->t_lock);
if ((tp->t_state & TS_ISOPEN) == 0) {
queue_delayed_reply(&tp->t_delayed_open, ior, char_open_done);
- simple_unlock(&tp->t_lock);
- splx(s);
+ simple_unlock_irq(s, &tp->t_lock);
return FALSE;
}
@@ -222,8 +219,7 @@ boolean_t char_open_done(
if (tp->t_mctl)
(*tp->t_mctl)(tp, TM_RTS, DMBIS);
- simple_unlock(&tp->t_lock);
- splx(s);
+ simple_unlock_irq(s, &tp->t_lock);
ior->io_error = D_SUCCESS;
(void) ds_open_done(ior);
@@ -277,8 +273,7 @@ io_return_t char_write(
/*
* Check for tty operating.
*/
- s = spltty();
- simple_lock(&tp->t_lock);
+ s = simple_lock_irq(&tp->t_lock);
if ((tp->t_state & TS_CARR_ON) == 0) {
@@ -322,8 +317,7 @@ io_return_t char_write(
rc = D_IO_QUEUED;
}
out:
- simple_unlock(&tp->t_lock);
- splx(s);
+ simple_unlock_irq(s, &tp->t_lock);
if (!(ior->io_op & IO_INBAND))
(void) vm_deallocate(device_io_map, addr, ior->io_count);
@@ -339,19 +333,17 @@ boolean_t char_write_done(
io_req_t ior)
{
struct tty *tp = (struct tty *)ior->io_dev_ptr;
- spl_t s = spltty();
+ spl_t s;
- simple_lock(&tp->t_lock);
+ s = simple_lock_irq(&tp->t_lock);
if (tp->t_outq.c_cc > TTHIWAT(tp) ||
(tp->t_state & TS_CARR_ON) == 0) {
queue_delayed_reply(&tp->t_delayed_write, ior, char_write_done);
- simple_unlock(&tp->t_lock);
- splx(s);
+ simple_unlock_irq(s, &tp->t_lock);
return FALSE;
}
- simple_unlock(&tp->t_lock);
- splx(s);
+ simple_unlock_irq(s, &tp->t_lock);
if (IP_VALID(ior->io_reply_port)) {
(void) (*((ior->io_op & IO_INBAND) ?
@@ -394,8 +386,7 @@ io_return_t char_read(
if (rc != KERN_SUCCESS)
return rc;
- s = spltty();
- simple_lock(&tp->t_lock);
+ s = simple_lock_irq(&tp->t_lock);
if ((tp->t_state & TS_CARR_ON) == 0) {
if ((tp->t_state & TS_ONDELAY) == 0) {
@@ -431,8 +422,7 @@ io_return_t char_read(
}
out:
- simple_unlock(&tp->t_lock);
- splx(s);
+ simple_unlock_irq(s, &tp->t_lock);
return rc;
}
@@ -445,16 +435,15 @@ boolean_t char_read_done(
io_req_t ior)
{
struct tty *tp = (struct tty *)ior->io_dev_ptr;
- spl_t s = spltty();
+ spl_t s;
- simple_lock(&tp->t_lock);
+ s = simple_lock_irq(&tp->t_lock);
if (tp->t_inq.c_cc <= 0 ||
(tp->t_state & TS_CARR_ON) == 0) {
queue_delayed_reply(&tp->t_delayed_read, ior, char_read_done);
- simple_unlock(&tp->t_lock);
- splx(s);
+ simple_unlock_irq(s, &tp->t_lock);
return FALSE;
}
@@ -466,8 +455,7 @@ boolean_t char_read_done(
tp->t_state &= ~TS_RTS_DOWN;
}
- simple_unlock(&tp->t_lock);
- splx(s);
+ simple_unlock_irq(s, &tp->t_lock);
(void) ds_read_done(ior);
return TRUE;
@@ -555,10 +543,10 @@ tty_portdeath(
struct tty * tp,
const ipc_port_t port)
{
- spl_t spl = spltty();
+ spl_t spl;
boolean_t result;
- simple_lock(&tp->t_lock);
+ spl = simple_lock_irq(&tp->t_lock);
/*
* The queues may never have been initialized
@@ -575,8 +563,7 @@ tty_portdeath(
|| tty_queue_clean(&tp->t_delayed_open, port,
tty_close_open_reply);
}
- simple_unlock(&tp->t_lock);
- splx(spl);
+ simple_unlock_irq(spl, &tp->t_lock);
return result;
}
@@ -603,8 +590,7 @@ io_return_t tty_get_status(
if (*count < TTY_STATUS_COUNT)
return (D_INVALID_OPERATION);
- s = spltty();
- simple_lock(&tp->t_lock);
+ s = simple_lock_irq(&tp->t_lock);
tsp->tt_ispeed = tp->t_ispeed;
tsp->tt_ospeed = tp->t_ospeed;
@@ -613,8 +599,7 @@ io_return_t tty_get_status(
if (tp->t_state & TS_HUPCLS)
tsp->tt_flags |= TF_HUPCLS;
- simple_unlock(&tp->t_lock);
- splx(s);
+ simple_unlock_irq(s, &tp->t_lock);
*count = TTY_STATUS_COUNT;
break;
@@ -651,36 +636,30 @@ io_return_t tty_set_status(
if (flags == 0)
flags = D_READ | D_WRITE;
- s = spltty();
- simple_lock(&tp->t_lock);
+ s = simple_lock_irq(&tp->t_lock);
tty_flush(tp, flags);
- simple_unlock(&tp->t_lock);
- splx(s);
+ simple_unlock_irq(s, &tp->t_lock);
break;
}
case TTY_STOP:
/* stop output */
- s = spltty();
- simple_lock(&tp->t_lock);
+ s = simple_lock_irq(&tp->t_lock);
if ((tp->t_state & TS_TTSTOP) == 0) {
tp->t_state |= TS_TTSTOP;
(*tp->t_stop)(tp, 0);
}
- simple_unlock(&tp->t_lock);
- splx(s);
+ simple_unlock_irq(s, &tp->t_lock);
break;
case TTY_START:
/* start output */
- s = spltty();
- simple_lock(&tp->t_lock);
+ s = simple_lock_irq(&tp->t_lock);
if (tp->t_state & TS_TTSTOP) {
tp->t_state &= ~TS_TTSTOP;
tty_output(tp);
}
- simple_unlock(&tp->t_lock);
- splx(s);
+ simple_unlock_irq(s, &tp->t_lock);
break;
case TTY_STATUS:
@@ -701,8 +680,7 @@ io_return_t tty_set_status(
return D_INVALID_OPERATION;
}
- s = spltty();
- simple_lock(&tp->t_lock);
+ s = simple_lock_irq(&tp->t_lock);
tp->t_ispeed = tsp->tt_ispeed;
tp->t_ospeed = tsp->tt_ospeed;
@@ -711,8 +689,7 @@ io_return_t tty_set_status(
if (tsp->tt_flags & TF_HUPCLS)
tp->t_state |= TS_HUPCLS;
- simple_unlock(&tp->t_lock);
- splx(s);
+ simple_unlock_irq(s, &tp->t_lock);
break;
}
default:
@@ -820,14 +797,12 @@ void ttrstrt(
{
spl_t s;
- s = spltty();
- simple_lock(&tp->t_lock);
+ s = simple_lock_irq(&tp->t_lock);
tp->t_state &= ~TS_TIMEOUT;
ttstart (tp);
- simple_unlock(&tp->t_lock);
- splx(s);
+ simple_unlock_irq(s, &tp->t_lock);
}
/*
@@ -885,10 +860,10 @@ void tty_output(
static void ttypush(void * _tp)
{
struct tty *tp = _tp;
- spl_t s = spltty();
+ spl_t s;
int state;
- simple_lock(&tp->t_lock);
+ s = simple_lock_irq(&tp->t_lock);
/*
The pdma timeout has gone off.
@@ -919,8 +894,7 @@ static void ttypush(void * _tp)
tp->t_state = state & ~TS_MIN_TO_RCV;/* sanity */
}
- simple_unlock(&tp->t_lock);
- splx(s);
+ simple_unlock_irq(s, &tp->t_lock);
}
/*
diff --git a/device/tty.h b/device/tty.h
index b0f99cf5..3f8b2f63 100644
--- a/device/tty.h
+++ b/device/tty.h
@@ -43,7 +43,7 @@
#include <device/io_req.h>
struct tty {
- decl_simple_lock_data(,t_lock) /* Shall be taken at spltty only */
+ decl_simple_lock_irq_data(,t_lock) /* Shall be taken at spltty only */
struct cirbuf t_inq; /* input buffer */
struct cirbuf t_outq; /* output buffer */
char * t_addr; /* device pointer */
diff --git a/i386/i386at/kd.c b/i386/i386at/kd.c
index 2fa7b60d..e9b110bf 100644
--- a/i386/i386at/kd.c
+++ b/i386/i386at/kd.c
@@ -441,13 +441,12 @@ kdopen(
spl_t o_pri;
tp = &kd_tty;
- o_pri = spltty();
- simple_lock(&tp->t_lock);
+ o_pri = simple_lock_irq(&tp->t_lock);
if (!(tp->t_state & (TS_ISOPEN|TS_WOPEN))) {
/* XXX ttychars allocates memory */
- simple_unlock(&tp->t_lock);
+ simple_unlock_nocheck(&tp->t_lock.slock);
ttychars(tp);
- simple_lock(&tp->t_lock);
+ simple_lock_nocheck(&tp->t_lock.slock);
/*
* Special support for boot-time rc scripts, which don't
* stty the console.
@@ -459,8 +458,7 @@ kdopen(
kdinit();
}
tp->t_state |= TS_CARR_ON;
- simple_unlock(&tp->t_lock);
- splx(o_pri);
+ simple_unlock_irq(o_pri, &tp->t_lock);
return (char_open(dev, tp, flag, ior));
}
@@ -484,11 +482,10 @@ kdclose(dev_t dev, int flag)
tp = &kd_tty;
{
- spl_t s = spltty();
- simple_lock(&tp->t_lock);
+ spl_t s;
+ s = simple_lock_irq(&tp->t_lock);
ttyclose(tp);
- simple_unlock(&tp->t_lock);
- splx(s);
+ simple_unlock_irq(s, &tp->t_lock);
}
return;
diff --git a/xen/console.c b/xen/console.c
index 61de4390..fd3cf5dd 100644
--- a/xen/console.c
+++ b/xen/console.c
@@ -184,32 +184,29 @@ int hypcnopen(dev_t dev, int flag, io_req_t ior)
struct tty *tp = &hypcn_tty;
spl_t o_pri;
- o_pri = spltty();
- simple_lock(&tp->t_lock);
+ o_pri = simple_lock_irq(&tp->t_lock);
if (!(tp->t_state & (TS_ISOPEN|TS_WOPEN))) {
/* XXX ttychars allocates memory */
- simple_unlock(&tp->t_lock);
+ simple_unlock_nocheck(&tp->t_lock.slock);
ttychars(tp);
- simple_lock(&tp->t_lock);
+ simple_lock_nocheck(&tp->t_lock.slock);
tp->t_oproc = hypcnstart;
tp->t_stop = hypcnstop;
tp->t_ospeed = tp->t_ispeed = B9600;
tp->t_flags = ODDP|EVENP|ECHO|CRMOD|XTABS;
}
tp->t_state |= TS_CARR_ON;
- simple_unlock(&tp->t_lock);
- splx(o_pri);
+ simple_unlock_irq(o_pri, &tp->t_lock);
return (char_open(dev, tp, flag, ior));
}
void hypcnclose(dev_t dev, int flag)
{
struct tty *tp = &hypcn_tty;
- spl_t s = spltty();
- simple_lock(&tp->t_lock);
+ spl_t s;
+ s = simple_lock_irq(&tp->t_lock);
ttyclose(tp);
- simple_unlock(&tp->t_lock);
- splx(s);
+ simple_unlock_irq(s, &tp->t_lock);
}
int hypcnprobe(struct consdev *cp)