clk: set initial best mux parent to current parent when determining rate
PATCH RESEND 1/1 clk: set initial best mux parent to current parent when determining rate
Originally, the initial clock rate is hardcoded to 0, this can lead to some problem when setting a very small rate with CLK_MUX_ROUND_NEAREST.
For example, if the lowest possible rate privided by the mux is 1000Hz, setting a rate below 500Hz will fail, because no clock can provide a better rate than the non-existant 0. But it should succeed with 1000Hz being set.
Setting the initial best parent to current parent could solve this bug very well.
---
This is actually a v2 of [1], but seems too simple to have a unittest. It's tested in a mmc host driver.
[1]: https://lore.kernel.org/linux-clk/[email protected]/
--- drivers/clk/clk.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/clk/clk.c +4 -0
@@ -649,6 +649,10 @@ int clk_mux_determine_rate_flags(struct clk_hw *hw,/* find the parent that can provide the fastest rate <= rate */ num_parents = core->num_parents; +if (core->parent) { + best_parent = core->parent; + best =clk_core_get_rate_nolock (best_parent); + }for (i =0 ; i < num_parents; i++) {unsigned long parent_rate;
---
base-commit: 8d3dea210042f54b952b481838c1e7dfc4ec751d
change-id: 20240215-mux-6db8b3714590
Best regards,
Signature · 1 line
Yang Xiwen <[email protected]>