diff options
author | Peter Hurley <peter@hurleysoftware.com> | 2015-01-17 15:42:04 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-02-02 13:11:27 -0500 |
commit | 3abf87cd3e70009ed70a7f28c2914888a7e27332 (patch) | |
tree | c1c57a8caab29cd953b7373c5a19d0a4f0494a14 | |
parent | fb5ef9e7da39968fec6d6f37f20a23d23740c75e (diff) |
tty: Make lock subclasses available for other tty locks
Besides nested legacy_mutex locking which is required on pty pair
teardown, other nested pty operations require lock subclassing.
Move lock subclass definition to tty interface header, include/linux/tty.h,
and document its use.
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/tty/tty_mutex.c | 12 | ||||
-rw-r--r-- | include/linux/tty.h | 17 |
2 files changed, 18 insertions, 11 deletions
diff --git a/drivers/tty/tty_mutex.c b/drivers/tty/tty_mutex.c index a872389dc0bc..0efcf713b756 100644 --- a/drivers/tty/tty_mutex.c +++ b/drivers/tty/tty_mutex.c | |||
@@ -4,18 +4,8 @@ | |||
4 | #include <linux/semaphore.h> | 4 | #include <linux/semaphore.h> |
5 | #include <linux/sched.h> | 5 | #include <linux/sched.h> |
6 | 6 | ||
7 | /* | ||
8 | * Nested tty locks are necessary for releasing pty pairs. | ||
9 | * The stable lock order is master pty first, then slave pty. | ||
10 | */ | ||
11 | |||
12 | /* Legacy tty mutex glue */ | 7 | /* Legacy tty mutex glue */ |
13 | 8 | ||
14 | enum { | ||
15 | TTY_MUTEX_NORMAL, | ||
16 | TTY_MUTEX_SLAVE, | ||
17 | }; | ||
18 | |||
19 | /* | 9 | /* |
20 | * Getting the big tty mutex. | 10 | * Getting the big tty mutex. |
21 | */ | 11 | */ |
@@ -58,5 +48,5 @@ void __lockfunc tty_unlock_slave(struct tty_struct *tty) | |||
58 | 48 | ||
59 | void tty_set_lock_subclass(struct tty_struct *tty) | 49 | void tty_set_lock_subclass(struct tty_struct *tty) |
60 | { | 50 | { |
61 | lockdep_set_subclass(&tty->legacy_mutex, TTY_MUTEX_SLAVE); | 51 | lockdep_set_subclass(&tty->legacy_mutex, TTY_LOCK_SLAVE); |
62 | } | 52 | } |
diff --git a/include/linux/tty.h b/include/linux/tty.h index 7d66ae508e5c..849659908f23 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h | |||
@@ -14,6 +14,23 @@ | |||
14 | #include <linux/llist.h> | 14 | #include <linux/llist.h> |
15 | 15 | ||
16 | 16 | ||
17 | /* | ||
18 | * Lock subclasses for tty locks | ||
19 | * | ||
20 | * TTY_LOCK_NORMAL is for normal ttys and master ptys. | ||
21 | * TTY_LOCK_SLAVE is for slave ptys only. | ||
22 | * | ||
23 | * Lock subclasses are necessary for handling nested locking with pty pairs. | ||
24 | * tty locks which use nested locking: | ||
25 | * | ||
26 | * legacy_mutex - Nested tty locks are necessary for releasing pty pairs. | ||
27 | * The stable lock order is master pty first, then slave pty. | ||
28 | */ | ||
29 | |||
30 | enum { | ||
31 | TTY_LOCK_NORMAL = 0, | ||
32 | TTY_LOCK_SLAVE, | ||
33 | }; | ||
17 | 34 | ||
18 | /* | 35 | /* |
19 | * (Note: the *_driver.minor_start values 1, 64, 128, 192 are | 36 | * (Note: the *_driver.minor_start values 1, 64, 128, 192 are |