* [PATCH 1/3] serial: qcom-geni: fix premature receiver enable
2024-09-16 17:26 [PATCH 0/3] serial: qcom-geni: fix receiver enable Johan Hovold
@ 2024-09-16 17:26 ` Johan Hovold
2024-09-16 17:26 ` [PATCH 2/3] serial: qcom-geni: fix shutdown race Johan Hovold
2024-09-16 17:26 ` [PATCH 3/3] serial: qcom-geni: fix receiver enable Johan Hovold
2 siblings, 0 replies; 6+ messages in thread
From: Johan Hovold @ 2024-09-16 17:26 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, Douglas Anderson, linux-arm-msm, linux-kernel,
linux-serial, Johan Hovold, stable, Aniket Randive
The receiver should no be enabled until the port is opened so drop the
bogus call to start tx from the setup code which is shared with the
console implementation.
This was added for some confused implementation of hibernation support,
but the receiver must not be started unconditionally as the port may not
have been open when hibernating the system.
Fixes: 35781d8356a2 ("tty: serial: qcom-geni-serial: Add support for Hibernation feature")
Cc: stable@vger.kernel.org # 6.2
Cc: Aniket Randive <quic_arandive@quicinc.com>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
---
drivers/tty/serial/qcom_geni_serial.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
index 6f0db310cf69..9ea6bd09e665 100644
--- a/drivers/tty/serial/qcom_geni_serial.c
+++ b/drivers/tty/serial/qcom_geni_serial.c
@@ -1152,7 +1152,6 @@ static int qcom_geni_serial_port_setup(struct uart_port *uport)
false, true, true);
geni_se_init(&port->se, UART_RX_WM, port->rx_fifo_depth - 2);
geni_se_select_mode(&port->se, port->dev_data->mode);
- qcom_geni_serial_start_rx(uport);
port->setup = true;
return 0;
--
2.44.2
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 2/3] serial: qcom-geni: fix shutdown race
2024-09-16 17:26 [PATCH 0/3] serial: qcom-geni: fix receiver enable Johan Hovold
2024-09-16 17:26 ` [PATCH 1/3] serial: qcom-geni: fix premature " Johan Hovold
@ 2024-09-16 17:26 ` Johan Hovold
2024-09-17 15:13 ` Bartosz Golaszewski
2024-09-16 17:26 ` [PATCH 3/3] serial: qcom-geni: fix receiver enable Johan Hovold
2 siblings, 1 reply; 6+ messages in thread
From: Johan Hovold @ 2024-09-16 17:26 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, Douglas Anderson, linux-arm-msm, linux-kernel,
linux-serial, Johan Hovold, stable, Bartosz Golaszewski
A commit adding back the stopping of tx on port shutdown failed to add
back the locking which had also been removed by commit e83766334f96
("tty: serial: qcom_geni_serial: No need to stop tx/rx on UART
shutdown").
Holding the port lock is needed to serialise against the console code,
which may update the interrupt enable register and access the port
state.
The call to stop rx that was added by the same commit is redundant as
serial core will already have taken care of that and can thus be
removed.
Fixes: d8aca2f96813 ("tty: serial: qcom-geni-serial: stop operations in progress at shutdown")
Fixes: 947cc4ecc06c ("serial: qcom-geni: fix soft lockup on sw flow control and suspend")
Cc: stable@vger.kernel.org # 6.3
Cc: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
---
drivers/tty/serial/qcom_geni_serial.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
index 9ea6bd09e665..88ad5a6e7de2 100644
--- a/drivers/tty/serial/qcom_geni_serial.c
+++ b/drivers/tty/serial/qcom_geni_serial.c
@@ -1096,10 +1096,10 @@ static void qcom_geni_serial_shutdown(struct uart_port *uport)
{
disable_irq(uport->irq);
+ uart_port_lock_irq(uport);
qcom_geni_serial_stop_tx(uport);
- qcom_geni_serial_stop_rx(uport);
-
qcom_geni_serial_cancel_tx_cmd(uport);
+ uart_port_unlock_irq(uport);
}
static void qcom_geni_serial_flush_buffer(struct uart_port *uport)
--
2.44.2
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH 2/3] serial: qcom-geni: fix shutdown race
2024-09-16 17:26 ` [PATCH 2/3] serial: qcom-geni: fix shutdown race Johan Hovold
@ 2024-09-17 15:13 ` Bartosz Golaszewski
0 siblings, 0 replies; 6+ messages in thread
From: Bartosz Golaszewski @ 2024-09-17 15:13 UTC (permalink / raw)
To: Johan Hovold
Cc: Greg Kroah-Hartman, Jiri Slaby, Douglas Anderson, linux-arm-msm,
linux-kernel, linux-serial, stable, Bartosz Golaszewski
On Mon, Sep 16, 2024 at 7:27 PM Johan Hovold <johan+linaro@kernel.org> wrote:
>
> A commit adding back the stopping of tx on port shutdown failed to add
> back the locking which had also been removed by commit e83766334f96
> ("tty: serial: qcom_geni_serial: No need to stop tx/rx on UART
> shutdown").
>
> Holding the port lock is needed to serialise against the console code,
> which may update the interrupt enable register and access the port
> state.
>
> The call to stop rx that was added by the same commit is redundant as
> serial core will already have taken care of that and can thus be
> removed.
>
> Fixes: d8aca2f96813 ("tty: serial: qcom-geni-serial: stop operations in progress at shutdown")
> Fixes: 947cc4ecc06c ("serial: qcom-geni: fix soft lockup on sw flow control and suspend")
> Cc: stable@vger.kernel.org # 6.3
> Cc: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
> ---
> drivers/tty/serial/qcom_geni_serial.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
> index 9ea6bd09e665..88ad5a6e7de2 100644
> --- a/drivers/tty/serial/qcom_geni_serial.c
> +++ b/drivers/tty/serial/qcom_geni_serial.c
> @@ -1096,10 +1096,10 @@ static void qcom_geni_serial_shutdown(struct uart_port *uport)
> {
> disable_irq(uport->irq);
>
> + uart_port_lock_irq(uport);
> qcom_geni_serial_stop_tx(uport);
> - qcom_geni_serial_stop_rx(uport);
> -
> qcom_geni_serial_cancel_tx_cmd(uport);
> + uart_port_unlock_irq(uport);
> }
>
> static void qcom_geni_serial_flush_buffer(struct uart_port *uport)
> --
> 2.44.2
>
>
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/3] serial: qcom-geni: fix receiver enable
2024-09-16 17:26 [PATCH 0/3] serial: qcom-geni: fix receiver enable Johan Hovold
2024-09-16 17:26 ` [PATCH 1/3] serial: qcom-geni: fix premature " Johan Hovold
2024-09-16 17:26 ` [PATCH 2/3] serial: qcom-geni: fix shutdown race Johan Hovold
@ 2024-09-16 17:26 ` Johan Hovold
2024-09-17 9:11 ` Johan Hovold
2 siblings, 1 reply; 6+ messages in thread
From: Johan Hovold @ 2024-09-16 17:26 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, Douglas Anderson, linux-arm-msm, linux-kernel,
linux-serial, Johan Hovold
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(-)
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
--
2.44.2
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH 3/3] serial: qcom-geni: fix receiver enable
2024-09-16 17:26 ` [PATCH 3/3] serial: qcom-geni: fix receiver enable Johan Hovold
@ 2024-09-17 9:11 ` Johan Hovold
0 siblings, 0 replies; 6+ messages in thread
From: Johan Hovold @ 2024-09-17 9:11 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, Douglas Anderson, linux-arm-msm, linux-kernel,
linux-serial
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
^ permalink raw reply [flat|nested] 6+ messages in thread