diff options
author | Peter Hurley <peter@hurleysoftware.com> | 2014-10-16 15:33:26 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-11-05 19:34:36 -0500 |
commit | 54e8e5fcaae109f0303f52efb24f29bfac79ca86 (patch) | |
tree | d0d4e39526384367fa195b61a5aa2de686170a7d | |
parent | 6054c16e80318d32ee084a0f5620a863ae8cea33 (diff) |
pty: Don't claim slave's ctrl_lock for master's packet mode
The slave's ctrl_lock serializes updates to the ctrl_status field
only, whereas the master's ctrl_lock serializes updates to the
packet mode enable (ie., the master does not have ctrl_status and
the slave does not have packet mode). Thus, claiming the slave's
ctrl_lock to access ->packet is useless.
Unlocked reads of ->packet are already smp-safe.
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Reviewed-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/tty/n_tty.c | 4 | ||||
-rw-r--r-- | drivers/tty/pty.c | 8 |
2 files changed, 6 insertions, 6 deletions
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c index d521058ee55a..cd725cc6e21e 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c | |||
@@ -351,13 +351,13 @@ static void n_tty_packet_mode_flush(struct tty_struct *tty) | |||
351 | { | 351 | { |
352 | unsigned long flags; | 352 | unsigned long flags; |
353 | 353 | ||
354 | spin_lock_irqsave(&tty->ctrl_lock, flags); | ||
355 | if (tty->link->packet) { | 354 | if (tty->link->packet) { |
355 | spin_lock_irqsave(&tty->ctrl_lock, flags); | ||
356 | tty->ctrl_status |= TIOCPKT_FLUSHREAD; | 356 | tty->ctrl_status |= TIOCPKT_FLUSHREAD; |
357 | spin_unlock_irqrestore(&tty->ctrl_lock, flags); | ||
357 | if (waitqueue_active(&tty->link->read_wait)) | 358 | if (waitqueue_active(&tty->link->read_wait)) |
358 | wake_up_interruptible(&tty->link->read_wait); | 359 | wake_up_interruptible(&tty->link->read_wait); |
359 | } | 360 | } |
360 | spin_unlock_irqrestore(&tty->ctrl_lock, flags); | ||
361 | } | 361 | } |
362 | 362 | ||
363 | /** | 363 | /** |
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index 29b5eeb01856..e554393d5551 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c | |||
@@ -339,26 +339,26 @@ static void pty_start(struct tty_struct *tty) | |||
339 | { | 339 | { |
340 | unsigned long flags; | 340 | unsigned long flags; |
341 | 341 | ||
342 | spin_lock_irqsave(&tty->ctrl_lock, flags); | ||
343 | if (tty->link && tty->link->packet) { | 342 | if (tty->link && tty->link->packet) { |
343 | spin_lock_irqsave(&tty->ctrl_lock, flags); | ||
344 | tty->ctrl_status &= ~TIOCPKT_STOP; | 344 | tty->ctrl_status &= ~TIOCPKT_STOP; |
345 | tty->ctrl_status |= TIOCPKT_START; | 345 | tty->ctrl_status |= TIOCPKT_START; |
346 | spin_unlock_irqrestore(&tty->ctrl_lock, flags); | ||
346 | wake_up_interruptible_poll(&tty->link->read_wait, POLLIN); | 347 | wake_up_interruptible_poll(&tty->link->read_wait, POLLIN); |
347 | } | 348 | } |
348 | spin_unlock_irqrestore(&tty->ctrl_lock, flags); | ||
349 | } | 349 | } |
350 | 350 | ||
351 | static void pty_stop(struct tty_struct *tty) | 351 | static void pty_stop(struct tty_struct *tty) |
352 | { | 352 | { |
353 | unsigned long flags; | 353 | unsigned long flags; |
354 | 354 | ||
355 | spin_lock_irqsave(&tty->ctrl_lock, flags); | ||
356 | if (tty->link && tty->link->packet) { | 355 | if (tty->link && tty->link->packet) { |
356 | spin_lock_irqsave(&tty->ctrl_lock, flags); | ||
357 | tty->ctrl_status &= ~TIOCPKT_START; | 357 | tty->ctrl_status &= ~TIOCPKT_START; |
358 | tty->ctrl_status |= TIOCPKT_STOP; | 358 | tty->ctrl_status |= TIOCPKT_STOP; |
359 | spin_unlock_irqrestore(&tty->ctrl_lock, flags); | ||
359 | wake_up_interruptible_poll(&tty->link->read_wait, POLLIN); | 360 | wake_up_interruptible_poll(&tty->link->read_wait, POLLIN); |
360 | } | 361 | } |
361 | spin_unlock_irqrestore(&tty->ctrl_lock, flags); | ||
362 | } | 362 | } |
363 | 363 | ||
364 | /** | 364 | /** |