Skip to content

Commit fa103d2

Browse files
jhovoldgregkh
authored andcommitted
serial: qcom-geni: fix receiver enable
The receiver is supposed to be enabled in the startup() callback and not in set_termios() which is called also during console setup. This specifically avoids accepting input before the port has been opened (and interrupts enabled), something which can also break the GENI firmware (cancel fails and after abort, the "stale" counter handling appears to be broken so that later input is not processed until twelve chars have been received). There also does not appear to be any need to keep the receiver disabled while updating the port settings. Since commit 6f3c3ca ("serial: qcom-geni: disable interrupts during console writes") the calls to manipulate the secondary interrupts, which were done without holding the port lock, can also lead to the receiver being left disabled when set_termios() races with the console code (e.g. when init opens the tty during boot). This can manifest itself as a serial getty not accepting input. The calls to stop and start rx in set_termios() can similarly race with DMA completion and, for example, cause the DMA buffer to be unmapped twice or the mapping to be leaked. Fix this by only enabling the receiver during startup and while holding the port lock to avoid racing with the console code. Fixes: 6f3c3ca ("serial: qcom-geni: disable interrupts during console writes") Fixes: 2aaa43c ("tty: serial: qcom-geni-serial: add support for serial engine DMA") Fixes: c4f5287 ("tty: serial: msm_geni_serial: Add serial driver support for GENI based QUP") Cc: [email protected] # 6.3 Cc: Bartosz Golaszewski <[email protected]> Signed-off-by: Johan Hovold <[email protected]> Reviewed-by: Douglas Anderson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 23ee4a2 commit fa103d2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drivers/tty/serial/qcom_geni_serial.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,6 +1197,11 @@ static int qcom_geni_serial_startup(struct uart_port *uport)
11971197
if (ret)
11981198
return ret;
11991199
}
1200+
1201+
uart_port_lock_irq(uport);
1202+
qcom_geni_serial_start_rx(uport);
1203+
uart_port_unlock_irq(uport);
1204+
12001205
enable_irq(uport->irq);
12011206

12021207
return 0;
@@ -1282,7 +1287,6 @@ static void qcom_geni_serial_set_termios(struct uart_port *uport,
12821287
unsigned int avg_bw_core;
12831288
unsigned long timeout;
12841289

1285-
qcom_geni_serial_stop_rx(uport);
12861290
/* baud rate */
12871291
baud = uart_get_baud_rate(uport, termios, old, 300, 4000000);
12881292

@@ -1298,7 +1302,7 @@ static void qcom_geni_serial_set_termios(struct uart_port *uport,
12981302
dev_err(port->se.dev,
12991303
"Couldn't find suitable clock rate for %u\n",
13001304
baud * sampling_rate);
1301-
goto out_restart_rx;
1305+
return;
13021306
}
13031307

13041308
dev_dbg(port->se.dev, "desired_rate = %u, clk_rate = %lu, clk_div = %u\n",
@@ -1389,8 +1393,6 @@ static void qcom_geni_serial_set_termios(struct uart_port *uport,
13891393
writel(stop_bit_len, uport->membase + SE_UART_TX_STOP_BIT_LEN);
13901394
writel(ser_clk_cfg, uport->membase + GENI_SER_M_CLK_CFG);
13911395
writel(ser_clk_cfg, uport->membase + GENI_SER_S_CLK_CFG);
1392-
out_restart_rx:
1393-
qcom_geni_serial_start_rx(uport);
13941396
}
13951397

13961398
#ifdef CONFIG_SERIAL_QCOM_GENI_CONSOLE

0 commit comments

Comments
 (0)