Merge tag 'pinctrl-v6.9-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw...
[linux-block.git] / drivers / tty / serial / serial_core.c
index ff85ebd3a007dba0105e38d732efc0f6a6f8ab5b..c476d884356dbda13ad2183a2d7218aa88ae3325 100644 (file)
@@ -156,7 +156,7 @@ static void __uart_start(struct uart_state *state)
         * enabled, serial_port_runtime_resume() calls start_tx() again
         * after enabling the device.
         */
-       if (pm_runtime_active(&port_dev->dev))
+       if (!pm_runtime_enabled(port->dev) || pm_runtime_active(&port_dev->dev))
                port->ops->start_tx(port);
        pm_runtime_mark_last_busy(&port_dev->dev);
        pm_runtime_put_autosuspend(&port_dev->dev);
@@ -323,16 +323,26 @@ static int uart_startup(struct tty_struct *tty, struct uart_state *state,
                        bool init_hw)
 {
        struct tty_port *port = &state->port;
+       struct uart_port *uport;
        int retval;
 
        if (tty_port_initialized(port))
-               return 0;
+               goto out_base_port_startup;
 
        retval = uart_port_startup(tty, state, init_hw);
-       if (retval)
+       if (retval) {
                set_bit(TTY_IO_ERROR, &tty->flags);
+               return retval;
+       }
 
-       return retval;
+out_base_port_startup:
+       uport = uart_port_check(state);
+       if (!uport)
+               return -EIO;
+
+       serial_base_port_startup(uport);
+
+       return 0;
 }
 
 /*
@@ -355,6 +365,9 @@ static void uart_shutdown(struct tty_struct *tty, struct uart_state *state)
        if (tty)
                set_bit(TTY_IO_ERROR, &tty->flags);
 
+       if (uport)
+               serial_base_port_shutdown(uport);
+
        if (tty_port_initialized(port)) {
                tty_port_set_initialized(port, false);
 
@@ -1775,6 +1788,7 @@ static void uart_tty_port_shutdown(struct tty_port *port)
        uport->ops->stop_rx(uport);
        uart_port_unlock_irq(uport);
 
+       serial_base_port_shutdown(uport);
        uart_port_shutdown(port);
 
        /*
@@ -1788,6 +1802,7 @@ static void uart_tty_port_shutdown(struct tty_port *port)
         * Free the transmit buffer.
         */
        uart_port_lock_irq(uport);
+       uart_circ_clear(&state->xmit);
        buf = state->xmit.buf;
        state->xmit.buf = NULL;
        uart_port_unlock_irq(uport);