diff options
author | Michal Ostrowski <mostrows@watson.ibm.com> | 2006-02-18 09:29:59 -0500 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2006-02-23 19:36:40 -0500 |
commit | fb5c594c2acc441f0d2d8f457484a0e0e9285db3 (patch) | |
tree | 0465b7b5fb518f21f6d4689e027f0f04bb3ebe35 /drivers/char/hvc_console.c | |
parent | 4558f417f49595337b7e9cc3e92bc0856c588ac1 (diff) |
[PATCH] Fix race condition in hvc console.
tty_schedule_flip() would schedule a thread that would call flush_to_ldisc().
If tty_buffer_request_room() gets called prior to that thread running --
which is likely in this loop in hvc_poll(), it would set the active flag
in the tty buffer and consequently flush_to_ldisc() would ignore it.
The result is that input on the hvc console is not processed.
This fix calls tty_flip_buffer_push (and flags the tty as
"low_latency"). The push to the ldisc thus happens synchronously.
Signed-off-by: Michal Ostrowski <mostrows@watson.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'drivers/char/hvc_console.c')
-rw-r--r-- | drivers/char/hvc_console.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c index 1994a92d4733..f65b2e14a485 100644 --- a/drivers/char/hvc_console.c +++ b/drivers/char/hvc_console.c | |||
@@ -335,6 +335,8 @@ static int hvc_open(struct tty_struct *tty, struct file * filp) | |||
335 | } /* else count == 0 */ | 335 | } /* else count == 0 */ |
336 | 336 | ||
337 | tty->driver_data = hp; | 337 | tty->driver_data = hp; |
338 | tty->low_latency = 1; /* Makes flushes to ldisc synchronous. */ | ||
339 | |||
338 | hp->tty = tty; | 340 | hp->tty = tty; |
339 | /* Save for request_irq outside of spin_lock. */ | 341 | /* Save for request_irq outside of spin_lock. */ |
340 | irq = hp->irq; | 342 | irq = hp->irq; |
@@ -633,9 +635,6 @@ static int hvc_poll(struct hvc_struct *hp) | |||
633 | tty_insert_flip_char(tty, buf[i], 0); | 635 | tty_insert_flip_char(tty, buf[i], 0); |
634 | } | 636 | } |
635 | 637 | ||
636 | if (count) | ||
637 | tty_schedule_flip(tty); | ||
638 | |||
639 | /* | 638 | /* |
640 | * Account for the total amount read in one loop, and if above | 639 | * Account for the total amount read in one loop, and if above |
641 | * 64 bytes, we do a quick schedule loop to let the tty grok | 640 | * 64 bytes, we do a quick schedule loop to let the tty grok |
@@ -656,6 +655,9 @@ static int hvc_poll(struct hvc_struct *hp) | |||
656 | bail: | 655 | bail: |
657 | spin_unlock_irqrestore(&hp->lock, flags); | 656 | spin_unlock_irqrestore(&hp->lock, flags); |
658 | 657 | ||
658 | if (read_total) | ||
659 | tty_flip_buffer_push(tty); | ||
660 | |||
659 | return poll_mask; | 661 | return poll_mask; |
660 | } | 662 | } |
661 | 663 | ||