* [PATCH v3] serial: 8250_mtk: Enable baud clock and manage in runtime PM
@ 2025-09-16 21:37 Daniel Golle
2025-09-17 10:00 ` Matthias Brugger
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Golle @ 2025-09-16 21:37 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby, Matthias Brugger,
AngeloGioacchino Del Regno, Daniel Golle, Yu Jiaoliang,
Uwe Kleine-König, 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.
Request the baud clock to be prepared and enabled during probe, and to
restore run-time power management capabilities to what it was before commit
e32a83c70cf9 ("serial: 8250-mtk: modify mtk uart power and clock
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")
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
v3: squash into single patch
v2: add managing run-time PM in dedicated patch
drivers/tty/serial/8250/8250_mtk.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c
index b44de2ed7413..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;
}
@@ -475,13 +477,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] 3+ messages in thread
* Re: [PATCH v3] serial: 8250_mtk: Enable baud clock and manage in runtime PM
2025-09-16 21:37 [PATCH v3] serial: 8250_mtk: Enable baud clock and manage in runtime PM Daniel Golle
@ 2025-09-17 10:00 ` Matthias Brugger
2025-10-19 2:02 ` Daniel Golle
0 siblings, 1 reply; 3+ messages in thread
From: Matthias Brugger @ 2025-09-17 10:00 UTC (permalink / raw)
To: Daniel Golle, Greg Kroah-Hartman, Jiri Slaby,
AngeloGioacchino Del Regno, Yu Jiaoliang, Uwe Kleine-König,
Andy Shevchenko, Changqi Hu, Sam Shih, Steven Liu, John Crispin,
linux-kernel, linux-serial, linux-arm-kernel, linux-mediatek
On 16/09/2025 23:37, Daniel Golle wrote:
> 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.
>
> Request the baud clock to be prepared and enabled during probe, and to
> restore run-time power management capabilities to what it was before commit
> e32a83c70cf9 ("serial: 8250-mtk: modify mtk uart power and clock
> 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")
Most of the issues from this commit are already fixed in
b6c7ff2693ddc ("serial: 8250_mtk: Simplify clock sequencing and runtime PM")
which is more or less a revert of e32a83c70cf9.
I think we should add
Fixes: b6c7ff2693ddc ("serial: 8250_mtk: Simplify clock sequencing and runtime PM")
here as well. It's a fix of a fix :)
Regards,
Matthias
> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Signed-off-by: Daniel Golle <daniel@makrotopia.org>
> ---
> v3: squash into single patch
> v2: add managing run-time PM in dedicated patch
>
> drivers/tty/serial/8250/8250_mtk.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c
> index b44de2ed7413..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;
> }
> @@ -475,13 +477,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] 3+ messages in thread
* Re: [PATCH v3] serial: 8250_mtk: Enable baud clock and manage in runtime PM
2025-09-17 10:00 ` Matthias Brugger
@ 2025-10-19 2:02 ` Daniel Golle
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Golle @ 2025-10-19 2:02 UTC (permalink / raw)
To: Matthias Brugger
Cc: Greg Kroah-Hartman, Jiri Slaby, AngeloGioacchino Del Regno,
Yu Jiaoliang, Uwe Kleine-König, Andy Shevchenko, Changqi Hu,
Sam Shih, Steven Liu, John Crispin, linux-kernel, linux-serial,
linux-arm-kernel, linux-mediatek
On Wed, Sep 17, 2025 at 12:00:57PM +0200, Matthias Brugger wrote:
> On 16/09/2025 23:37, Daniel Golle wrote:
> > 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.
> >
> > Request the baud clock to be prepared and enabled during probe, and to
> > restore run-time power management capabilities to what it was before commit
> > e32a83c70cf9 ("serial: 8250-mtk: modify mtk uart power and clock
> > 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")
>
> Most of the issues from this commit are already fixed in
> b6c7ff2693ddc ("serial: 8250_mtk: Simplify clock sequencing and runtime PM")
> which is more or less a revert of e32a83c70cf9.
>
> I think we should add
> Fixes: b6c7ff2693ddc ("serial: 8250_mtk: Simplify clock sequencing and runtime PM")
> here as well. It's a fix of a fix :)
Just a friendly ping about this patch :)
Should I resend the patch with the added Fixes:-tag? Or can it be merged
including the tag added my Matthias without a resend?
>
> Regards,
> Matthias
>
>
> > Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> > Signed-off-by: Daniel Golle <daniel@makrotopia.org>
> > ---
> > v3: squash into single patch
> > v2: add managing run-time PM in dedicated patch
> >
> > drivers/tty/serial/8250/8250_mtk.c | 6 ++++--
> > 1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c
> > index b44de2ed7413..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;
> > }
> > @@ -475,13 +477,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] 3+ messages in thread
end of thread, other threads:[~2025-10-19 2:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-16 21:37 [PATCH v3] serial: 8250_mtk: Enable baud clock and manage in runtime PM Daniel Golle
2025-09-17 10:00 ` Matthias Brugger
2025-10-19 2:02 ` Daniel Golle
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).