[PATCH 02/13] tty: make atomic_write_lock release tty_lock

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Arnd Bergmann
Date: Tuesday, May 4, 2010 - 3:33 pm

atomic_write_lock never nests below BTM as far
as I can tell, so this can eventually get
reverted again unless it triggers bugs.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/char/tty_io.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 3bf2c75..8331dd3 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -912,10 +912,15 @@ void tty_write_unlock(struct tty_struct *tty)
 
 int tty_write_lock(struct tty_struct *tty, int ndelay)
 {
+	/*
+	 * code inspection has shown that this is never called
+	 * with the BTM held. Make sure this stays that way.
+	 */
+	WARN_ON_ONCE(tty_locked());
 	if (!mutex_trylock(&tty->atomic_write_lock)) {
 		if (ndelay)
 			return -EAGAIN;
-		if (mutex_lock_interruptible(&tty->atomic_write_lock))
+		if (mutex_lock_interruptible_tty(&tty->atomic_write_lock))
 			return -ERESTARTSYS;
 	}
 	return 0;
@@ -1024,7 +1029,7 @@ out:
 void tty_write_message(struct tty_struct *tty, char *msg)
 {
 	if (tty) {
-		mutex_lock(&tty->atomic_write_lock);
+		mutex_lock_tty_off(&tty->atomic_write_lock);
 		tty_lock();
 		if (tty->ops->write && !test_bit(TTY_CLOSING, &tty->flags)) {
 			tty_unlock();
-- 
1.7.0.4

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH v2 00/13] BKL conversion in tty layer, Arnd Bergmann, (Tue May 4, 3:33 pm)
[PATCH 01/13] tty: replace BKL with a new tty_lock, Arnd Bergmann, (Tue May 4, 3:33 pm)
[PATCH 02/13] tty: make atomic_write_lock release tty_lock, Arnd Bergmann, (Tue May 4, 3:33 pm)
[PATCH 05/13] tty: make ldisc_mutex nest under tty_lock, Arnd Bergmann, (Tue May 4, 3:33 pm)
[PATCH 10/13] tty: untangle locking of wait_until_sent, Arnd Bergmann, (Tue May 4, 3:33 pm)
[PATCH 11/13] tty: remove tty_lock_nested, Arnd Bergmann, (Tue May 4, 3:33 pm)
Re: [PATCH v2 00/13] BKL conversion in tty layer, Alan Cox, (Wed May 5, 3:52 am)
Re: [PATCH v2 00/13] BKL conversion in tty layer, Arnd Bergmann, (Wed May 5, 5:24 am)