From: Arnd Bergmann <arnd@arndb.de>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>, Greg KH <gregkh@suse.de>,
Frederic Weisbecker <fweisbec@gmail.com>,
Thomas Gleixner <tglx@linutronix.de>,
Andrew Morton <akpm@linux-foundation.org>,
John Kacur <jkacur@redhat.com>, Al Viro <viro@zeniv.linux.org.uk>,
Ingo Molnar <mingo@elte.hu>, Arnd Bergmann <arnd@arndb.de>
Subject: [RFC 3/9] tty: make tty_port->mutex nest under tty_lock
Date: Tue, 30 Mar 2010 22:56:14 +0200 [thread overview]
Message-ID: <1269982580-9361-4-git-send-email-arnd@arndb.de> (raw)
In-Reply-To: <1269982580-9361-1-git-send-email-arnd@arndb.de>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/char/mxser.c | 10 +++++-----
drivers/char/tty_port.c | 4 ++--
drivers/serial/serial_core.c | 32 ++++++++++++++++----------------
3 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c
index e0c5d2a..25ff7e6 100644
--- a/drivers/char/mxser.c
+++ b/drivers/char/mxser.c
@@ -1078,7 +1078,7 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)
return;
if (tty_port_close_start(port, tty, filp) == 0)
return;
- mutex_lock(&port->mutex);
+ mutex_lock_tty(&port->mutex);
mxser_close_port(port);
mxser_flush_buffer(tty);
mxser_shutdown_port(port);
@@ -1512,7 +1512,7 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
port = &ip->port;
memset(&ms, 0, sizeof(ms));
- mutex_lock(&port->mutex);
+ mutex_lock_tty_off(&port->mutex);
if (!ip->ioaddr)
goto copy;
@@ -1558,7 +1558,7 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
ip = &mxser_boards[i].ports[j];
port = &ip->port;
- mutex_lock(&port->mutex);
+ mutex_lock_tty_off(&port->mutex);
if (!ip->ioaddr) {
mutex_unlock(&port->mutex);
continue;
@@ -1705,12 +1705,12 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
switch (cmd) {
case TIOCGSERIAL:
- mutex_lock(&port->mutex);
+ mutex_lock_tty_off(&port->mutex);
retval = mxser_get_serial_info(tty, argp);
mutex_unlock(&port->mutex);
return retval;
case TIOCSSERIAL:
- mutex_lock(&port->mutex);
+ mutex_lock_tty_off(&port->mutex);
retval = mxser_set_serial_info(tty, argp);
mutex_unlock(&port->mutex);
return retval;
diff --git a/drivers/char/tty_port.c b/drivers/char/tty_port.c
index a3bd1d0..5ad1446 100644
--- a/drivers/char/tty_port.c
+++ b/drivers/char/tty_port.c
@@ -118,7 +118,7 @@ EXPORT_SYMBOL(tty_port_tty_set);
static void tty_port_shutdown(struct tty_port *port)
{
- mutex_lock(&port->mutex);
+ mutex_lock_tty(&port->mutex);
if (port->ops->shutdown && !port->console &&
test_and_clear_bit(ASYNCB_INITIALIZED, &port->flags))
port->ops->shutdown(port);
@@ -424,7 +424,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
* port mutex.
*/
- mutex_lock(&port->mutex);
+ mutex_lock_tty(&port->mutex);
if (!test_bit(ASYNCB_INITIALIZED, &port->flags)) {
clear_bit(TTY_IO_ERROR, &tty->flags);
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
index 1bc580b..81be0c9 100644
--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -647,7 +647,7 @@ static int uart_get_info(struct uart_state *state,
/* Ensure the state we copy is consistent and no hardware changes
occur as we go */
- mutex_lock(&port->mutex);
+ mutex_lock_tty_off(&port->mutex);
tmp.type = uport->type;
tmp.line = uport->line;
@@ -706,7 +706,7 @@ static int uart_set_info(struct uart_state *state,
* module insertion/removal doesn't change anything
* under us.
*/
- mutex_lock(&port->mutex);
+ mutex_lock_tty_off(&port->mutex);
change_irq = !(uport->flags & UPF_FIXED_PORT)
&& new_serial.irq != uport->irq;
@@ -913,7 +913,7 @@ static int uart_tiocmget(struct tty_struct *tty, struct file *file)
struct uart_port *uport = state->uart_port;
int result = -EIO;
- mutex_lock(&port->mutex);
+ mutex_lock_tty_off(&port->mutex);
if ((!file || !tty_hung_up_p(file)) &&
!(tty->flags & (1 << TTY_IO_ERROR))) {
result = uport->mctrl;
@@ -936,7 +936,7 @@ uart_tiocmset(struct tty_struct *tty, struct file *file,
struct tty_port *port = &state->port;
int ret = -EIO;
- mutex_lock(&port->mutex);
+ mutex_lock_tty_off(&port->mutex);
if ((!file || !tty_hung_up_p(file)) &&
!(tty->flags & (1 << TTY_IO_ERROR))) {
uart_update_mctrl(uport, set, clear);
@@ -952,7 +952,7 @@ static int uart_break_ctl(struct tty_struct *tty, int break_state)
struct tty_port *port = &state->port;
struct uart_port *uport = state->uart_port;
- mutex_lock(&port->mutex);
+ mutex_lock_tty_off(&port->mutex);
if (uport->type != PORT_UNKNOWN)
uport->ops->break_ctl(uport, break_state);
@@ -975,7 +975,7 @@ static int uart_do_autoconfig(struct uart_state *state)
* changing, and hence any extra opens of the port while
* we're auto-configuring.
*/
- if (mutex_lock_interruptible(&port->mutex))
+ if (mutex_lock_interruptible_tty(&port->mutex))
return -ERESTARTSYS;
ret = -EBUSY;
@@ -1159,7 +1159,7 @@ uart_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd,
if (ret != -ENOIOCTLCMD)
goto out;
- mutex_lock(&port->mutex);
+ mutex_lock_tty_off(&port->mutex);
if (tty_hung_up_p(filp)) {
ret = -EIO;
@@ -1283,7 +1283,7 @@ static void uart_close(struct tty_struct *tty, struct file *filp)
pr_debug("uart_close(%d) called\n", uport->line);
- mutex_lock(&port->mutex);
+ mutex_lock_tty(&port->mutex);
if (tty_hung_up_p(filp))
goto done;
@@ -1433,7 +1433,7 @@ static void uart_hangup(struct tty_struct *tty)
BUG_ON(!tty_locked());
pr_debug("uart_hangup(%d)\n", state->uart_port->line);
- mutex_lock(&port->mutex);
+ mutex_lock_tty(&port->mutex);
if (port->flags & ASYNC_NORMAL_ACTIVE) {
uart_flush_buffer(tty);
uart_shutdown(state);
@@ -1547,7 +1547,7 @@ uart_block_til_ready(struct file *filp, struct uart_state *state)
mutex_unlock(&port->mutex);
schedule();
- mutex_lock(&port->mutex);
+ mutex_lock_tty(&port->mutex);
if (signal_pending(current))
break;
@@ -1575,7 +1575,7 @@ static struct uart_state *uart_get(struct uart_driver *drv, int line)
state = drv->state + line;
port = &state->port;
- if (mutex_lock_interruptible(&port->mutex)) {
+ if (mutex_lock_interruptible_tty(&port->mutex)) {
ret = -ERESTARTSYS;
goto err;
}
@@ -1732,7 +1732,7 @@ static void uart_line_info(struct seq_file *m, struct uart_driver *drv, int i)
}
if (capable(CAP_SYS_ADMIN)) {
- mutex_lock(&port->mutex);
+ mutex_lock_tty_off(&port->mutex);
pm_state = state->pm_state;
if (pm_state)
uart_change_pm(state, 0);
@@ -2011,7 +2011,7 @@ int uart_suspend_port(struct uart_driver *drv, struct uart_port *uport)
struct device *tty_dev;
struct uart_match match = {uport, drv};
- mutex_lock(&port->mutex);
+ mutex_lock_tty(&port->mutex);
tty_dev = device_find_child(uport->dev, &match, serial_match_port);
if (device_may_wakeup(tty_dev)) {
@@ -2077,7 +2077,7 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *uport)
struct uart_match match = {uport, drv};
struct ktermios termios;
- mutex_lock(&port->mutex);
+ mutex_lock_tty(&port->mutex);
tty_dev = device_find_child(uport->dev, &match, serial_match_port);
if (!uport->suspended && device_may_wakeup(tty_dev)) {
@@ -2436,7 +2436,7 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *uport)
port = &state->port;
mutex_lock(&port_mutex);
- mutex_lock(&port->mutex);
+ mutex_lock_tty(&port->mutex);
if (state->uart_port) {
ret = -EINVAL;
goto out;
@@ -2509,7 +2509,7 @@ int uart_remove_one_port(struct uart_driver *drv, struct uart_port *uport)
* Mark the port "dead" - this prevents any opens from
* succeeding while we shut down the port.
*/
- mutex_lock(&port->mutex);
+ mutex_lock_tty(&port->mutex);
uport->flags |= UPF_DEAD;
mutex_unlock(&port->mutex);
--
1.7.0
next prev parent reply other threads:[~2010-03-30 20:56 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-30 20:56 [RFC 0/9] BKL conversion in TTY drivers Arnd Bergmann
2010-03-30 20:56 ` [RFC 1/9] tty: replace BKL with a new tty_lock Arnd Bergmann
2010-03-30 22:23 ` Frederic Weisbecker
2010-03-30 20:56 ` [RFC 2/9] tty: make atomic_write_lock release tty_lock Arnd Bergmann
2010-03-30 20:56 ` Arnd Bergmann [this message]
2010-03-30 20:56 ` [RFC 4/9] tty: make termios mutex nest under tty_lock Arnd Bergmann
2010-03-30 20:56 ` [RFC 5/9] tty: make ldisc_mutex " Arnd Bergmann
2010-03-30 20:56 ` [RFC 6/9] tty: never hold tty_lock() while getting tty_mutex Arnd Bergmann
2010-03-30 20:56 ` [RFC 7/9] ppp: use big tty mutex Arnd Bergmann
2010-03-31 4:37 ` Américo Wang
2010-03-31 7:39 ` Arnd Bergmann
2010-03-30 20:56 ` [RFC 8/9] tty: release tty lock when blocking Arnd Bergmann
2010-03-30 20:56 ` [RFC 9/9] tty: implement BTM as mutex instead of BKL Arnd Bergmann
2010-03-30 22:50 ` Frederic Weisbecker
2010-03-30 22:37 ` [RFC 0/9] BKL conversion in TTY drivers Alan Cox
2010-03-31 7:57 ` Arnd Bergmann
2010-03-31 10:02 ` Alan Cox
2010-04-01 12:51 ` Arnd Bergmann
2010-04-01 14:17 ` Alan Cox
2010-04-01 15:24 ` Greg KH
2010-04-01 19:10 ` Arnd Bergmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1269982580-9361-4-git-send-email-arnd@arndb.de \
--to=arnd@arndb.de \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=fweisbec@gmail.com \
--cc=gregkh@suse.de \
--cc=jkacur@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®