Skip to contentSkip to conversation

clk: qcom: Use parent rate when set rate to pixel RCG clock

PATCH Applied Hai Li 3 participants 5 messages Jun 25, 2015 – Jul 6, 2015

Subsystems (3)
lore
Share & tools
lore

Hai Li

author
#0 lore raw

PATCH 1/1 clk: qcom: Use parent rate when set rate to pixel RCG clock

Since the parent rate has been recalculated, pixel RCG clock should rely on it to find the correct M/N values during set_rate, instead of calling __clk_round_rate() to its parent again.

---
 drivers/clk/qcom/clk-rcg2.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/clk/qcom/clk-rcg2.c +2 -1
index 4d3e2f7..b344899 100644
@@ -615,10 +615,11 @@ static int clk_pixel_set_rate(struct clk_hw *hw, unsigned long rate,
 	if (!parent)
 		return -EINVAL;
 
+	src_rate = parent_rate;
+
 	for (; frac->num; frac++) {
 		request = (rate * frac->den) / frac->num;
 
-		src_rate = __clk_round_rate(parent, request);
 		if ((src_rate < (request - delta)) ||
 			(src_rate > (request + delta)))
 			continue;
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
Tested-by on v1 1/1
#1 lore raw
Quoted 3 lines · Hai Li

Since the parent rate has been recalculated, pixel RCG clock should rely on it to find the correct M/N values during set_rate, instead of calling __clk_round_rate() to its parent again.

Quoted 24 lines
---
  drivers/clk/qcom/clk-rcg2.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/clk/qcom/clk-rcg2.c +2 -1
index 4d3e2f7..b344899 100644
@@ -615,10 +615,11 @@ static int clk_pixel_set_rate(struct clk_hw *hw, unsigned long rate,
  	if (!parent)
  		return -EINVAL;
 
+	src_rate = parent_rate;
+
  	for (; frac->num; frac++) {
  		request = (rate * frac->den) / frac->num;
 
-		src_rate = __clk_round_rate(parent, request);
  		if ((src_rate < (request - delta)) ||
  			(src_rate > (request + delta)))
  			continue;
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
Applied
#2 lore raw
In reply to Hai Li
Quoted 6 lines · Hai Li

Since the parent rate has been recalculated, pixel RCG clock should rely on it to find the correct M/N values during set_rate, instead of calling __clk_round_rate() to its parent again.

---

Applied to clk-fixes, but please send patches based on clk-fixes/clk-next instead of whatever was done here. I had to fixup conflicts.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
author
#3 lore raw

PATCH v2 1/1 clk: qcom: Use parent rate when set rate to pixel RCG clock

In reply to Hai Li

Since the parent rate has been recalculated, pixel RCG clock should rely on it to find the correct M/N values during set_rate, instead of calling __clk_round_rate() to its parent again.

v2: Rebase on clk-next and avoid build warning

Fixes 99cbd064b059 ("clk: qcom: Support display RCG clocks")
---
 drivers/clk/qcom/clk-rcg2.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/clk/qcom/clk-rcg2.c +3 -6
index b95d17f..92936f0 100644
@@ -530,19 +530,16 @@ static int clk_pixel_set_rate(struct clk_hw *hw, unsigned long rate,
 	struct clk_rcg2 *rcg = to_clk_rcg2(hw);
 	struct freq_tbl f = *rcg->freq_tbl;
 	const struct frac_entry *frac = frac_table_pixel;
-	unsigned long request, src_rate;
+	unsigned long request;
 	int delta = 100000;
 	u32 mask = BIT(rcg->hid_width) - 1;
 	u32 hid_div;
-	int index = qcom_find_src_index(hw, rcg->parent_map, f.src);
-	struct clk *parent = clk_get_parent_by_index(hw->clk, index);
 
 	for (; frac->num; frac++) {
 		request = (rate * frac->den) / frac->num;
 
-		src_rate = __clk_round_rate(parent, request);
-		if ((src_rate < (request - delta)) ||
-			(src_rate > (request + delta)))
+		if ((parent_rate < (request - delta)) ||
+			(parent_rate > (request + delta)))
 			continue;
 
 		regmap_read(rcg->clkr.regmap, rcg->cmd_rcgr + CFG_REG,
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
#4 lore raw
Quoted 11 lines · Hai Li

Since the parent rate has been recalculated, pixel RCG clock should rely on it to find the correct M/N values during set_rate, instead of calling __clk_round_rate() to its parent again.

v2: Rebase on clk-next and avoid build warning

Fixes 99cbd064b059 ("clk: qcom: Support display RCG clocks")

---

Huh? I didn't sign this off. The original patch was already applied, so a new patch on top of the patch in -next that removed the index and parent lines and renamed the variable should have been sent. Then we have the option of applying the new patch on top to silence the warning, or to squash it into the original patch if we want to redo clk-fixes. I've opted to redo clk-fixes this time.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project