linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: moinejf@free.fr (Jean-Francois Moine)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] clk: sunxi: Accept a greater rate when setting a parent clock
Date: Thu, 10 Mar 2016 08:15:02 +0100	[thread overview]
Message-ID: <mailman.11.1457597843.1636.linux-arm-kernel@lists.infradead.org> (raw)

The best rate of a clock may be a bit greater than the requested one.
In such a case, the rate setting from a child clock was rejected.

Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
---
I don't know exactly why the rate constraint existed nor what can be
the impact of setting the rate of other clocks.

I had the problem when setting the PLL2 clock of the H3 (patch to come).
It has 4 outputs, so, it is composed of a base clock and 4 children
clocks pll2, pll2x2, pll2x4 and pll2x8 with a fixed factor (/4, /2, 1
and *2).
The pll2 clock rate may be only 24576000 (for the audio family 48000Hz)
or 22579200 (for the audio family 44100Hz).

Setting 24576000 asks for mul=86 and div=21,4 giving 24571428 as the
best rate, i.e. a bit slower than requested: good.

Setting 22579200 asks for mul=64 and div=17,4 giving 22588235, i.e.
a bit greater: then, the rate setting was rejected (no parent clock),
preventing audio streaming at 44100Hz.
---
 drivers/clk/sunxi/clk-factors.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/sunxi/clk-factors.c b/drivers/clk/sunxi/clk-factors.c
index 59428db..d0774c2 100644
--- a/drivers/clk/sunxi/clk-factors.c
+++ b/drivers/clk/sunxi/clk-factors.c
@@ -86,7 +86,7 @@ static int clk_factors_determine_rate(struct clk_hw *hw,
 	int i, num_parents;
 	unsigned long parent_rate, best = 0, child_rate, best_child_rate = 0;
 
-	/* find the parent that can help provide the fastest rate <= rate */
+	/* find the parent that can help provide the fastest rate */
 	num_parents = clk_hw_get_num_parents(hw);
 	for (i = 0; i < num_parents; i++) {
 		parent = clk_hw_get_parent_by_index(hw, i);
@@ -100,7 +100,7 @@ static int clk_factors_determine_rate(struct clk_hw *hw,
 		child_rate = clk_factors_round_rate(hw, req->rate,
 						    &parent_rate);
 
-		if (child_rate <= req->rate && child_rate > best_child_rate) {
+		if (child_rate > best_child_rate) {
 			best_parent = parent;
 			best = parent_rate;
 			best_child_rate = child_rate;
-- 
2.7.2

             reply	other threads:[~2016-03-10  7:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-10  7:15 Jean-Francois Moine [this message]
     [not found] <E1advmk-0004Nt-Ba@bombadil.infradead.org>
2016-03-18  7:47 ` [PATCH] clk: sunxi: Accept a greater rate when setting a parent clock Jean-Francois Moine
     [not found] <20160310081658.B749246B@mail.free-electrons.com>
2016-03-21  7:25 ` Maxime Ripard
2016-03-21  8:25   ` Jean-Francois Moine
2016-03-29  9:38     ` Maxime Ripard
2016-03-29 10:08       ` Jean-Francois Moine
2016-03-30 20:49     ` Emilio López
2016-04-14 17:24       ` Maxime Ripard
2016-04-14 18:14         ` Jean-Francois Moine
2016-04-14 19:31           ` Maxime Ripard

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=mailman.11.1457597843.1636.linux-arm-kernel@lists.infradead.org \
    --to=moinejf@free.fr \
    --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).