* [PATCH] clk: Fix clk_set_parent() regression
@ 2025-04-19 9:07 Jonas Karlman
2025-04-19 9:13 ` Dang Huynh
2025-04-22 7:47 ` Miquel Raynal
0 siblings, 2 replies; 3+ messages in thread
From: Jonas Karlman @ 2025-04-19 9:07 UTC (permalink / raw)
To: Lukasz Majewski, Sean Anderson, Tom Rini, Miquel Raynal
Cc: Kever Yang, Dang Huynh, Jonas Karlman, u-boot
The commit ac30d90f3367 ("clk: Ensure the parent clocks are enabled
while reparenting") add a call to clk_enable() for the parent clock.
For clock drivers that do not implement the enable() ops, like most
Rockchip clock drivers, this now cause the set_parent() ops to never
be called when CLK_CCF=n (default for Rockchip).
clk_enable() typically return -NOSYS when the enable() ops is not
implemented by the clock driver, with CLK_CCF=y clk_enable() instead
return 0 when the enable() ops is unimplemented.
Change to ignore -NOSYS from the newly introduced clk_enable() call to
fix this regression and restore the old behavior of set_parent() ops
being called regardless of if enable() ops is implemented or not.
Fixes: ac30d90f3367 ("clk: Ensure the parent clocks are enabled while reparenting")
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
---
drivers/clk/clk-uclass.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index 4b3d812f9c65..93dd32ebe74d 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -624,7 +624,7 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
return -ENOSYS;
ret = clk_enable(parent);
- if (ret) {
+ if (ret && ret != -ENOSYS) {
printf("Cannot enable parent %s\n", parent->dev->name);
return ret;
}
--
2.49.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] clk: Fix clk_set_parent() regression
2025-04-19 9:07 [PATCH] clk: Fix clk_set_parent() regression Jonas Karlman
@ 2025-04-19 9:13 ` Dang Huynh
2025-04-22 7:47 ` Miquel Raynal
1 sibling, 0 replies; 3+ messages in thread
From: Dang Huynh @ 2025-04-19 9:13 UTC (permalink / raw)
To: Jonas Karlman
Cc: Lukasz Majewski, Sean Anderson, Tom Rini, Miquel Raynal,
Kever Yang, u-boot
Hi Jonas,
Tested on PineTab 2 (RK3566) and this got rid of "Cannot enable parent"
errors.
Tested-by: Dang Huynh <danct12@riseup.net>
On Sat, Apr 19, 2025 at 09:07:16AM +0000, Jonas Karlman wrote:
> The commit ac30d90f3367 ("clk: Ensure the parent clocks are enabled
> while reparenting") add a call to clk_enable() for the parent clock.
>
> For clock drivers that do not implement the enable() ops, like most
> Rockchip clock drivers, this now cause the set_parent() ops to never
> be called when CLK_CCF=n (default for Rockchip).
>
> clk_enable() typically return -NOSYS when the enable() ops is not
> implemented by the clock driver, with CLK_CCF=y clk_enable() instead
> return 0 when the enable() ops is unimplemented.
>
> Change to ignore -NOSYS from the newly introduced clk_enable() call to
> fix this regression and restore the old behavior of set_parent() ops
> being called regardless of if enable() ops is implemented or not.
>
> Fixes: ac30d90f3367 ("clk: Ensure the parent clocks are enabled while reparenting")
> Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
> ---
> drivers/clk/clk-uclass.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
> index 4b3d812f9c65..93dd32ebe74d 100644
> --- a/drivers/clk/clk-uclass.c
> +++ b/drivers/clk/clk-uclass.c
> @@ -624,7 +624,7 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
> return -ENOSYS;
>
> ret = clk_enable(parent);
> - if (ret) {
> + if (ret && ret != -ENOSYS) {
> printf("Cannot enable parent %s\n", parent->dev->name);
> return ret;
> }
> --
> 2.49.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] clk: Fix clk_set_parent() regression
2025-04-19 9:07 [PATCH] clk: Fix clk_set_parent() regression Jonas Karlman
2025-04-19 9:13 ` Dang Huynh
@ 2025-04-22 7:47 ` Miquel Raynal
1 sibling, 0 replies; 3+ messages in thread
From: Miquel Raynal @ 2025-04-22 7:47 UTC (permalink / raw)
To: Jonas Karlman
Cc: Lukasz Majewski, Sean Anderson, Tom Rini, Kever Yang, Dang Huynh,
u-boot
On 19/04/2025 at 09:07:16 GMT, Jonas Karlman <jonas@kwiboo.se> wrote:
> The commit ac30d90f3367 ("clk: Ensure the parent clocks are enabled
> while reparenting") add a call to clk_enable() for the parent clock.
>
> For clock drivers that do not implement the enable() ops, like most
> Rockchip clock drivers, this now cause the set_parent() ops to never
> be called when CLK_CCF=n (default for Rockchip).
>
> clk_enable() typically return -NOSYS when the enable() ops is not
> implemented by the clock driver, with CLK_CCF=y clk_enable() instead
> return 0 when the enable() ops is unimplemented.
I am really not a big fan of this logic to return low-level information
in high-level helpers. I am constantly disagreeing with this approach
because this is exactly the kind of breakage it leads to.
> Change to ignore -NOSYS from the newly introduced clk_enable() call to
> fix this regression and restore the old behavior of set_parent() ops
> being called regardless of if enable() ops is implemented or not.
>
> Fixes: ac30d90f3367 ("clk: Ensure the parent clocks are enabled while reparenting")
> Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Thanks for the fix,
Acked-by: Miquel Raynal <miquel.raynal@bootlin.com>
Miquèl
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-04-22 12:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-19 9:07 [PATCH] clk: Fix clk_set_parent() regression Jonas Karlman
2025-04-19 9:13 ` Dang Huynh
2025-04-22 7:47 ` Miquel Raynal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox