linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: mturquette@linaro.org (Mike Turquette)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/5] clk: prevent spurious parent rate propagation
Date: Sun, 6 May 2012 22:08:27 -0700	[thread overview]
Message-ID: <1336367310-5140-3-git-send-email-mturquette@linaro.org> (raw)
In-Reply-To: <1336367310-5140-1-git-send-email-mturquette@linaro.org>

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: Mike Turquette <mturquette@linaro.org>
Reported-by: Sascha Hauer<s.hauer@pengutronix.de>
---
 drivers/clk/clk.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 8149764..7ceca0e 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -774,12 +774,18 @@ static struct clk *clk_calc_new_rates(struct clk *clk, unsigned long rate)
 	if (IS_ERR_OR_NULL(clk))
 		return NULL;
 
+	/* save parent rate, if it exists */
+	if (clk->parent)
+		best_parent_rate = clk->parent->rate;
+
 	/* never propagate up to the parent */
 	if (!(clk->flags & CLK_SET_RATE_PARENT)) {
 		if (!clk->ops->round_rate) {
 			clk->new_rate = clk->rate;
 			return NULL;
 		}
+		new_rate = clk->ops->round_rate(clk->hw, rate, &best_parent_rate);
+		goto 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)
 		goto out;
 	}
 
-	best_parent_rate = clk->parent->rate;
 	new_rate = clk->ops->round_rate(clk->hw, rate, &best_parent_rate);
 
 	if (best_parent_rate != clk->parent->rate) {
-- 
1.7.5.4

  parent reply	other threads:[~2012-05-07  5:08 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-07  5:08 [PATCH 0/5] more clk-next fixes Mike Turquette
2012-05-07  5:08 ` [PATCH 1/5] MAINTAINERS: add entry for common clk framework Mike Turquette
2012-05-07  5:08 ` Mike Turquette [this message]
2012-05-07  7:58   ` [PATCH 2/5] clk: prevent spurious parent rate propagation Sascha Hauer
2012-05-07 17:34     ` Turquette, Mike
2012-05-07  5:08 ` [PATCH 3/5] clk: remove COMMON_CLK_DISABLE_UNUSED Mike Turquette
2012-05-07 19:31   ` Saravana Kannan
2012-05-07  5:08 ` [PATCH 4/5] clk: mux: assign init data Mike Turquette
2012-05-07  5:08 ` [PATCH 5/5] clk: add a fixed factor clock Mike Turquette
2012-05-07 19:54   ` Saravana Kannan
2012-05-07 20:14     ` Turquette, Mike
2012-05-07 20:26       ` Saravana Kannan
2012-05-08  7:20 ` [PATCH 0/5] more clk-next fixes Andrew Lunn
2012-05-08 16:12 ` Shawn Guo
2012-05-08 17:33   ` Turquette, Mike
2012-05-08 21:35 ` Turquette, Mike
2012-05-11 14:39   ` Arnd Bergmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1336367310-5140-3-git-send-email-mturquette@linaro.org \
    --to=mturquette@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).