]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
serial: zs: Fix bootconsole handover lockup
authorMaciej W. Rozycki <macro@orcam.me.uk>
Wed, 6 May 2026 22:42:39 +0000 (23:42 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 22 May 2026 09:52:34 +0000 (11:52 +0200)
Calling zs_reset() in the course of setting up the serial device causes
line parameters to be reset and the transmitter disabled.  We've been
lucky in that no message is usually produced to the kernel log between
this call and the later call to uart_set_options() in the course of
console setup done by zs_serial_console_init(), or the system would hang
as the console output handler in the firmware tried to access a port the
transmitter of which has been disabled and line parameters messed up.

This will change with the next change to the driver, so fix zs_reset()
such that line parameters are set for 9600n8 console operation as with
the system firmware and the transmitter re-enabled after reset.  This
also means zs_pm() serves no purpose anymore, so drop it.

Fixes: 8b4a40809e53 ("zs: move to the serial subsystem")
Signed-off-by: Maciej W. Rozycki <macro@orcam.me.uk>
Cc: stable@vger.kernel.org # v2.6.23+
Link: https://patch.msgid.link/alpine.DEB.2.21.2605062308040.46195@angie.orcam.me.uk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/zs.c

index 31e12645f66b15d62163ef687b9c03c1f38316df..bb10cd8aa7dcf5e3dfa584ff379d63b771f46404 100644 (file)
@@ -105,18 +105,24 @@ struct zs_parms {
 
 static struct zs_scc zs_sccs[ZS_NUM_SCCS];
 
+/*
+ * Set parameters in WR5, WR12, WR13 such as not to interfere
+ * with the initial PROM-based console.  Otherwise any output
+ * produced before the console handover would cause the system
+ * firmware to hang (TxENAB) or produce rubbish (Tx8, B9600).
+ */
 static u8 zs_init_regs[ZS_NUM_REGS] __initdata = {
        0,                              /* write 0 */
        PAR_SPEC,                       /* write 1 */
        0,                              /* write 2 */
        0,                              /* write 3 */
        X16CLK | SB1,                   /* write 4 */
-       0,                              /* write 5 */
+       Tx8 | TxENAB,                   /* write 5 */
        0, 0, 0,                        /* write 6, 7, 8 */
        MIE | DLC | NV,                 /* write 9 */
        NRZ,                            /* write 10 */
        TCBR | RCBR,                    /* write 11 */
-       0, 0,                           /* BRG time constant, write 12 + 13 */
+       0x16, 0x00,                     /* BRG time constant, write 12 + 13 */
        BRSRC | BRENABL,                /* write 14 */
        0,                              /* write 15 */
 };
@@ -956,23 +962,6 @@ static void zs_set_termios(struct uart_port *uport, struct ktermios *termios,
        spin_unlock_irqrestore(&scc->zlock, flags);
 }
 
-/*
- * Hack alert!
- * Required solely so that the initial PROM-based console
- * works undisturbed in parallel with this one.
- */
-static void zs_pm(struct uart_port *uport, unsigned int state,
-                 unsigned int oldstate)
-{
-       struct zs_port *zport = to_zport(uport);
-
-       if (state < 3)
-               zport->regs[5] |= TxENAB;
-       else
-               zport->regs[5] &= ~TxENAB;
-       write_zsreg(zport, R5, zport->regs[5]);
-}
-
 
 static const char *zs_type(struct uart_port *uport)
 {
@@ -1055,7 +1044,6 @@ static const struct uart_ops zs_ops = {
        .startup        = zs_startup,
        .shutdown       = zs_shutdown,
        .set_termios    = zs_set_termios,
-       .pm             = zs_pm,
        .type           = zs_type,
        .release_port   = zs_release_port,
        .request_port   = zs_request_port,
@@ -1210,7 +1198,6 @@ static int __init zs_console_setup(struct console *co, char *options)
                return ret;
 
        zs_reset(zport);
-       zs_pm(uport, 0, -1);
 
        if (options)
                uart_parse_options(options, &baud, &parity, &bits, &flow);