Centos-kernel-stream-9/drivers/tty
Jared Kangas 312680f1c7 serial: sh-sci: Increment the runtime usage counter for the earlycon device
JIRA: https://issues.redhat.com/browse/RHEL-78246

commit 651dee03696e1dfde6d9a7e8664bbdcd9a10ea7f
Author: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Date:   Thu Jan 16 20:22:49 2025 +0200

    serial: sh-sci: Increment the runtime usage counter for the earlycon device

    In the sh-sci driver, serial ports are mapped to the sci_ports[] array,
    with earlycon mapped at index zero.

    The uart_add_one_port() function eventually calls __device_attach(),
    which, in turn, calls pm_request_idle(). The identified code path is as
    follows:

    uart_add_one_port() ->
      serial_ctrl_register_port() ->
        serial_core_register_port() ->
          serial_core_port_device_add() ->
            serial_base_port_add() ->
              device_add() ->
                bus_probe_device() ->
                  device_initial_probe() ->
                    __device_attach() ->
                      // ...
                      if (dev->p->dead) {
                        // ...
                      } else if (dev->driver) {
                        // ...
                      } else {
                        // ...
                        pm_request_idle(dev);
                        // ...
                      }

    The earlycon device clocks are enabled by the bootloader. However, the
    pm_request_idle() call in __device_attach() disables the SCI port clocks
    while earlycon is still active.

    The earlycon write function, serial_console_write(), calls
    sci_poll_put_char() via serial_console_putchar(). If the SCI port clocks
    are disabled, writing to earlycon may sometimes cause the SR.TDFE bit to
    remain unset indefinitely, causing the while loop in sci_poll_put_char()
    to never exit. On single-core SoCs, this can result in the system being
    blocked during boot when this issue occurs.

    To resolve this, increment the runtime PM usage counter for the earlycon
    SCI device before registering the UART port.

    Fixes: 0b0cced19a ("serial: sh-sci: Add CONFIG_SERIAL_EARLYCON support")
    Cc: stable@vger.kernel.org
    Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
    Link: https://lore.kernel.org/r/20250116182249.3828577-6-claudiu.beznea.uj@bp.renesas.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Signed-off-by: Jared Kangas <jkangas@redhat.com>
2025-02-06 18:06:46 -08:00
..
hvc
ipwireless
serdev
serial serial: sh-sci: Increment the runtime usage counter for the earlycon device 2025-02-06 18:06:46 -08:00
vt vt: remove superfluous CONFIG_HW_CONSOLE 2024-11-20 11:19:51 +01:00
Kconfig vt: remove superfluous CONFIG_HW_CONSOLE 2024-11-20 11:19:51 +01:00
Makefile
amiserial.c
ehv_bytechan.c
goldfish.c
mips_ejtag_fdc.c
moxa.c
mxser.c
n_gsm.c tty: n_gsm: Fix use-after-free in gsm_cleanup_mux 2024-10-29 07:42:27 +00:00
n_hdlc.c
n_null.c
n_tty.c
nozomi.c
pty.c
rpmsg_tty.c
synclink_gt.c
sysrq.c mm: remove arguments of show_mem() 2024-10-01 11:17:31 -04:00
tty.h
tty_audit.c
tty_baudrate.c
tty_buffer.c
tty_io.c tty, proc, kernfs, random: Use copy_splice_read() 2024-09-05 20:35:54 -04:00
tty_ioctl.c
tty_jobctrl.c
tty_ldisc.c
tty_ldsem.c
tty_mutex.c
tty_port.c
ttynull.c
vcc.c