linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2] clk: tegra: Return the exact clock rate from clk_round_rate
@ 2018-09-25 21:49 Robert Yang
  2018-10-16 22:47 ` Stephen Boyd
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Robert Yang @ 2018-09-25 21:49 UTC (permalink / raw)
  To: Peter De Schrijver
  Cc: Prashant Gaikwad, Michael Turquette, Stephen Boyd,
	Thierry Reding, Jonathan Hunter, linux-clk, linux-tegra,
	linux-kernel, Robert Yang

The current behavior is that clk_round_rate would return the same clock
rate passed to it for valid PLL configurations. This change will return
the exact rate the PLL will provide in accordance with clk API.

Signed-off-by: Robert Yang <decatf@gmail.com>
---
Changes in V2:
 - Move input divider (m == 0) check into the cfg constraints check
   condition. Forgo adding WARN_ON and avoid using 0 input divider
   all together.

 drivers/clk/tegra/clk-pll.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/clk/tegra/clk-pll.c b/drivers/clk/tegra/clk-pll.c
index 17a058c3bbc1..2a800a9c56e6 100644
--- a/drivers/clk/tegra/clk-pll.c
+++ b/drivers/clk/tegra/clk-pll.c
@@ -589,12 +589,13 @@ static int _calc_rate(struct clk_hw *hw, struct tegra_clk_pll_freq_table *cfg,
 	cfg->n = cfg->output_rate / cfreq;
 	cfg->cpcon = OUT_OF_TABLE_CPCON;
 
-	if (cfg->m > divm_max(pll) || cfg->n > divn_max(pll) ||
-	    (1 << p_div) > divp_max(pll)
-	    || cfg->output_rate > pll->params->vco_max) {
+	if (cfg->m == 0 || cfg->m > divm_max(pll) ||
+	    cfg->n > divn_max(pll) || (1 << p_div) > divp_max(pll) ||
+	    cfg->output_rate > pll->params->vco_max) {
 		return -EINVAL;
 	}
 
+	cfg->output_rate = cfg->n * DIV_ROUND_UP(parent_rate, cfg->m);
 	cfg->output_rate >>= p_div;
 
 	if (pll->params->pdiv_tohw) {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH V2] clk: tegra: Return the exact clock rate from clk_round_rate
  2018-09-25 21:49 [PATCH V2] clk: tegra: Return the exact clock rate from clk_round_rate Robert Yang
@ 2018-10-16 22:47 ` Stephen Boyd
  2018-11-27 19:40   ` Dmitry Osipenko
  2018-11-28  9:16 ` Thierry Reding
  2018-12-10 19:11 ` Stephen Boyd
  2 siblings, 1 reply; 5+ messages in thread
From: Stephen Boyd @ 2018-10-16 22:47 UTC (permalink / raw)
  To: Peter De Schrijver, Robert Yang
  Cc: Prashant Gaikwad, Michael Turquette, Thierry Reding,
	Jonathan Hunter, linux-clk, linux-tegra, linux-kernel,
	Robert Yang

Quoting Robert Yang (2018-09-25 14:49:40)
> The current behavior is that clk_round_rate would return the same clock
> rate passed to it for valid PLL configurations. This change will return
> the exact rate the PLL will provide in accordance with clk API.
> 
> Signed-off-by: Robert Yang <decatf@gmail.com>
> ---

I'm waiting for someone from Nvidia/Tegra background to review this
change.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH V2] clk: tegra: Return the exact clock rate from clk_round_rate
  2018-10-16 22:47 ` Stephen Boyd
@ 2018-11-27 19:40   ` Dmitry Osipenko
  0 siblings, 0 replies; 5+ messages in thread
From: Dmitry Osipenko @ 2018-11-27 19:40 UTC (permalink / raw)
  To: Stephen Boyd, Peter De Schrijver, Robert Yang
  Cc: Prashant Gaikwad, Michael Turquette, Thierry Reding,
	Jonathan Hunter, linux-clk, linux-tegra, linux-kernel

On 17.10.2018 1:47, Stephen Boyd wrote:
> Quoting Robert Yang (2018-09-25 14:49:40)
>> The current behavior is that clk_round_rate would return the same clock
>> rate passed to it for valid PLL configurations. This change will return
>> the exact rate the PLL will provide in accordance with clk API.
>>
>> Signed-off-by: Robert Yang <decatf@gmail.com>
>> ---
> 
> I'm waiting for someone from Nvidia/Tegra background to review this
> change.
> 

Apparently Peter is taking a pause. I think Thierry's ACK to V1 should be still valid here.

Also, if this helps:

Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Tested-by: Dmitry Osipenko <digetx@gmail.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH V2] clk: tegra: Return the exact clock rate from clk_round_rate
  2018-09-25 21:49 [PATCH V2] clk: tegra: Return the exact clock rate from clk_round_rate Robert Yang
  2018-10-16 22:47 ` Stephen Boyd
@ 2018-11-28  9:16 ` Thierry Reding
  2018-12-10 19:11 ` Stephen Boyd
  2 siblings, 0 replies; 5+ messages in thread
From: Thierry Reding @ 2018-11-28  9:16 UTC (permalink / raw)
  To: Robert Yang
  Cc: Peter De Schrijver, Prashant Gaikwad, Michael Turquette,
	Stephen Boyd, Jonathan Hunter, linux-clk, linux-tegra,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 667 bytes --]

On Tue, Sep 25, 2018 at 05:49:40PM -0400, Robert Yang wrote:
> The current behavior is that clk_round_rate would return the same clock
> rate passed to it for valid PLL configurations. This change will return
> the exact rate the PLL will provide in accordance with clk API.
> 
> Signed-off-by: Robert Yang <decatf@gmail.com>
> ---
> Changes in V2:
>  - Move input divider (m == 0) check into the cfg constraints check
>    condition. Forgo adding WARN_ON and avoid using 0 input divider
>    all together.
> 
>  drivers/clk/tegra/clk-pll.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)

Acked-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH V2] clk: tegra: Return the exact clock rate from clk_round_rate
  2018-09-25 21:49 [PATCH V2] clk: tegra: Return the exact clock rate from clk_round_rate Robert Yang
  2018-10-16 22:47 ` Stephen Boyd
  2018-11-28  9:16 ` Thierry Reding
@ 2018-12-10 19:11 ` Stephen Boyd
  2 siblings, 0 replies; 5+ messages in thread
From: Stephen Boyd @ 2018-12-10 19:11 UTC (permalink / raw)
  To: Peter De Schrijver, Robert Yang
  Cc: Prashant Gaikwad, Michael Turquette, Thierry Reding,
	Jonathan Hunter, linux-clk, linux-tegra, linux-kernel,
	Robert Yang

Quoting Robert Yang (2018-09-25 14:49:40)
> The current behavior is that clk_round_rate would return the same clock
> rate passed to it for valid PLL configurations. This change will return
> the exact rate the PLL will provide in accordance with clk API.
> 
> Signed-off-by: Robert Yang <decatf@gmail.com>
> ---

Applied to clk-next


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-12-10 19:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-25 21:49 [PATCH V2] clk: tegra: Return the exact clock rate from clk_round_rate Robert Yang
2018-10-16 22:47 ` Stephen Boyd
2018-11-27 19:40   ` Dmitry Osipenko
2018-11-28  9:16 ` Thierry Reding
2018-12-10 19:11 ` Stephen Boyd

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).