@@ -3145,6 +3145,13 @@ static int serial_core_add_one_port(struct uart_driver *drv, struct uart_port *u
state->uart_port = uport;
uport->state = state;
+ /*
+ * If this port is in use as a console then the spinlock is already
+ * initialised.
+ */
+ if (!uart_console_registered(uport))
+ uart_port_spin_lock_init(uport);
+
state->pm_state = UART_PM_STATE_UNDEFINED;
uart_port_set_cons(uport, drv->cons);
uport->minor = drv->tty_driver->minor_start + uport->line;
@@ -3155,13 +3162,6 @@ static int serial_core_add_one_port(struct uart_driver *drv, struct uart_port *u
goto out;
}
- /*
- * If this port is in use as a console then the spinlock is already
- * initialised.
- */
- if (!uart_console_registered(uport))
- uart_port_spin_lock_init(uport);
-
if (uport->cons && uport->dev)
of_console_check(uport->dev->of_node, uport->cons->name, uport->line);
@@ -424,9 +424,8 @@ struct console {
* migrate_disable().
*
* The flags argument is provided as a convenience to the driver. It
- * will be passed again to device_unlock() when printing is completed
- * (for example, if spin_lock_irqsave() was used). It can be ignored
- * if the driver does not need it.
+ * will be passed again to device_unlock(). It can be ignored if the
+ * driver does not need it.
*/
void (*device_lock)(struct console *con, unsigned long *flags);
@@ -1392,7 +1392,7 @@ static void __nbcon_atomic_flush_pending(u64 stop_seq, bool allow_unsafe_takeove
* lock for uart consoles). Therefore IRQs must be
* disabled to avoid being interrupted and then
* calling into a driver that will deadlock trying
- * acquire console ownership.
+ * to acquire console ownership.
*/
local_irq_save(irq_flags);
@@ -476,7 +476,7 @@ static DEFINE_MUTEX(syslog_lock);
/*
* Specifies if a legacy console is registered. If legacy consoles are
- * present, it is necessary to perform the console_lock/console_unlock dance
+ * present, it is necessary to perform the console lock/unlock dance
* whenever console flushing should occur.
*/
bool have_legacy_console;
@@ -2354,8 +2354,10 @@ void printk_legacy_allow_panic_sync(void)
{
legacy_allow_panic_sync = true;
- if (printing_via_unlock && !in_nmi() && console_trylock())
- console_unlock();
+ if (printing_via_unlock && !in_nmi()) {
+ if (console_trylock())
+ console_unlock();
+ }
}
asmlinkage int vprintk_emit(int facility, int level,
@@ -2413,10 +2415,9 @@ asmlinkage int vprintk_emit(int facility, int level,
* - During shutdown, since the printing threads may not get
* a chance to print the final messages.
*
- * Note that if boot consoles are registered, the
- * console_lock/console_unlock dance must be relied upon
- * instead because nbcon consoles cannot print simultaneously
- * with boot consoles.
+ * Note that if boot consoles are registered, the console
+ * lock/unlock dance must be relied upon instead because nbcon
+ * consoles cannot print simultaneously with boot consoles.
*/
if (is_panic_context ||
!printk_threads_enabled ||
@@ -4174,7 +4175,6 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre
u64 last_diff = 0;
u64 printk_seq;
short flags;
- bool locked;
int cookie;
u64 diff;
u64 seq;
@@ -4196,11 +4196,18 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre
for (;;) {
unsigned long begin_jiffies;
unsigned long slept_jiffies;
+ bool use_console_lock = printing_via_unlock;
+
+ /*
+ * Ensure the compiler does not optimize @use_console_lock to
+ * be @printing_via_unlock since the latter can change at any
+ * time.
+ */
+ barrier();
- locked = false;
diff = 0;
- if (printing_via_unlock) {
+ if (use_console_lock) {
/*
* Hold the console_lock to guarantee safe access to
* console->seq. Releasing console_lock flushes more
@@ -4208,16 +4215,8 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre
* usable consoles.
*/
console_lock();
- locked = true;
}
- /*
- * Ensure the compiler does not optimize @locked to be
- * @printing_via_unlock since the latter can change at any
- * time.
- */
- barrier();
-
cookie = console_srcu_read_lock();
for_each_console_srcu(c) {
if (con && con != c)
@@ -4238,7 +4237,7 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre
if (flags & CON_NBCON) {
printk_seq = nbcon_seq_read(c);
} else {
- WARN_ON_ONCE(!locked);
+ WARN_ON_ONCE(!use_console_lock);
printk_seq = c->seq;
}
@@ -4250,7 +4249,7 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre
if (diff != last_diff && reset_on_progress)
remaining_jiffies = timeout_jiffies;
- if (locked)
+ if (use_console_lock)
console_unlock();
/* Note: @diff is 0 if there are no usable consoles. */
@@ -1 +1 @@
--rt10
+-rt11