Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
* [PATCH] clk: qcom: clk-rpmh: Fix overflow in BCM vote
@ 2024-08-08  7:05 Imran Shaik
  2024-08-08  7:27 ` Taniya Das
  2024-08-08 19:43 ` Stephen Boyd
  0 siblings, 2 replies; 4+ messages in thread
From: Imran Shaik @ 2024-08-08  7:05 UTC (permalink / raw)
  To: Bjorn Andersson, Michael Turquette, Stephen Boyd, David Dai
  Cc: linux-arm-msm, linux-clk, linux-kernel, Ajit Pandey, Imran Shaik,
	Taniya Das, Jagadeesh Kona, Satya Priya Kakitapalli, Mike Tipton,
	stable

From: Mike Tipton <quic_mdtipton@quicinc.com>

Valid frequencies may result in BCM votes that exceed the max HW value.
Set vote ceiling to BCM_TCS_CMD_VOTE_MASK to ensure the votes aren't
truncated, which can result in lower frequencies than desired.

Fixes: 04053f4d23a4 ("clk: qcom: clk-rpmh: Add IPA clock support")
Cc: stable@vger.kernel.org
Signed-off-by: Mike Tipton <quic_mdtipton@quicinc.com>
Signed-off-by: Imran Shaik <quic_imrashai@quicinc.com>
---
 drivers/clk/qcom/clk-rpmh.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/clk/qcom/clk-rpmh.c b/drivers/clk/qcom/clk-rpmh.c
index bb82abeed88f..233ccd365a37 100644
--- a/drivers/clk/qcom/clk-rpmh.c
+++ b/drivers/clk/qcom/clk-rpmh.c
@@ -263,6 +263,9 @@ static int clk_rpmh_bcm_send_cmd(struct clk_rpmh *c, bool enable)
 		cmd_state = 0;
 	}
 
+	if (cmd_state > BCM_TCS_CMD_VOTE_MASK)
+		cmd_state = BCM_TCS_CMD_VOTE_MASK;
+
 	if (c->last_sent_aggr_state != cmd_state) {
 		cmd.addr = c->res_addr;
 		cmd.data = BCM_TCS_CMD(1, enable, 0, cmd_state);

---
base-commit: 222a3380f92b8791d4eeedf7cd750513ff428adf
change-id: 20240808-clk-rpmh-bcm-vote-fix-c344e213c9bb

Best regards,
-- 
Imran Shaik <quic_imrashai@quicinc.com>


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

* Re: [PATCH] clk: qcom: clk-rpmh: Fix overflow in BCM vote
  2024-08-08  7:05 [PATCH] clk: qcom: clk-rpmh: Fix overflow in BCM vote Imran Shaik
@ 2024-08-08  7:27 ` Taniya Das
  2024-08-08 19:43 ` Stephen Boyd
  1 sibling, 0 replies; 4+ messages in thread
From: Taniya Das @ 2024-08-08  7:27 UTC (permalink / raw)
  To: Imran Shaik, Bjorn Andersson, Michael Turquette, Stephen Boyd,
	David Dai
  Cc: linux-arm-msm, linux-clk, linux-kernel, Ajit Pandey,
	Jagadeesh Kona, Satya Priya Kakitapalli, Mike Tipton, stable



On 8/8/2024 12:35 PM, Imran Shaik wrote:
> From: Mike Tipton <quic_mdtipton@quicinc.com>
> 
> Valid frequencies may result in BCM votes that exceed the max HW value.
> Set vote ceiling to BCM_TCS_CMD_VOTE_MASK to ensure the votes aren't
> truncated, which can result in lower frequencies than desired.
> 
> Fixes: 04053f4d23a4 ("clk: qcom: clk-rpmh: Add IPA clock support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Mike Tipton <quic_mdtipton@quicinc.com>
> Signed-off-by: Imran Shaik <quic_imrashai@quicinc.com>
> ---
>   drivers/clk/qcom/clk-rpmh.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/clk/qcom/clk-rpmh.c b/drivers/clk/qcom/clk-rpmh.c
> index bb82abeed88f..233ccd365a37 100644
> --- a/drivers/clk/qcom/clk-rpmh.c
> +++ b/drivers/clk/qcom/clk-rpmh.c
> @@ -263,6 +263,9 @@ static int clk_rpmh_bcm_send_cmd(struct clk_rpmh *c, bool enable)
>   		cmd_state = 0;
>   	}
>   
> +	if (cmd_state > BCM_TCS_CMD_VOTE_MASK)
> +		cmd_state = BCM_TCS_CMD_VOTE_MASK;
> +
>   	if (c->last_sent_aggr_state != cmd_state) {
>   		cmd.addr = c->res_addr;
>   		cmd.data = BCM_TCS_CMD(1, enable, 0, cmd_state);
> 


Reviewed-by: Taniya Das <quic_tdas@quicinc.com>

-- 
Thanks & Regards,
Taniya Das.

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

* Re: [PATCH] clk: qcom: clk-rpmh: Fix overflow in BCM vote
  2024-08-08  7:05 [PATCH] clk: qcom: clk-rpmh: Fix overflow in BCM vote Imran Shaik
  2024-08-08  7:27 ` Taniya Das
@ 2024-08-08 19:43 ` Stephen Boyd
  2024-08-09  5:18   ` Imran Shaik
  1 sibling, 1 reply; 4+ messages in thread
From: Stephen Boyd @ 2024-08-08 19:43 UTC (permalink / raw)
  To: Bjorn Andersson, David Dai, Imran Shaik, Michael Turquette
  Cc: linux-arm-msm, linux-clk, linux-kernel, Ajit Pandey, Imran Shaik,
	Taniya Das, Jagadeesh Kona, Satya Priya Kakitapalli, Mike Tipton,
	stable

Quoting Imran Shaik (2024-08-08 00:05:02)
> From: Mike Tipton <quic_mdtipton@quicinc.com>
> 
> Valid frequencies may result in BCM votes that exceed the max HW value.
> Set vote ceiling to BCM_TCS_CMD_VOTE_MASK to ensure the votes aren't
> truncated, which can result in lower frequencies than desired.
> 
> Fixes: 04053f4d23a4 ("clk: qcom: clk-rpmh: Add IPA clock support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Mike Tipton <quic_mdtipton@quicinc.com>
> Signed-off-by: Imran Shaik <quic_imrashai@quicinc.com>
> ---
>  drivers/clk/qcom/clk-rpmh.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/clk/qcom/clk-rpmh.c b/drivers/clk/qcom/clk-rpmh.c
> index bb82abeed88f..233ccd365a37 100644
> --- a/drivers/clk/qcom/clk-rpmh.c
> +++ b/drivers/clk/qcom/clk-rpmh.c
> @@ -263,6 +263,9 @@ static int clk_rpmh_bcm_send_cmd(struct clk_rpmh *c, bool enable)
>                 cmd_state = 0;
>         }
>  
> +       if (cmd_state > BCM_TCS_CMD_VOTE_MASK)
> +               cmd_state = BCM_TCS_CMD_VOTE_MASK;
> +

This is

	cmd_state = min(cmd_state, BCM_TCS_CMD_VOTE_MASK);

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

* Re: [PATCH] clk: qcom: clk-rpmh: Fix overflow in BCM vote
  2024-08-08 19:43 ` Stephen Boyd
@ 2024-08-09  5:18   ` Imran Shaik
  0 siblings, 0 replies; 4+ messages in thread
From: Imran Shaik @ 2024-08-09  5:18 UTC (permalink / raw)
  To: Stephen Boyd, Bjorn Andersson, David Dai, Michael Turquette
  Cc: linux-arm-msm, linux-clk, linux-kernel, Ajit Pandey, Taniya Das,
	Jagadeesh Kona, Satya Priya Kakitapalli, Mike Tipton, stable



On 8/9/2024 1:13 AM, Stephen Boyd wrote:
> Quoting Imran Shaik (2024-08-08 00:05:02)
>> From: Mike Tipton <quic_mdtipton@quicinc.com>
>>
>> Valid frequencies may result in BCM votes that exceed the max HW value.
>> Set vote ceiling to BCM_TCS_CMD_VOTE_MASK to ensure the votes aren't
>> truncated, which can result in lower frequencies than desired.
>>
>> Fixes: 04053f4d23a4 ("clk: qcom: clk-rpmh: Add IPA clock support")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Mike Tipton <quic_mdtipton@quicinc.com>
>> Signed-off-by: Imran Shaik <quic_imrashai@quicinc.com>
>> ---
>>   drivers/clk/qcom/clk-rpmh.c | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/clk/qcom/clk-rpmh.c b/drivers/clk/qcom/clk-rpmh.c
>> index bb82abeed88f..233ccd365a37 100644
>> --- a/drivers/clk/qcom/clk-rpmh.c
>> +++ b/drivers/clk/qcom/clk-rpmh.c
>> @@ -263,6 +263,9 @@ static int clk_rpmh_bcm_send_cmd(struct clk_rpmh *c, bool enable)
>>                  cmd_state = 0;
>>          }
>>   
>> +       if (cmd_state > BCM_TCS_CMD_VOTE_MASK)
>> +               cmd_state = BCM_TCS_CMD_VOTE_MASK;
>> +
> 
> This is
> 
> 	cmd_state = min(cmd_state, BCM_TCS_CMD_VOTE_MASK);

Sure, I will update this logic and post another series.

Thanks,
Imran

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

end of thread, other threads:[~2024-08-09  5:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-08  7:05 [PATCH] clk: qcom: clk-rpmh: Fix overflow in BCM vote Imran Shaik
2024-08-08  7:27 ` Taniya Das
2024-08-08 19:43 ` Stephen Boyd
2024-08-09  5:18   ` Imran Shaik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox