Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9bffb963 authored by Vikram Mulukutla's avatar Vikram Mulukutla
Browse files

clk: qcom: clock-generic: Don't assume parent rate



The try_get_rate flag, when set, allows the mux code to
optimize selecting a parent by checking if a parent is
already at the required rate. However if that parent has
the CLKFLAG_NO_RATE_CACHE flag set, it is possible that
the rate on the parent is stale, and needs to be set again.
Remove the optimization that does an early-exit if the
parent's rate is the requested rate.

Furthermore, some sources may not be able to support
a rate since their own parents may have stale rates.
Confirm that a source can still support a rate by
invoking clk_round_rate on it. The try_get_rate flag
remains useful in real implementations since it
still selects parent already at a given rate that
don't have the restrictions mentioned above.

Change-Id: I4e0c5db934d39ad046755483acf74865b75ca61f
Signed-off-by: default avatarVikram Mulukutla <markivx@codeaurora.org>
parent deb052f1
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -104,15 +104,13 @@ static int mux_set_rate(struct clk *c, unsigned long rate)
	 * rate.
	 */
	for (i = 0; i < mux->num_parents && mux->try_get_rate; i++) {
		if (mux->parents[i].src->rate == rate) {
		struct clk *p = mux->parents[i].src;
		if (p->rate == rate && clk_round_rate(p, rate) == rate) {
			new_parent = mux->parents[i].src;
			break;
		}
	}

	if (new_parent == c->parent && rate == c->rate)
		return 0;

	for (i = 0; i < mux->num_parents && !(!i && new_parent); i++) {
		if (clk_round_rate(mux->parents[i].src, rate) == rate) {
			new_parent = mux->parents[i].src;