Merge tag 'tty-6.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
[sfrench/cifs-2.6.git] / drivers / tty / serial / qcom_geni_serial.c
index 99e08737f293c6868e56d2de80f31bf0e3345ca3..f9f7ac1a10df3d668d41506075359c7601b12185 100644 (file)
@@ -488,18 +488,16 @@ static void qcom_geni_serial_console_write(struct console *co, const char *s,
 
        geni_status = readl(uport->membase + SE_GENI_STATUS);
 
-       /* Cancel the current write to log the fault */
        if (!locked) {
-               geni_se_cancel_m_cmd(&port->se);
-               if (!qcom_geni_serial_poll_bit(uport, SE_GENI_M_IRQ_STATUS,
-                                               M_CMD_CANCEL_EN, true)) {
-                       geni_se_abort_m_cmd(&port->se);
-                       qcom_geni_serial_poll_bit(uport, SE_GENI_M_IRQ_STATUS,
-                                                       M_CMD_ABORT_EN, true);
-                       writel(M_CMD_ABORT_EN, uport->membase +
-                                                       SE_GENI_M_IRQ_CLEAR);
-               }
-               writel(M_CMD_CANCEL_EN, uport->membase + SE_GENI_M_IRQ_CLEAR);
+               /*
+                * We can only get here if an oops is in progress then we were
+                * unable to get the lock. This means we can't safely access
+                * our state variables like tx_remaining. About the best we
+                * can do is wait for the FIFO to be empty before we start our
+                * transfer, so we'll do that.
+                */
+               qcom_geni_serial_poll_bit(uport, SE_GENI_M_IRQ_STATUS,
+                                         M_TX_FIFO_NOT_EMPTY_EN, false);
        } else if ((geni_status & M_GENI_CMD_ACTIVE) && !port->tx_remaining) {
                /*
                 * It seems we can't interrupt existing transfers if all data
@@ -516,11 +514,12 @@ static void qcom_geni_serial_console_write(struct console *co, const char *s,
 
        __qcom_geni_serial_console_write(uport, s, count);
 
-       if (port->tx_remaining)
-               qcom_geni_serial_setup_tx(uport, port->tx_remaining);
 
-       if (locked)
+       if (locked) {
+               if (port->tx_remaining)
+                       qcom_geni_serial_setup_tx(uport, port->tx_remaining);
                uart_port_unlock_irqrestore(uport, flags);
+       }
 }
 
 static void handle_rx_console(struct uart_port *uport, u32 bytes, bool drop)