All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] serial: fsl_lpuart: Reset prior to registration
@ 2022-09-11  8:22 Lukas Wunner
  2022-09-13  7:20 ` Ilpo Järvinen
  0 siblings, 1 reply; 2+ messages in thread
From: Lukas Wunner @ 2022-09-11  8:22 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Fugang Duan, Sherry Sun
  Cc: Jiri Slaby, linux-serial, Lino Sanfilippo, Ilpo Jarvinen

Since commit bd5305dcabbc ("tty: serial: fsl_lpuart: do software reset
for imx7ulp and imx8qxp"), certain i.MX UARTs are reset after they've
already been registered.  Register state may thus be clobbered after
user space has begun to open and access the UART.

Avoid by performing the reset prior to registration.

Fixes: bd5305dcabbc ("tty: serial: fsl_lpuart: do software reset for imx7ulp and imx8qxp")
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Cc: stable@vger.kernel.org # v5.15+
Cc: Fugang Duan <fugang.duan@nxp.com>
Cc: Sherry Sun <sherry.sun@nxp.com>
---
 drivers/tty/serial/fsl_lpuart.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index f21915015d67..e9d5b481bb31 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -2719,14 +2719,15 @@ static int lpuart_probe(struct platform_device *pdev)
 		lpuart_reg.cons = LPUART_CONSOLE;
 		handler = lpuart_int;
 	}
-	ret = uart_add_one_port(&lpuart_reg, &sport->port);
-	if (ret)
-		goto failed_attach_port;
 
 	ret = lpuart_global_reset(sport);
 	if (ret)
 		goto failed_reset;
 
+	ret = uart_add_one_port(&lpuart_reg, &sport->port);
+	if (ret)
+		goto failed_attach_port;
+
 	ret = uart_get_rs485_mode(&sport->port);
 	if (ret)
 		goto failed_get_rs485;
@@ -2742,9 +2743,9 @@ static int lpuart_probe(struct platform_device *pdev)
 
 failed_irq_request:
 failed_get_rs485:
-failed_reset:
 	uart_remove_one_port(&lpuart_reg, &sport->port);
 failed_attach_port:
+failed_reset:
 	lpuart_disable_clks(sport);
 	return ret;
 }
-- 
2.36.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] serial: fsl_lpuart: Reset prior to registration
  2022-09-11  8:22 [PATCH] serial: fsl_lpuart: Reset prior to registration Lukas Wunner
@ 2022-09-13  7:20 ` Ilpo Järvinen
  0 siblings, 0 replies; 2+ messages in thread
From: Ilpo Järvinen @ 2022-09-13  7:20 UTC (permalink / raw)
  To: Lukas Wunner
  Cc: Greg Kroah-Hartman, Fugang Duan, Sherry Sun, Jiri Slaby,
	linux-serial, Lino Sanfilippo

[-- Attachment #1: Type: text/plain, Size: 697 bytes --]

On Sun, 11 Sep 2022, Lukas Wunner wrote:

> Since commit bd5305dcabbc ("tty: serial: fsl_lpuart: do software reset
> for imx7ulp and imx8qxp"), certain i.MX UARTs are reset after they've
> already been registered.  Register state may thus be clobbered after
> user space has begun to open and access the UART.
> 
> Avoid by performing the reset prior to registration.
> 
> Fixes: bd5305dcabbc ("tty: serial: fsl_lpuart: do software reset for imx7ulp and imx8qxp")
> Signed-off-by: Lukas Wunner <lukas@wunner.de>
> Cc: stable@vger.kernel.org # v5.15+
> Cc: Fugang Duan <fugang.duan@nxp.com>
> Cc: Sherry Sun <sherry.sun@nxp.com>

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

-- 
 i.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-09-13  7:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-11  8:22 [PATCH] serial: fsl_lpuart: Reset prior to registration Lukas Wunner
2022-09-13  7:20 ` Ilpo Järvinen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.