[PATCH 07/13] tty: give up BTM in acquire_console_sem

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

This was not caught in the initial sweep through
the TTY layer, nor by lockdep, which does not know
about classic semaphores.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 kernel/printk.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/kernel/printk.c b/kernel/printk.c
index 75077ad..30669a3 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -970,7 +970,16 @@ void resume_console(void)
 void acquire_console_sem(void)
 {
 	BUG_ON(in_interrupt());
-	down(&console_sem);
+	if (down_trylock(&console_sem)) {
+		/*
+		 * we may get called here with the BTM held.
+		 * it's not clear whether we get the BTM while
+		 * holding console_sem, need to check.
+		 */
+		release_tty_lock(current);
+		down(&console_sem);
+		reacquire_tty_lock(current);
+	}
 	if (console_suspended)
 		return;
 	console_locked = 1;
-- 
1.7.0.4

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

Messages in current thread:
[PATCH 07/13] tty: give up BTM in acquire_console_sem, Arnd Bergmann, (Tue May 4, 3:33 pm)