Merge tag 'linux-kselftest-5.2-rc2' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-2.6-microblaze.git] / kernel / printk / printk.c
index 17102fd..1888f6a 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  *  linux/kernel/printk.c
  *
@@ -2535,10 +2536,11 @@ void console_unblank(void)
 
 /**
  * console_flush_on_panic - flush console content on panic
+ * @mode: flush all messages in buffer or just the pending ones
  *
  * Immediately output all pending messages no matter what.
  */
-void console_flush_on_panic(void)
+void console_flush_on_panic(enum con_flush_mode mode)
 {
        /*
         * If someone else is holding the console lock, trylock will fail
@@ -2549,6 +2551,15 @@ void console_flush_on_panic(void)
         */
        console_trylock();
        console_may_schedule = 0;
+
+       if (mode == CONSOLE_REPLAY_ALL) {
+               unsigned long flags;
+
+               logbuf_lock_irqsave(flags);
+               console_seq = log_first_seq;
+               console_idx = log_first_idx;
+               logbuf_unlock_irqrestore(flags);
+       }
        console_unlock();
 }