From: Milton Miller <miltonm@bga.com>
Date: Thu, 8 Jan 2009 02:14:18 +0000 (+0000)
Subject: hvc_console: Change an mb() to smp_mb() and add some comments
X-Git-Tag: firefly_0821_release~15862^2~9
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=9fef3d2d15ae8ca24e4a145f2e189eea145d18c2;p=firefly-linux-kernel-4.4.55.git

hvc_console: Change an mb() to smp_mb() and add some comments

I remember some history on this barrier.  There was a race between
open via /dev/console and the tty being fully setup.  Its also why
there is a temporary variable and the global is assigned at the end
of the function.

Signed-off-by: Milton Miller <miltonm@bga.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---

diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c
index 5a8a4c28c867..f2685b747fb9 100644
--- a/drivers/char/hvc_console.c
+++ b/drivers/char/hvc_console.c
@@ -876,8 +876,11 @@ static int hvc_init(void)
 		goto stop_thread;
 	}
 
-	/* FIXME: This mb() seems completely random.  Remove it. */
-	mb();
+	/*
+	 * Make sure tty is fully registered before allowing it to be
+	 * found by hvc_console_device.
+	 */
+	smp_mb();
 	hvc_driver = drv;
 	return 0;