Skip to content

Commit 9023ca0

Browse files
jognesspmladek
authored andcommitted
printk: do not wait for consoles when suspended
The console_stop() and console_start() functions call pr_flush(). When suspending, these functions are called by the serial subsystem while the serial port is suspended. In this scenario, if there are any pending messages, a call to pr_flush() will always result in a timeout because the serial port cannot make forward progress. This causes longer suspend and resume times. Add a check in pr_flush() so that it will immediately timeout if the consoles are suspended. Fixes: 3b604ca ("printk: add pr_flush()") Reported-by: Todd Brandt <todd.e.brandt@linux.intel.com> Signed-off-by: John Ogness <john.ogness@linutronix.de> Tested-by: Todd Brandt <todd.e.brandt@linux.intel.com> Signed-off-by: Petr Mladek <pmladek@suse.com> Link: https://lore.kernel.org/r/20220715061042.373640-2-john.ogness@linutronix.de
1 parent 07a22b6 commit 9023ca0

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

kernel/printk/printk.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3380,6 +3380,7 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre
33803380
diff = 0;
33813381

33823382
console_lock();
3383+
33833384
for_each_console(c) {
33843385
if (con && con != c)
33853386
continue;
@@ -3389,11 +3390,19 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre
33893390
if (printk_seq < seq)
33903391
diff += seq - printk_seq;
33913392
}
3392-
console_unlock();
33933393

3394-
if (diff != last_diff && reset_on_progress)
3394+
/*
3395+
* If consoles are suspended, it cannot be expected that they
3396+
* make forward progress, so timeout immediately. @diff is
3397+
* still used to return a valid flush status.
3398+
*/
3399+
if (console_suspended)
3400+
remaining = 0;
3401+
else if (diff != last_diff && reset_on_progress)
33953402
remaining = timeout_ms;
33963403

3404+
console_unlock();
3405+
33973406
if (diff == 0 || remaining == 0)
33983407
break;
33993408

0 commit comments

Comments
 (0)