Embedded Linux development
 help / color / mirror / Atom feed
From: VomLehn <dvomlehn@cisco.com>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: Linux Embedded Mailing List <linux-embedded@vger.kernel.org>
Subject: [PATCH] Wait for console to become available
Date: Tue, 14 Apr 2009 16:28:36 -0700	[thread overview]
Message-ID: <20090414232835.GA20307@cuplxvomd02.corp.sa.net> (raw)

Work to improve boot times appears to be successful enough that a race
condition has been created between the open of /dev/console in init_post
and USB serial device initialization. Embedded systems are probably the
primary users of USB serial devices, though I can certainly image blade
servers using them, as well.

This patch works for me and, though it's possible this is all that needs
to be done, I think it's likely there are some other changes required,
as well.

Signed-off-by: David VomLehn <dvomlehn@cisco>
---
 kernel/printk.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/kernel/printk.c b/kernel/printk.c
index e3602d0..39f554a 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -104,6 +104,10 @@ static unsigned log_start;	/* Index into log_buf: next char to be read by syslog
 static unsigned con_start;	/* Index into log_buf: next char to be sent to consoles */
 static unsigned log_end;	/* Index into log_buf: most-recently-written-char + 1 */
 
+/* Definitions for waiting until a console is registered */
+#define MAX_CONSOLE_WAIT	msecs_to_jiffies(2000)
+static DECLARE_WAIT_QUEUE_HEAD(console_wait);
+
 /*
  *	Array of consoles built from command line options (console=)
  */
@@ -1062,6 +1066,10 @@ struct tty_driver *console_device(int *index)
 	struct console *c;
 	struct tty_driver *driver = NULL;
 
+	/* Wait a while for a console to show up. If one doesn't show up
+	 * for too long, we'll just continue without a console. */
+	wait_event_timeout(console_wait, console_drivers, MAX_CONSOLE_WAIT);
+
 	acquire_console_sem();
 	for (c = console_drivers; c != NULL; c = c->next) {
 		if (!c->device)
@@ -1211,6 +1219,7 @@ void register_console(struct console *console)
 		spin_unlock_irqrestore(&logbuf_lock, flags);
 	}
 	release_console_sem();
+	wake_up_all(&console_wait);
 }
 EXPORT_SYMBOL(register_console);
 

                 reply	other threads:[~2009-04-14 23: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=20090414232835.GA20307@cuplxvomd02.corp.sa.net \
    --to=dvomlehn@cisco.com \
    --cc=linux-embedded@vger.kernel.org \
    --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