Skip to content

Commit 9605081

Browse files
committed
Merge tag 'printk-for-6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux
Pull printk updates from Petr Mladek: - New option "printk.debug_non_panic_cpus" allows to store printk messages from non-panic CPUs during panic. It might be useful when panic() fails. It is disabled by default because it increases the chance to see the messages printed before panic() and on the panic-CPU. - New build option "CONFIG_NULL_TTY_DEFAULT_CONSOLE" allows to build kernel without the virtual terminal support which prefers ttynull over serial console. - Do not unblank suspended consoles. - Some code clean up. * tag 'printk-for-6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux: printk/panic: Add option to allow non-panic CPUs to write to the ring buffer. printk: Add an option to allow ttynull to be a default console device printk: Check CON_SUSPEND when unblanking a console printk: Rename console_start to console_resume printk: Rename console_stop to console_suspend printk: Rename resume_console to console_resume_all printk: Rename suspend_console to console_suspend_all
2 parents a10c794 + f49040c commit 9605081

File tree

14 files changed

+110
-46
lines changed

14 files changed

+110
-46
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5020,6 +5020,14 @@
50205020
Format: <bool>
50215021
default: 0 (auto_verbose is enabled)
50225022

5023+
printk.debug_non_panic_cpus=
5024+
Allows storing messages from non-panic CPUs into
5025+
the printk log buffer during panic(). They are
5026+
flushed to consoles by the panic-CPU on
5027+
a best-effort basis.
5028+
Format: <bool> (1/Y/y=enable, 0/N/n=disable)
5029+
Default: disabled
5030+
50235031
printk.devkmsg={on,off,ratelimit}
50245032
Control writing to /dev/kmsg.
50255033
on - unlimited logging to /dev/kmsg from userspace

Documentation/admin-guide/serial-console.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ If no console device is specified, the first device found capable of
7878
acting as a system console will be used. At this time, the system
7979
first looks for a VGA card and then for a serial port. So if you don't
8080
have a VGA card in your system the first serial port will automatically
81-
become the console.
81+
become the console, unless the kernel is configured with the
82+
CONFIG_NULL_TTY_DEFAULT_CONSOLE option, then it will default to using the
83+
ttynull device.
8284

8385
You will need to create a new device to use ``/dev/console``. The official
8486
``/dev/console`` is now character device 5,1.

drivers/gpu/drm/clients/drm_log.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ static int drm_log_client_suspend(struct drm_client_dev *client, bool _console_l
323323
{
324324
struct drm_log *dlog = client_to_drm_log(client);
325325

326-
console_stop(&dlog->con);
326+
console_suspend(&dlog->con);
327327

328328
return 0;
329329
}
@@ -332,7 +332,7 @@ static int drm_log_client_resume(struct drm_client_dev *client, bool _console_lo
332332
{
333333
struct drm_log *dlog = client_to_drm_log(client);
334334

335-
console_start(&dlog->con);
335+
console_resume(&dlog->con);
336336

337337
return 0;
338338
}

drivers/tty/Kconfig

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,24 @@ config NULL_TTY
383383
available or desired.
384384

385385
In order to use this driver, you should redirect the console to this
386-
TTY, or boot the kernel with console=ttynull.
386+
TTY, boot the kernel with console=ttynull, or enable
387+
NULL_TTY_DEFAULT_CONSOLE.
388+
389+
If unsure, say N.
390+
391+
config NULL_TTY_DEFAULT_CONSOLE
392+
bool "Support for console on ttynull"
393+
depends on NULL_TTY=y && !VT_CONSOLE
394+
help
395+
Say Y here if you want the NULL TTY to be used as a /dev/console
396+
device by default.
397+
398+
For example, it might be useful to prevent a VT-less kernel from
399+
writing the system log to a random device connected to the serial
400+
port.
401+
402+
Another console driver still might get preferred via the command
403+
line, SPCR, or the device tree.
387404

388405
If unsure, say N.
389406

drivers/tty/serial/serial_core.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2426,10 +2426,10 @@ int uart_suspend_port(struct uart_driver *drv, struct uart_port *uport)
24262426
}
24272427

24282428
/*
2429-
* Disable the console device before suspending.
2429+
* Suspend the console device before suspending the port.
24302430
*/
24312431
if (uart_console(uport))
2432-
console_stop(uport->cons);
2432+
console_suspend(uport->cons);
24332433

24342434
uart_change_pm(state, UART_PM_STATE_OFF);
24352435

@@ -2484,7 +2484,7 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *uport)
24842484
uart_port_unlock_irq(uport);
24852485
}
24862486
if (console_suspend_enabled)
2487-
console_start(uport->cons);
2487+
console_resume(uport->cons);
24882488
}
24892489

24902490
if (tty_port_suspended(port)) {

include/linux/console.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -633,8 +633,8 @@ extern void console_conditional_schedule(void);
633633
extern void console_unblank(void);
634634
extern void console_flush_on_panic(enum con_flush_mode mode);
635635
extern struct tty_driver *console_device(int *);
636-
extern void console_stop(struct console *);
637-
extern void console_start(struct console *);
636+
extern void console_suspend(struct console *);
637+
extern void console_resume(struct console *);
638638
extern int is_console_locked(void);
639639
extern int braille_register_console(struct console *, int index,
640640
char *console_options, char *braille_options);
@@ -648,8 +648,8 @@ static inline void console_sysfs_notify(void)
648648
extern bool console_suspend_enabled;
649649

650650
/* Suspend and resume console messages over PM events */
651-
extern void suspend_console(void);
652-
extern void resume_console(void);
651+
extern void console_suspend_all(void);
652+
extern void console_resume_all(void);
653653

654654
int mda_console_init(void);
655655

kernel/kexec_core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,7 @@ int kernel_kexec(void)
10131013
error = -EBUSY;
10141014
goto Restore_console;
10151015
}
1016-
suspend_console();
1016+
console_suspend_all();
10171017
error = dpm_suspend_start(PMSG_FREEZE);
10181018
if (error)
10191019
goto Resume_console;
@@ -1072,7 +1072,7 @@ int kernel_kexec(void)
10721072
Resume_devices:
10731073
dpm_resume_end(PMSG_RESTORE);
10741074
Resume_console:
1075-
resume_console();
1075+
console_resume_all();
10761076
thaw_processes();
10771077
Restore_console:
10781078
pm_restore_console();

kernel/power/hibernate.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ int hibernation_snapshot(int platform_mode)
411411
goto Thaw;
412412
}
413413

414-
suspend_console();
414+
console_suspend_all();
415415
pm_restrict_gfp_mask();
416416

417417
error = dpm_suspend(PMSG_FREEZE);
@@ -437,7 +437,7 @@ int hibernation_snapshot(int platform_mode)
437437
if (error || !in_suspend)
438438
pm_restore_gfp_mask();
439439

440-
resume_console();
440+
console_resume_all();
441441
dpm_complete(msg);
442442

443443
Close:
@@ -547,7 +547,7 @@ int hibernation_restore(int platform_mode)
547547
int error;
548548

549549
pm_prepare_console();
550-
suspend_console();
550+
console_suspend_all();
551551
pm_restrict_gfp_mask();
552552
error = dpm_suspend_start(PMSG_QUIESCE);
553553
if (!error) {
@@ -561,7 +561,7 @@ int hibernation_restore(int platform_mode)
561561
}
562562
dpm_resume_end(PMSG_RECOVER);
563563
pm_restore_gfp_mask();
564-
resume_console();
564+
console_resume_all();
565565
pm_restore_console();
566566
return error;
567567
}
@@ -586,7 +586,7 @@ int hibernation_platform_enter(void)
586586
goto Close;
587587

588588
entering_platform_hibernation = true;
589-
suspend_console();
589+
console_suspend_all();
590590
error = dpm_suspend_start(PMSG_HIBERNATE);
591591
if (error) {
592592
if (hibernation_ops->recover)
@@ -639,7 +639,7 @@ int hibernation_platform_enter(void)
639639
Resume_devices:
640640
entering_platform_hibernation = false;
641641
dpm_resume_end(PMSG_RESTORE);
642-
resume_console();
642+
console_resume_all();
643643

644644
Close:
645645
hibernation_ops->end();
@@ -901,7 +901,7 @@ int hibernate_quiet_exec(int (*func)(void *data), void *data)
901901
if (error)
902902
goto dpm_complete;
903903

904-
suspend_console();
904+
console_suspend_all();
905905

906906
error = dpm_suspend(PMSG_FREEZE);
907907
if (error)
@@ -925,7 +925,7 @@ int hibernate_quiet_exec(int (*func)(void *data), void *data)
925925
dpm_resume:
926926
dpm_resume(PMSG_THAW);
927927

928-
resume_console();
928+
console_resume_all();
929929

930930
dpm_complete:
931931
dpm_complete(PMSG_THAW);

kernel/power/suspend.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ int suspend_devices_and_enter(suspend_state_t state)
508508
if (error)
509509
goto Close;
510510

511-
suspend_console();
511+
console_suspend_all();
512512
suspend_test_start();
513513
error = dpm_suspend_start(PMSG_SUSPEND);
514514
if (error) {
@@ -527,9 +527,9 @@ int suspend_devices_and_enter(suspend_state_t state)
527527
suspend_test_start();
528528
dpm_resume_end(PMSG_RESUME);
529529
suspend_test_finish("resume devices");
530-
trace_suspend_resume(TPS("resume_console"), state, true);
531-
resume_console();
532-
trace_suspend_resume(TPS("resume_console"), state, false);
530+
trace_suspend_resume(TPS("console_resume_all"), state, true);
531+
console_resume_all();
532+
trace_suspend_resume(TPS("console_resume_all"), state, false);
533533

534534
Close:
535535
platform_resume_end(state);

kernel/printk/internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ struct dev_printk_info;
6464

6565
extern struct printk_ringbuffer *prb;
6666
extern bool printk_kthreads_running;
67+
extern bool debug_non_panic_cpus;
6768

6869
__printf(4, 0)
6970
int vprintk_store(int facility, int level,

0 commit comments

Comments
 (0)