mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Michal Ostrowski <mostrows@watson.ibm.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] Fix race condition in hvc console.
Date: Sat, 18 Feb 2006 09:29:59 -0500	[thread overview]
Message-ID: <E1FAT5z-0004nt-V8@heater.watson.ibm.com> (raw)


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>

---

 drivers/char/hvc_console.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

1d719e2972f0c02d62a428aa84ca60793ad79666
diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c
index 1994a92..67f368f 100644
--- a/drivers/char/hvc_console.c
+++ b/drivers/char/hvc_console.c
@@ -335,6 +335,8 @@ static int hvc_open(struct tty_struct *t
 	} /* 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 *h
 			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,10 @@ static int hvc_poll(struct hvc_struct *h
  bail:
 	spin_unlock_irqrestore(&hp->lock, flags);
 
+	if (read_total) {
+		tty_flip_buffer_push(tty);
+	}
+	
 	return poll_mask;
 }
 
-- 
1.1.4.g0b63-dirty


                 reply	other threads:[~2006-02-18 14:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1FAT5z-0004nt-V8@heater.watson.ibm.com \
    --to=mostrows@watson.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®