* [PATCH v2 1/2] tty: serial: 8250_mtk: enable baud clock
@ 2025-09-15 13:06 Daniel Golle
2025-09-15 13:06 ` [PATCH v2 2/2] tty: serial: 8250_mtk: manage baud clock in runtime PM ops Daniel Golle
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Daniel Golle @ 2025-09-15 13:06 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby, Matthias Brugger,
AngeloGioacchino Del Regno, Daniel Golle, Uwe Kleine-König,
Yu Jiaoliang, Andy Shevchenko, Changqi Hu, Sam Shih, Steven Liu,
John Crispin, linux-kernel, linux-serial, linux-arm-kernel,
linux-mediatek
Some MediaTek SoCs got a gated UART baud clock, which currently gets
disabled as the clk subsystem believes it would be unused. This results in
the uart freezing right after "clk: Disabling unused clocks" on those
platforms.
To fix this request the baud clock to be prepared and enabled during probe.
Fixes: e32a83c70cf9 ("serial: 8250-mtk: modify mtk uart power and clock management")
Suggested-by: Sam Shih <sam.shih@mediatek.com>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
v2: no changes
drivers/tty/serial/8250/8250_mtk.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c
index b44de2ed7413..9329ed1f759d 100644
--- a/drivers/tty/serial/8250/8250_mtk.c
+++ b/drivers/tty/serial/8250/8250_mtk.c
@@ -475,13 +475,13 @@ static int mtk8250_probe_of(struct platform_device *pdev, struct uart_port *p,
int dmacnt;
#endif
- data->uart_clk = devm_clk_get(&pdev->dev, "baud");
+ data->uart_clk = devm_clk_get_enabled(&pdev->dev, "baud");
if (IS_ERR(data->uart_clk)) {
/*
* For compatibility with older device trees try unnamed
* clk when no baud clk can be found.
*/
- data->uart_clk = devm_clk_get(&pdev->dev, NULL);
+ data->uart_clk = devm_clk_get_enabled(&pdev->dev, NULL);
if (IS_ERR(data->uart_clk)) {
dev_warn(&pdev->dev, "Can't get uart clock\n");
return PTR_ERR(data->uart_clk);
--
2.51.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH v2 2/2] tty: serial: 8250_mtk: manage baud clock in runtime PM ops
2025-09-15 13:06 [PATCH v2 1/2] tty: serial: 8250_mtk: enable baud clock Daniel Golle
@ 2025-09-15 13:06 ` Daniel Golle
2025-09-15 13:41 ` [PATCH v2 1/2] tty: serial: 8250_mtk: enable baud clock AngeloGioacchino Del Regno
2025-09-15 14:54 ` Andy Shevchenko
2 siblings, 0 replies; 5+ messages in thread
From: Daniel Golle @ 2025-09-15 13:06 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby, Matthias Brugger,
AngeloGioacchino Del Regno, Daniel Golle, Uwe Kleine-König,
Yu Jiaoliang, Andy Shevchenko, Changqi Hu, Sam Shih, Steven Liu,
John Crispin, linux-kernel, linux-serial, linux-arm-kernel,
linux-mediatek
The baud clock is gated on some MediaTek SoCs and can be managed by
runtime power management.
Disable and unprepare the baud clock when suspending the UART, prepare
and enable it again when resuming it.
Fixes: e32a83c70cf9 ("serial: 8250-mtk: modify mtk uart power and clock management")
Suggested-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
v2: add this patch as suggested by AngeloGioacchino Del Regno in
https://lore.kernel.org/all/8b1c1796-6de2-4526-9a29-d8649141b878@collabora.com/
drivers/tty/serial/8250/8250_mtk.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c
index 9329ed1f759d..5875a7b9b4b1 100644
--- a/drivers/tty/serial/8250/8250_mtk.c
+++ b/drivers/tty/serial/8250/8250_mtk.c
@@ -435,6 +435,7 @@ static int __maybe_unused mtk8250_runtime_suspend(struct device *dev)
while
(serial_in(up, MTK_UART_DEBUG0));
+ clk_disable_unprepare(data->uart_clk);
clk_disable_unprepare(data->bus_clk);
return 0;
@@ -445,6 +446,7 @@ static int __maybe_unused mtk8250_runtime_resume(struct device *dev)
struct mtk8250_data *data = dev_get_drvdata(dev);
clk_prepare_enable(data->bus_clk);
+ clk_prepare_enable(data->uart_clk);
return 0;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH v2 1/2] tty: serial: 8250_mtk: enable baud clock
2025-09-15 13:06 [PATCH v2 1/2] tty: serial: 8250_mtk: enable baud clock Daniel Golle
2025-09-15 13:06 ` [PATCH v2 2/2] tty: serial: 8250_mtk: manage baud clock in runtime PM ops Daniel Golle
@ 2025-09-15 13:41 ` AngeloGioacchino Del Regno
2025-09-15 14:51 ` Andy Shevchenko
2025-09-15 14:54 ` Andy Shevchenko
2 siblings, 1 reply; 5+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-09-15 13:41 UTC (permalink / raw)
To: Daniel Golle, Greg Kroah-Hartman, Jiri Slaby, Matthias Brugger,
Uwe Kleine-König, Yu Jiaoliang, Andy Shevchenko, Changqi Hu,
Sam Shih, Steven Liu, John Crispin, linux-kernel, linux-serial,
linux-arm-kernel, linux-mediatek
Il 15/09/25 15:06, Daniel Golle ha scritto:
> Some MediaTek SoCs got a gated UART baud clock, which currently gets
> disabled as the clk subsystem believes it would be unused. This results in
> the uart freezing right after "clk: Disabling unused clocks" on those
> platforms.
>
> To fix this request the baud clock to be prepared and enabled during probe.
>
> Fixes: e32a83c70cf9 ("serial: 8250-mtk: modify mtk uart power and clock management")
> Suggested-by: Sam Shih <sam.shih@mediatek.com>
> Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Thanks for caring about power management. However, this and the addition in PM ops
should be a single commit. It's even using the same Fixes tag...! :-)
I've read both of the commits in this series and the code LGTM.
tty: serial: 8250_mtk: Enable baud clock and manage in runtime PM
Please, squash the two commits, after which...
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Cheers,
Angelo
> ---
> v2: no changes
>
> drivers/tty/serial/8250/8250_mtk.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c
> index b44de2ed7413..9329ed1f759d 100644
> --- a/drivers/tty/serial/8250/8250_mtk.c
> +++ b/drivers/tty/serial/8250/8250_mtk.c
> @@ -475,13 +475,13 @@ static int mtk8250_probe_of(struct platform_device *pdev, struct uart_port *p,
> int dmacnt;
> #endif
>
> - data->uart_clk = devm_clk_get(&pdev->dev, "baud");
> + data->uart_clk = devm_clk_get_enabled(&pdev->dev, "baud");
> if (IS_ERR(data->uart_clk)) {
> /*
> * For compatibility with older device trees try unnamed
> * clk when no baud clk can be found.
> */
> - data->uart_clk = devm_clk_get(&pdev->dev, NULL);
> + data->uart_clk = devm_clk_get_enabled(&pdev->dev, NULL);
> if (IS_ERR(data->uart_clk)) {
> dev_warn(&pdev->dev, "Can't get uart clock\n");
> return PTR_ERR(data->uart_clk);
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v2 1/2] tty: serial: 8250_mtk: enable baud clock
2025-09-15 13:41 ` [PATCH v2 1/2] tty: serial: 8250_mtk: enable baud clock AngeloGioacchino Del Regno
@ 2025-09-15 14:51 ` Andy Shevchenko
0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2025-09-15 14:51 UTC (permalink / raw)
To: AngeloGioacchino Del Regno
Cc: Daniel Golle, Greg Kroah-Hartman, Jiri Slaby, Matthias Brugger,
Uwe Kleine-König, Yu Jiaoliang, Changqi Hu, Sam Shih,
Steven Liu, John Crispin, linux-kernel, linux-serial,
linux-arm-kernel, linux-mediatek
On Mon, Sep 15, 2025 at 03:41:25PM +0200, AngeloGioacchino Del Regno wrote:
> Il 15/09/25 15:06, Daniel Golle ha scritto:
...
> I've read both of the commits in this series and the code LGTM.
>
> tty: serial: 8250_mtk: Enable baud clock and manage in runtime PM
"tty: " part is not needed.
> Please, squash the two commits, after which...
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] tty: serial: 8250_mtk: enable baud clock
2025-09-15 13:06 [PATCH v2 1/2] tty: serial: 8250_mtk: enable baud clock Daniel Golle
2025-09-15 13:06 ` [PATCH v2 2/2] tty: serial: 8250_mtk: manage baud clock in runtime PM ops Daniel Golle
2025-09-15 13:41 ` [PATCH v2 1/2] tty: serial: 8250_mtk: enable baud clock AngeloGioacchino Del Regno
@ 2025-09-15 14:54 ` Andy Shevchenko
2 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2025-09-15 14:54 UTC (permalink / raw)
To: Daniel Golle
Cc: Greg Kroah-Hartman, Jiri Slaby, Matthias Brugger,
AngeloGioacchino Del Regno, Uwe Kleine-König, Yu Jiaoliang,
Changqi Hu, Sam Shih, Steven Liu, John Crispin, linux-kernel,
linux-serial, linux-arm-kernel, linux-mediatek
On Mon, Sep 15, 2025 at 02:06:37PM +0100, Daniel Golle wrote:
...
> - data->uart_clk = devm_clk_get(&pdev->dev, NULL);
> + data->uart_clk = devm_clk_get_enabled(&pdev->dev, NULL);
> if (IS_ERR(data->uart_clk)) {
> dev_warn(&pdev->dev, "Can't get uart clock\n");
> return PTR_ERR(data->uart_clk);
Consider making this to be either dev_warn_once() / _ratelimited() or
better to have
return dev_err_probe(...);
This will allow to avoid flooding the logs when clock is not yet ready.
The proposed change can be done in the separate patch.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-09-15 14:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-15 13:06 [PATCH v2 1/2] tty: serial: 8250_mtk: enable baud clock Daniel Golle
2025-09-15 13:06 ` [PATCH v2 2/2] tty: serial: 8250_mtk: manage baud clock in runtime PM ops Daniel Golle
2025-09-15 13:41 ` [PATCH v2 1/2] tty: serial: 8250_mtk: enable baud clock AngeloGioacchino Del Regno
2025-09-15 14:51 ` Andy Shevchenko
2025-09-15 14:54 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox