All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] clk: qcom: Don't overwrite 'cfg' in clk_rcg2_dfs_populate_freq()
@ 2020-01-28 19:33 Stephen Boyd
  2020-01-29  3:21 ` Rajendra Nayak
  2020-02-03 19:19 ` Stephen Boyd
  0 siblings, 2 replies; 3+ messages in thread
From: Stephen Boyd @ 2020-01-28 19:33 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd; +Cc: linux-kernel, linux-clk, Rajendra Nayak

The DFS frequency table logic overwrites 'cfg' while detecting the
parent clk and then later on in clk_rcg2_dfs_populate_freq() we use that
same variable to figure out the mode of the clk, either MND or not. Add
a new variable to hold the parent clk bit so that 'cfg' is left
untouched for use later.

This fixes problems in detecting the supported frequencies for any clks
in DFS mode.

Fixes: cc4f6944d0e3 ("clk: qcom: Add support for RCG to register for DFS")
Reported-by: Rajendra Nayak <rnayak@codeaurora.org>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
---
 drivers/clk/qcom/clk-rcg2.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/qcom/clk-rcg2.c b/drivers/clk/qcom/clk-rcg2.c
index da045b200def..973ecf4f6bc5 100644
--- a/drivers/clk/qcom/clk-rcg2.c
+++ b/drivers/clk/qcom/clk-rcg2.c
@@ -953,7 +953,7 @@ static void clk_rcg2_dfs_populate_freq(struct clk_hw *hw, unsigned int l,
 	struct clk_rcg2 *rcg = to_clk_rcg2(hw);
 	struct clk_hw *p;
 	unsigned long prate = 0;
-	u32 val, mask, cfg, mode;
+	u32 val, mask, cfg, mode, src;
 	int i, num_parents;
 
 	regmap_read(rcg->clkr.regmap, rcg->cmd_rcgr + SE_PERF_DFSR(l), &cfg);
@@ -963,12 +963,12 @@ static void clk_rcg2_dfs_populate_freq(struct clk_hw *hw, unsigned int l,
 	if (cfg & mask)
 		f->pre_div = cfg & mask;
 
-	cfg &= CFG_SRC_SEL_MASK;
-	cfg >>= CFG_SRC_SEL_SHIFT;
+	src = cfg & CFG_SRC_SEL_MASK;
+	src >>= CFG_SRC_SEL_SHIFT;
 
 	num_parents = clk_hw_get_num_parents(hw);
 	for (i = 0; i < num_parents; i++) {
-		if (cfg == rcg->parent_map[i].cfg) {
+		if (src == rcg->parent_map[i].cfg) {
 			f->src = rcg->parent_map[i].src;
 			p = clk_hw_get_parent_by_index(&rcg->clkr.hw, i);
 			prate = clk_hw_get_rate(p);
-- 
Sent by a computer, using git, on the internet


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

* Re: [PATCH] clk: qcom: Don't overwrite 'cfg' in clk_rcg2_dfs_populate_freq()
  2020-01-28 19:33 [PATCH] clk: qcom: Don't overwrite 'cfg' in clk_rcg2_dfs_populate_freq() Stephen Boyd
@ 2020-01-29  3:21 ` Rajendra Nayak
  2020-02-03 19:19 ` Stephen Boyd
  1 sibling, 0 replies; 3+ messages in thread
From: Rajendra Nayak @ 2020-01-29  3:21 UTC (permalink / raw)
  To: Stephen Boyd, Michael Turquette; +Cc: linux-kernel, linux-clk


On 1/29/2020 1:03 AM, Stephen Boyd wrote:
> The DFS frequency table logic overwrites 'cfg' while detecting the
> parent clk and then later on in clk_rcg2_dfs_populate_freq() we use that
> same variable to figure out the mode of the clk, either MND or not. Add
> a new variable to hold the parent clk bit so that 'cfg' is left
> untouched for use later.
> 
> This fixes problems in detecting the supported frequencies for any clks
> in DFS mode.
> 
> Fixes: cc4f6944d0e3 ("clk: qcom: Add support for RCG to register for DFS")
> Reported-by: Rajendra Nayak <rnayak@codeaurora.org>
> Signed-off-by: Stephen Boyd <sboyd@kernel.org>
> ---

Tested-by: Rajendra Nayak <rnayak@codeaurora.org>

>   drivers/clk/qcom/clk-rcg2.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/clk/qcom/clk-rcg2.c b/drivers/clk/qcom/clk-rcg2.c
> index da045b200def..973ecf4f6bc5 100644
> --- a/drivers/clk/qcom/clk-rcg2.c
> +++ b/drivers/clk/qcom/clk-rcg2.c
> @@ -953,7 +953,7 @@ static void clk_rcg2_dfs_populate_freq(struct clk_hw *hw, unsigned int l,
>   	struct clk_rcg2 *rcg = to_clk_rcg2(hw);
>   	struct clk_hw *p;
>   	unsigned long prate = 0;
> -	u32 val, mask, cfg, mode;
> +	u32 val, mask, cfg, mode, src;
>   	int i, num_parents;
>   
>   	regmap_read(rcg->clkr.regmap, rcg->cmd_rcgr + SE_PERF_DFSR(l), &cfg);
> @@ -963,12 +963,12 @@ static void clk_rcg2_dfs_populate_freq(struct clk_hw *hw, unsigned int l,
>   	if (cfg & mask)
>   		f->pre_div = cfg & mask;
>   
> -	cfg &= CFG_SRC_SEL_MASK;
> -	cfg >>= CFG_SRC_SEL_SHIFT;
> +	src = cfg & CFG_SRC_SEL_MASK;
> +	src >>= CFG_SRC_SEL_SHIFT;
>   
>   	num_parents = clk_hw_get_num_parents(hw);
>   	for (i = 0; i < num_parents; i++) {
> -		if (cfg == rcg->parent_map[i].cfg) {
> +		if (src == rcg->parent_map[i].cfg) {
>   			f->src = rcg->parent_map[i].src;
>   			p = clk_hw_get_parent_by_index(&rcg->clkr.hw, i);
>   			prate = clk_hw_get_rate(p);
> 

-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation

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

* Re: [PATCH] clk: qcom: Don't overwrite 'cfg' in clk_rcg2_dfs_populate_freq()
  2020-01-28 19:33 [PATCH] clk: qcom: Don't overwrite 'cfg' in clk_rcg2_dfs_populate_freq() Stephen Boyd
  2020-01-29  3:21 ` Rajendra Nayak
@ 2020-02-03 19:19 ` Stephen Boyd
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Boyd @ 2020-02-03 19:19 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd; +Cc: linux-kernel, linux-clk, Rajendra Nayak

Quoting Stephen Boyd (2020-01-28 11:33:29)
> The DFS frequency table logic overwrites 'cfg' while detecting the
> parent clk and then later on in clk_rcg2_dfs_populate_freq() we use that
> same variable to figure out the mode of the clk, either MND or not. Add
> a new variable to hold the parent clk bit so that 'cfg' is left
> untouched for use later.
> 
> This fixes problems in detecting the supported frequencies for any clks
> in DFS mode.
> 
> Fixes: cc4f6944d0e3 ("clk: qcom: Add support for RCG to register for DFS")
> Reported-by: Rajendra Nayak <rnayak@codeaurora.org>
> Signed-off-by: Stephen Boyd <sboyd@kernel.org>
> ---

Applied to clk-next


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

end of thread, other threads:[~2020-02-03 19:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-28 19:33 [PATCH] clk: qcom: Don't overwrite 'cfg' in clk_rcg2_dfs_populate_freq() Stephen Boyd
2020-01-29  3:21 ` Rajendra Nayak
2020-02-03 19:19 ` Stephen Boyd

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.