linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: zynqmp: move zynqmp_pll_set_mode out of round_rate callback
@ 2021-03-31  9:00 quanyang.wang
  2021-04-01  1:48 ` Stephen Boyd
  0 siblings, 1 reply; 3+ messages in thread
From: quanyang.wang @ 2021-03-31  9:00 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd, Laurent Pinchart, Michal Simek
  Cc: Greg Kroah-Hartman, Jolly Shah, Rajan Vaja, Quanyang Wang,
	linux-clk, linux-arm-kernel, linux-kernel

From: Quanyang Wang <quanyang.wang@windriver.com>

The round_rate callback should only perform rate calculation and not
involve calling zynqmp_pll_set_mode to change the pll mode. So let's
move zynqmp_pll_set_mode out of round_rate and to set_rate callback.

Reported-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Quanyang Wang <quanyang.wang@windriver.com>
---
 drivers/clk/zynqmp/pll.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/clk/zynqmp/pll.c b/drivers/clk/zynqmp/pll.c
index fb16ddbb7e2d..1aea5c137b69 100644
--- a/drivers/clk/zynqmp/pll.c
+++ b/drivers/clk/zynqmp/pll.c
@@ -104,9 +104,7 @@ static long zynqmp_pll_round_rate(struct clk_hw *hw, unsigned long rate,
 	/* Enable the fractional mode if needed */
 	rate_div = (rate * FRAC_DIV) / *prate;
 	f = rate_div % FRAC_DIV;
-	zynqmp_pll_set_mode(hw, !!f);
-
-	if (zynqmp_pll_get_mode(hw) == PLL_MODE_FRAC) {
+	if (f) {
 		if (rate > PS_PLL_VCO_MAX) {
 			fbdiv = rate / PS_PLL_VCO_MAX;
 			rate = rate / (fbdiv + 1);
@@ -177,10 +175,12 @@ static int zynqmp_pll_set_rate(struct clk_hw *hw, unsigned long rate,
 	long rate_div, frac, m, f;
 	int ret;
 
-	if (zynqmp_pll_get_mode(hw) == PLL_MODE_FRAC) {
-		rate_div = (rate * FRAC_DIV) / parent_rate;
+	rate_div = (rate * FRAC_DIV) / parent_rate;
+	f = rate_div % FRAC_DIV;
+	zynqmp_pll_set_mode(hw, !!f);
+
+	if (f) {
 		m = rate_div / FRAC_DIV;
-		f = rate_div % FRAC_DIV;
 		m = clamp_t(u32, m, (PLL_FBDIV_MIN), (PLL_FBDIV_MAX));
 		rate = parent_rate * m;
 		frac = (parent_rate * f) / FRAC_DIV;
-- 
2.25.1


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

* Re: [PATCH] clk: zynqmp: move zynqmp_pll_set_mode out of round_rate callback
  2021-03-31  9:00 [PATCH] clk: zynqmp: move zynqmp_pll_set_mode out of round_rate callback quanyang.wang
@ 2021-04-01  1:48 ` Stephen Boyd
  2021-04-01  2:01   ` quanyang.wang
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Boyd @ 2021-04-01  1:48 UTC (permalink / raw)
  To: Laurent Pinchart, Michael Turquette, Michal Simek, quanyang.wang
  Cc: Greg Kroah-Hartman, Jolly Shah, Rajan Vaja, Quanyang Wang,
	linux-clk, linux-arm-kernel, linux-kernel

Quoting quanyang.wang@windriver.com (2021-03-31 02:00:18)
> From: Quanyang Wang <quanyang.wang@windriver.com>
> 
> The round_rate callback should only perform rate calculation and not
> involve calling zynqmp_pll_set_mode to change the pll mode. So let's
> move zynqmp_pll_set_mode out of round_rate and to set_rate callback.
> 
> Reported-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Quanyang Wang <quanyang.wang@windriver.com>
> ---

Any Fixes tag?

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

* Re: [PATCH] clk: zynqmp: move zynqmp_pll_set_mode out of round_rate callback
  2021-04-01  1:48 ` Stephen Boyd
@ 2021-04-01  2:01   ` quanyang.wang
  0 siblings, 0 replies; 3+ messages in thread
From: quanyang.wang @ 2021-04-01  2:01 UTC (permalink / raw)
  To: Stephen Boyd, Laurent Pinchart, Michael Turquette, Michal Simek
  Cc: Greg Kroah-Hartman, Jolly Shah, Rajan Vaja, linux-clk,
	linux-arm-kernel, linux-kernel

Hi Stephen,

On 4/1/21 9:48 AM, Stephen Boyd wrote:
> Quoting quanyang.wang@windriver.com (2021-03-31 02:00:18)
>> From: Quanyang Wang <quanyang.wang@windriver.com>
>>
>> The round_rate callback should only perform rate calculation and not
>> involve calling zynqmp_pll_set_mode to change the pll mode. So let's
>> move zynqmp_pll_set_mode out of round_rate and to set_rate callback.
>>
>> Reported-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>> Signed-off-by: Quanyang Wang <quanyang.wang@windriver.com>
>> ---
> Any Fixes tag?

Thanks for your reminder. I will add Fixes tag at the V2 version patch.

Thanks,

Quanyang


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

end of thread, other threads:[~2021-04-01  2:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-31  9:00 [PATCH] clk: zynqmp: move zynqmp_pll_set_mode out of round_rate callback quanyang.wang
2021-04-01  1:48 ` Stephen Boyd
2021-04-01  2:01   ` quanyang.wang

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