From: Michal Ostrowski Date: Sat, 18 Feb 2006 14:29:59 +0000 (-0500) Subject: [PATCH] Fix race condition in hvc console. X-Git-Tag: accepted/tizen/common/20141203.182822~39733^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fb5c594c2acc441f0d2d8f457484a0e0e9285db3;p=platform%2Fkernel%2Flinux-arm64.git [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 Signed-off-by: Paul Mackerras --- diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c index 1994a92..f65b2e1 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) } /* else count == 0 */ tty->driver_data = hp; + tty->low_latency = 1; /* Makes flushes to ldisc synchronous. */ + hp->tty = tty; /* Save for request_irq outside of spin_lock. */ irq = hp->irq; @@ -633,9 +635,6 @@ static int hvc_poll(struct hvc_struct *hp) tty_insert_flip_char(tty, buf[i], 0); } - if (count) - tty_schedule_flip(tty); - /* * Account for the total amount read in one loop, and if above * 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) bail: spin_unlock_irqrestore(&hp->lock, flags); + if (read_total) + tty_flip_buffer_push(tty); + return poll_mask; }