* [PATCH] serial: fsl_lpuart: Skip the reset for the early console port
@ 2022-10-24 9:12 Xiaolei Wang
2022-10-24 9:56 ` Sherry Sun
0 siblings, 1 reply; 2+ messages in thread
From: Xiaolei Wang @ 2022-10-24 9:12 UTC (permalink / raw)
To: gregkh, jirislaby, lukas
Cc: fugang.duan, sherry.sun, ilpo.jarvinen, linux-serial, linux-kernel
The commit 60f361722ad2 ("serial: fsl_lpuart: Reset prior to
registration") has moved the reset before the port registration,
this change makes the uart_console() in lpuart_global_reset() no sense
since the port is not registered to the system yet. So drop it.
But we sill need to check if the port is used as an early console
before performing the port reset, otherwise the reset will hang the
system.
Fixes: 60f361722ad2 ("serial: fsl_lpuart: Reset prior to registration")
Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
---
drivers/tty/serial/fsl_lpuart.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index 67fa113f77d4..d0efeba5c695 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -239,6 +239,8 @@
/* IMX lpuart has four extra unused regs located at the beginning */
#define IMX_REG_OFF 0x10
+static resource_size_t lpuart_earlycon_mapbase;
+
enum lpuart_type {
VF610_LPUART,
LS1021A_LPUART,
@@ -410,7 +412,7 @@ static int lpuart_global_reset(struct lpuart_port *sport)
void __iomem *global_addr;
int ret;
- if (uart_console(port))
+ if ((port->mapbase - 0x10) == lpuart_earlycon_mapbase)
return 0;
ret = clk_prepare_enable(sport->ipg_clk);
@@ -2604,6 +2606,7 @@ static int __init lpuart32_imx_early_console_setup(struct earlycon_device *devic
device->port.iotype = UPIO_MEM32;
device->port.membase += IMX_REG_OFF;
device->con->write = lpuart32_early_write;
+ lpuart_earlycon_mapbase = device->port.mapbase;
return 0;
}
--
2.25.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* RE: [PATCH] serial: fsl_lpuart: Skip the reset for the early console port
2022-10-24 9:12 [PATCH] serial: fsl_lpuart: Skip the reset for the early console port Xiaolei Wang
@ 2022-10-24 9:56 ` Sherry Sun
0 siblings, 0 replies; 2+ messages in thread
From: Sherry Sun @ 2022-10-24 9:56 UTC (permalink / raw)
To: Xiaolei Wang, gregkh, jirislaby, lukas
Cc: fugang.duan, ilpo.jarvinen, linux-serial, linux-kernel
> -----Original Message-----
> From: Xiaolei Wang <xiaolei.wang@windriver.com>
> Sent: 2022年10月24日 17:12
> To: gregkh@linuxfoundation.org; jirislaby@kernel.org; lukas@wunner.de
> Cc: fugang.duan@nxp.com; Sherry Sun <sherry.sun@nxp.com>;
> ilpo.jarvinen@linux.intel.com; linux-serial@vger.kernel.org; linux-
> kernel@vger.kernel.org
> Subject: [PATCH] serial: fsl_lpuart: Skip the reset for the early console port
>
> The commit 60f361722ad2 ("serial: fsl_lpuart: Reset prior to
> registration") has moved the reset before the port registration, this change
> makes the uart_console() in lpuart_global_reset() no sense since the port is
> not registered to the system yet. So drop it.
> But we sill need to check if the port is used as an early console before
> performing the port reset, otherwise the reset will hang the system.
>
> Fixes: 60f361722ad2 ("serial: fsl_lpuart: Reset prior to registration")
> Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
> ---
> drivers/tty/serial/fsl_lpuart.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
> index 67fa113f77d4..d0efeba5c695 100644
> --- a/drivers/tty/serial/fsl_lpuart.c
> +++ b/drivers/tty/serial/fsl_lpuart.c
> @@ -239,6 +239,8 @@
> /* IMX lpuart has four extra unused regs located at the beginning */
> #define IMX_REG_OFF 0x10
>
> +static resource_size_t lpuart_earlycon_mapbase;
> +
> enum lpuart_type {
> VF610_LPUART,
> LS1021A_LPUART,
> @@ -410,7 +412,7 @@ static int lpuart_global_reset(struct lpuart_port
> *sport)
> void __iomem *global_addr;
> int ret;
>
> - if (uart_console(port))
> + if ((port->mapbase - 0x10) == lpuart_earlycon_mapbase)
> return 0;
>
> ret = clk_prepare_enable(sport->ipg_clk);
> @@ -2604,6 +2606,7 @@ static int __init
> lpuart32_imx_early_console_setup(struct earlycon_device *devic
> device->port.iotype = UPIO_MEM32;
> device->port.membase += IMX_REG_OFF;
> device->con->write = lpuart32_early_write;
> + lpuart_earlycon_mapbase = device->port.mapbase;
>
Hi, thanks for the fix for lpuart driver, but this looks more like a workaround patch.
Per my understanding, the root cause for this issue is that lpuart_global_reset() break the on-going transfer, such as the earlycon here.
I have sent a patch to fix the lpuart console hang issue, please check https://lore.kernel.org/lkml/20221024085844.22786-1-sherry.sun@nxp.com/
Best Regards
Sherry
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-10-24 9:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-24 9:12 [PATCH] serial: fsl_lpuart: Skip the reset for the early console port Xiaolei Wang
2022-10-24 9:56 ` Sherry Sun
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®