Skip to contentSkip to conversation

clk: Fix clk_set_parent() regression

PATCH Superseded Jonas Karlman 3 participants 3 messages Apr 19, 2025 – Apr 22, 2025 Common clk

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clk: Fix clk_set_parent() regression

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")
---
 drivers/clk/clk-uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/clk-uclass.c +1 -1
index 4b3d812f9c65..93dd32ebe74d 100644
@@ -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;
 	}
Signature · 1 line
2.49.0
Tested-by on v1 1/1
#1 lore raw

Hi Jonas,

Tested on PineTab 2 (RK3566) and this got rid of "Cannot enable parent" errors.

Quoted 37 lines · Jonas Karlman

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")
---
 drivers/clk/clk-uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/clk-uclass.c +1 -1
index 4b3d812f9c65..93dd32ebe74d 100644
@@ -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;
 	}
Signature · 1 line
2.49.0
Acked-by on v1 1/1
#2 lore raw
In reply to Jonas Karlman
Quoted 10 lines · Jonas Karlman

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.

Quoted 6 lines

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")

Thanks for the fix,

Miquèl