Skip to contentSkip to conversation

clk: scmi: Fix the rounding of clock rate

PATCH In review Amit Daniel Kachhap 3 participants 9 messages Jul 27, 2018 – Aug 2, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clk: scmi: Fix the rounding of clock rate

This fix rounds the clock rate properly by using quotient and not remainder in the calculation. This issue was found while testing HDMI in the Juno platform.

---
 drivers/clk/clk-scmi.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/clk/clk-scmi.c +2 -3
index bb2a6f2..a985bf5 100644
@@ -38,7 +38,6 @@ static unsigned long scmi_clk_recalc_rate(struct clk_hw *hw,
 static long scmi_clk_round_rate(struct clk_hw *hw, unsigned long rate,
 				unsigned long *parent_rate)
 {
-	int step;
 	u64 fmin, fmax, ftmp;
 	struct scmi_clk *clk = to_scmi_clk(hw);
 
@@ -60,9 +59,9 @@ static long scmi_clk_round_rate(struct clk_hw *hw, unsigned long rate,
 
 	ftmp = rate - fmin;
 	ftmp += clk->info->range.step_size - 1; /* to round up */
-	step = do_div(ftmp, clk->info->range.step_size);
+	do_div(ftmp, clk->info->range.step_size);
 
-	return step * clk->info->range.step_size + fmin;
+	return ftmp * clk->info->range.step_size + fmin;
 }
 
 static int scmi_clk_set_rate(struct clk_hw *hw, unsigned long rate,
Signature · 1 line
2.7.4
maintainer
#1 lore raw

Quoting Amit Daniel Kachhap (2018-07-27 07:01:52)

Quoted 5 lines

This fix rounds the clock rate properly by using quotient and not remainder in the calculation. This issue was found while testing HDMI in the Juno platform.

Any Fixes: tag here?

Quoted 9 lines
---
 drivers/clk/clk-scmi.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/clk/clk-scmi.c +0 -0
index bb2a6f2..a985bf5 100644

drivers/clk/clk-scmi.c static long scmi_clk_round_rate(struct clk_hw *hw, unsigned long rate, · line 64

Quoted 8 lines
drivers/clk/clk-scmi.c +2 -2
@@ -60,9 +59,9 @@ static long scmi_clk_round_rate(struct clk_hw *hw, unsigned long rate,
 
        ftmp = rate - fmin;
        ftmp += clk->info->range.step_size - 1; /* to round up */
-       step = do_div(ftmp, clk->info->range.step_size);
+       do_div(ftmp, clk->info->range.step_size);
 
-       return step * clk->info->range.step_size + fmin;
+       return ftmp * clk->info->range.step_size + fmin;

Good catch.

#2 lore raw

Hi,

Quoted 8 lines · Stephen Boyd

Quoting Amit Daniel Kachhap (2018-07-27 07:01:52)

Quoted 5 lines

This fix rounds the clock rate properly by using quotient and not remainder in the calculation. This issue was found while testing HDMI in the Juno platform.

Any Fixes: tag here?

Yes, This patch is tested with Linux v4.18-rc6 tag.

Quoted 16 lines
Quoted 16 lines
---
 drivers/clk/clk-scmi.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/clk/clk-scmi.c +1 -1
index bb2a6f2..a985bf5 100644
@@ -60,9 +59,9 @@ static long scmi_clk_round_rate(struct clk_hw *hw, unsigned long rate,
 
        ftmp = rate - fmin;
        ftmp += clk->info->range.step_size - 1; /* to round up */
-       step = do_div(ftmp, clk->info->range.step_size);
+       do_div(ftmp, clk->info->range.step_size);
 
Quoted 4 lines

drivers/clk/clk-scmi.c static long scmi_clk_round_rate(struct clk_hw *hw, unsigned long rate, · line 64

Quoted 2 lines
drivers/clk/clk-scmi.c +1 -1
-       return step * clk->info->range.step_size + fmin;
+       return ftmp * clk->info->range.step_size + fmin;

Good catch.

Thanks.

Quoted 1 line

Regards,
Amit

#3 lore raw
In reply to Amit Daniel Kachhap
Quoted 4 lines · Amit Daniel Kachhap

Hi,

Quoted 1 line · Stephen Boyd

Quoting Amit Daniel Kachhap (2018-07-27 07:01:52)

Quoted 9 lines
Quoted 7 lines
Quoted 5 lines

This fix rounds the clock rate properly by using quotient and not remainder in the calculation. This issue was found while testing HDMI in the Juno platform.

Any Fixes: tag here?

Yes, This patch is tested with Linux v4.18-rc6 tag.

No Stephen meant the commit that this fixes, something like below:

Fixes 6d6a1d82eaef ("clk: add support for clocks provided by SCMI")

so that it can get backported if required.

--
Regards,
Sudeep

maintainer
#4 lore raw

Quoting Sudeep Holla (2018-07-30 04:40:56)

Quoted 12 lines · Amit Daniel Kachhap
Quoted 11 lines

Hi,

Quoted 8 lines · Stephen Boyd

Quoting Amit Daniel Kachhap (2018-07-27 07:01:52)

Quoted 5 lines

This fix rounds the clock rate properly by using quotient and not remainder in the calculation. This issue was found while testing HDMI in the Juno platform.

Any Fixes: tag here?

Quoted 9 lines
Quoted 2 lines

Yes, This patch is tested with Linux v4.18-rc6 tag.

No Stephen meant the commit that this fixes, something like below:

Fixes 6d6a1d82eaef ("clk: add support for clocks provided by SCMI")

so that it can get backported if required.

Yep! Thanks!

#7 lore raw
In reply to Sudeep Holla
Quoted 12 lines · Sudeep Holla
Quoted 11 lines · Amit Daniel Kachhap

Hi,

Quoted 8 lines · Stephen Boyd

Quoting Amit Daniel Kachhap (2018-07-27 07:01:52)

Quoted 5 lines

This fix rounds the clock rate properly by using quotient and not remainder in the calculation. This issue was found while testing HDMI in the Juno platform.

Any Fixes: tag here?

Quoted 8 lines
Quoted 2 lines

Yes, This patch is tested with Linux v4.18-rc6 tag.

No Stephen meant the commit that this fixes, something like below:

Fixes 6d6a1d82eaef ("clk: add support for clocks provided by SCMI")

so that it can get backported if required.

ok my mistake. Thanks for the clarification.

Quoted 4 lines

--
Regards,
Sudeep

#5 lore raw

PATCH 1/1 clk: scmi: Fix the rounding of clock rate

In reply to Stephen Boyd

This fix rounds the clock rate properly by using quotient and not remainder in the calculation. This issue was found while testing HDMI in the Juno platform.

Fixes 6d6a1d82eaef7 ("clk: add support for clocks provided by SCMI")
---
 drivers/clk/clk-scmi.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/clk/clk-scmi.c +2 -3
index bb2a6f2..a985bf5 100644
@@ -38,7 +38,6 @@ static unsigned long scmi_clk_recalc_rate(struct clk_hw *hw,
 static long scmi_clk_round_rate(struct clk_hw *hw, unsigned long rate,
 				unsigned long *parent_rate)
 {
-	int step;
 	u64 fmin, fmax, ftmp;
 	struct scmi_clk *clk = to_scmi_clk(hw);
 
@@ -60,9 +59,9 @@ static long scmi_clk_round_rate(struct clk_hw *hw, unsigned long rate,
 
 	ftmp = rate - fmin;
 	ftmp += clk->info->range.step_size - 1; /* to round up */
-	step = do_div(ftmp, clk->info->range.step_size);
+	do_div(ftmp, clk->info->range.step_size);
 
-	return step * clk->info->range.step_size + fmin;
+	return ftmp * clk->info->range.step_size + fmin;
 }
 
 static int scmi_clk_set_rate(struct clk_hw *hw, unsigned long rate,
Signature · 1 line
2.7.4
maintainer Applied
#6 lore raw

Quoting Amit Daniel Kachhap (2018-07-30 22:55:55)

Quoted 8 lines

This fix rounds the clock rate properly by using quotient and not remainder in the calculation. This issue was found while testing HDMI in the Juno platform.

Fixes 6d6a1d82eaef7 ("clk: add support for clocks provided by SCMI")

---

Applied to clk-next