Commit 63f5c3b2 authored by Mike Turquette's avatar Mike Turquette

clk: prevent spurious parent rate propagation

Patch 'clk: always pass parent_rate into .round_rate' made a subtle
change to the semantics of .round_rate.  It is now expected for the
parent's rate to always be passed in, simplifying the implemenation of
various .round_rate callback definitions.

However the patch also introduced a bug in clk_calc_new_rates whereby a
clock without the CLK_SET_RATE_PARENT flag set could still propagate a
rate change up to a parent clock if the the .round_rate callback
modified the &best_parent_rate value in any way.

This patch fixes the issue at the framework level (in
clk_calc_new_rates) by specifically handling the case where the
CLK_SET_RATE_PARENT flag is not set.
Signed-off-by: default avatarMike Turquette <mturquette@linaro.org>
Acked-by: default avatarSascha Hauer <s.hauer@pengutronix.de>
parent 7704addb
...@@ -774,12 +774,18 @@ static struct clk *clk_calc_new_rates(struct clk *clk, unsigned long rate) ...@@ -774,12 +774,18 @@ static struct clk *clk_calc_new_rates(struct clk *clk, unsigned long rate)
if (IS_ERR_OR_NULL(clk)) if (IS_ERR_OR_NULL(clk))
return NULL; return NULL;
/* save parent rate, if it exists */
if (clk->parent)
best_parent_rate = clk->parent->rate;
/* never propagate up to the parent */ /* never propagate up to the parent */
if (!(clk->flags & CLK_SET_RATE_PARENT)) { if (!(clk->flags & CLK_SET_RATE_PARENT)) {
if (!clk->ops->round_rate) { if (!clk->ops->round_rate) {
clk->new_rate = clk->rate; clk->new_rate = clk->rate;
return NULL; return NULL;
} }
new_rate = clk->ops->round_rate(clk->hw, rate, &best_parent_rate);
goto out;
} }
/* need clk->parent from here on out */ /* need clk->parent from here on out */
...@@ -795,7 +801,6 @@ static struct clk *clk_calc_new_rates(struct clk *clk, unsigned long rate) ...@@ -795,7 +801,6 @@ static struct clk *clk_calc_new_rates(struct clk *clk, unsigned long rate)
goto out; goto out;
} }
best_parent_rate = clk->parent->rate;
new_rate = clk->ops->round_rate(clk->hw, rate, &best_parent_rate); new_rate = clk->ops->round_rate(clk->hw, rate, &best_parent_rate);
if (best_parent_rate != clk->parent->rate) { if (best_parent_rate != clk->parent->rate) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment