Message ID | 20240916172642.7814-4-johan+linaro@kernel.org (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | serial: qcom-geni: fix receiver enable | expand |
On Mon, Sep 16, 2024 at 07:26:42PM +0200, Johan Hovold wrote: > The receiver should be enabled in the startup() callback and there is no > need to stop it on every termios update. > > Since commit 6f3c3cafb115 ("serial: qcom-geni: disable interrupts during > console writes") the calls to manipulate the secondary interrupts, which > were done without holding the port lock, can lead to the receiver being > left disabled when set_termios() races with the console code (e.g. when > init opens the tty during boot). > > Fixes: 6f3c3cafb115 ("serial: qcom-geni: disable interrupts during console writes") > Signed-off-by: Johan Hovold <johan+linaro@kernel.org> Turns out the DMA implementation is broken and currently depends on these bogus calls to stop and restart rx in set_termios(). I won't have time to look at this for a couple of weeks due to conferences, so please hold off on merging these until I'm back. Johan
diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c index 88ad5a6e7de2..85c2742e6cc4 100644 --- a/drivers/tty/serial/qcom_geni_serial.c +++ b/drivers/tty/serial/qcom_geni_serial.c @@ -1167,6 +1167,11 @@ static int qcom_geni_serial_startup(struct uart_port *uport) if (ret) return ret; } + + uart_port_lock_irq(uport); + qcom_geni_serial_start_rx(uport); + uart_port_unlock_irq(uport); + enable_irq(uport->irq); return 0; @@ -1252,7 +1257,6 @@ static void qcom_geni_serial_set_termios(struct uart_port *uport, unsigned int avg_bw_core; unsigned long timeout; - qcom_geni_serial_stop_rx(uport); /* baud rate */ baud = uart_get_baud_rate(uport, termios, old, 300, 4000000); @@ -1268,7 +1272,7 @@ static void qcom_geni_serial_set_termios(struct uart_port *uport, dev_err(port->se.dev, "Couldn't find suitable clock rate for %u\n", baud * sampling_rate); - goto out_restart_rx; + return; } dev_dbg(port->se.dev, "desired_rate = %u, clk_rate = %lu, clk_div = %u\n", @@ -1359,8 +1363,6 @@ static void qcom_geni_serial_set_termios(struct uart_port *uport, writel(stop_bit_len, uport->membase + SE_UART_TX_STOP_BIT_LEN); writel(ser_clk_cfg, uport->membase + GENI_SER_M_CLK_CFG); writel(ser_clk_cfg, uport->membase + GENI_SER_S_CLK_CFG); -out_restart_rx: - qcom_geni_serial_start_rx(uport); } #ifdef CONFIG_SERIAL_QCOM_GENI_CONSOLE
The receiver should be enabled in the startup() callback and there is no need to stop it on every termios update. Since commit 6f3c3cafb115 ("serial: qcom-geni: disable interrupts during console writes") the calls to manipulate the secondary interrupts, which were done without holding the port lock, can lead to the receiver being left disabled when set_termios() races with the console code (e.g. when init opens the tty during boot). Fixes: 6f3c3cafb115 ("serial: qcom-geni: disable interrupts during console writes") Signed-off-by: Johan Hovold <johan+linaro@kernel.org> --- drivers/tty/serial/qcom_geni_serial.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)