* [PATCH 1/2] Add a new helper for sleepable BTM acquirements which is used by tty_write_message()
@ 2012-06-30 9:39 Jeff Liu
2012-06-30 12:35 ` Alan Cox
0 siblings, 1 reply; 2+ messages in thread
From: Jeff Liu @ 2012-06-30 9:39 UTC (permalink / raw)
To: linux-serial
Cc: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, gregkh,
Jan Kara, Ted Ts'o
This helper only used by tty_write_message(), it will sleep until BTM lock acquired.
Signed-off-by: Jie Liu <jeff.liu@oracle.com>
---
drivers/tty/tty_mutex.c | 13 +++++++++++++
include/linux/tty.h | 1 +
2 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/drivers/tty/tty_mutex.c b/drivers/tty/tty_mutex.c
index 9ff986c..e638636 100644
--- a/drivers/tty/tty_mutex.c
+++ b/drivers/tty/tty_mutex.c
@@ -30,3 +30,16 @@ void __lockfunc tty_unlock(void)
mutex_unlock(&big_tty_mutex);
}
EXPORT_SYMBOL(tty_unlock);
+
+/*
+ * Wait until getting the big tty mutex.
+ * This function only used by tty_write_message().
+ */
+void __lockfunc tty_lock_wait(void)
+{
+ while (!mutex_trylock(&big_tty_mutex)) {
+ set_current_state(TASK_UNINTERRUPTIBLE);
+ schedule();
+ }
+}
+EXPORT_SYMBOL(tty_lock_wait);
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 9f47ab5..5e01e0b 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -607,6 +607,7 @@ extern long vt_compat_ioctl(struct tty_struct *tty,
/* functions for preparation of BKL removal */
extern void __lockfunc tty_lock(void) __acquires(tty_lock);
extern void __lockfunc tty_unlock(void) __releases(tty_lock);
+extern void __lockfunc tty_lock_wait(void) __acquires(tty_lock);
/*
* this shall be called only from where BTM is held (like close)
--
1.7.9
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/2] Add a new helper for sleepable BTM acquirements which is used by tty_write_message()
2012-06-30 9:39 [PATCH 1/2] Add a new helper for sleepable BTM acquirements which is used by tty_write_message() Jeff Liu
@ 2012-06-30 12:35 ` Alan Cox
0 siblings, 0 replies; 2+ messages in thread
From: Alan Cox @ 2012-06-30 12:35 UTC (permalink / raw)
To: jeff.liu
Cc: linux-serial, linux-fsdevel@vger.kernel.org,
linux-ext4@vger.kernel.org, gregkh, Jan Kara, Ted Ts'o
On Sat, 30 Jun 2012 17:39:58 +0800
Jeff Liu <jeff.liu@oracle.com> wrote:
> This helper only used by tty_write_message(), it will sleep until BTM lock acquired.
This makes no sense at all. mutexes already sleep. Your code is also
wrong for real time processes.
So NAK.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-06-30 12:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-30 9:39 [PATCH 1/2] Add a new helper for sleepable BTM acquirements which is used by tty_write_message() Jeff Liu
2012-06-30 12:35 ` Alan Cox
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox