[PATCH V3 1/2] firmware: arm_scmi: Add support for marking certain frequencies as boost

Sibi Sankar posted 2 patches 1 year, 11 months ago
There is a newer version of this series
[PATCH V3 1/2] firmware: arm_scmi: Add support for marking certain frequencies as boost
Posted by Sibi Sankar 1 year, 11 months ago
All opps above the sustained level/frequency are treated as boost, so mark
them accordingly.

Suggested-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Sibi Sankar <quic_sibis@quicinc.com>
---
 drivers/firmware/arm_scmi/perf.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c
index 8e832d1ad825..64d9a90bf443 100644
--- a/drivers/firmware/arm_scmi/perf.c
+++ b/drivers/firmware/arm_scmi/perf.c
@@ -857,7 +857,7 @@ static int scmi_dvfs_device_opps_add(const struct scmi_protocol_handle *ph,
 				     struct device *dev, u32 domain)
 {
 	int idx, ret;
-	unsigned long freq;
+	unsigned long freq, sustained_freq;
 	struct dev_pm_opp_data data = {};
 	struct perf_dom_info *dom;
 
@@ -865,12 +865,18 @@ static int scmi_dvfs_device_opps_add(const struct scmi_protocol_handle *ph,
 	if (IS_ERR(dom))
 		return PTR_ERR(dom);
 
+	sustained_freq = dom->sustained_freq_khz * 1000UL;
+
 	for (idx = 0; idx < dom->opp_count; idx++) {
 		if (!dom->level_indexing_mode)
 			freq = dom->opp[idx].perf * dom->mult_factor;
 		else
 			freq = dom->opp[idx].indicative_freq * dom->mult_factor;
 
+		/* All opps above the sustained level/frequency are treated as boost */
+		if (freq > sustained_freq)
+			data.turbo = true;
+
 		data.level = dom->opp[idx].perf;
 		data.freq = freq;
 
-- 
2.34.1
Re: [PATCH V3 1/2] firmware: arm_scmi: Add support for marking certain frequencies as boost
Posted by Dhruva Gole 1 year, 11 months ago
On Mar 08, 2024 at 16:14:09 +0530, Sibi Sankar wrote:
> All opps above the sustained level/frequency are treated as boost, so mark

I know that we use the terms boost and turbo interchangeably however I
would suggest to avoid confusion that we say "treated as turbo" just
because the variable is called turbo.

> them accordingly.
> 
> Suggested-by: Sudeep Holla <sudeep.holla@arm.com>
> Signed-off-by: Sibi Sankar <quic_sibis@quicinc.com>
> ---
>  drivers/firmware/arm_scmi/perf.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c
> index 8e832d1ad825..64d9a90bf443 100644
> --- a/drivers/firmware/arm_scmi/perf.c
> +++ b/drivers/firmware/arm_scmi/perf.c
> @@ -857,7 +857,7 @@ static int scmi_dvfs_device_opps_add(const struct scmi_protocol_handle *ph,
>  				     struct device *dev, u32 domain)
>  {
>  	int idx, ret;
> -	unsigned long freq;
> +	unsigned long freq, sustained_freq;
>  	struct dev_pm_opp_data data = {};
>  	struct perf_dom_info *dom;
>  
> @@ -865,12 +865,18 @@ static int scmi_dvfs_device_opps_add(const struct scmi_protocol_handle *ph,
>  	if (IS_ERR(dom))
>  		return PTR_ERR(dom);
>  
> +	sustained_freq = dom->sustained_freq_khz * 1000UL;
> +
>  	for (idx = 0; idx < dom->opp_count; idx++) {
>  		if (!dom->level_indexing_mode)
>  			freq = dom->opp[idx].perf * dom->mult_factor;
>  		else
>  			freq = dom->opp[idx].indicative_freq * dom->mult_factor;
>  
> +		/* All opps above the sustained level/frequency are treated as boost */

Same here, would be better to say "turbo" than boost.

> +		if (freq > sustained_freq)
> +			data.turbo = true;

It's simple enough that we can write it as
data.turbo = (freq > sustained_freq_khz*1000) ? true : false;

We can avoid an additional variable and all the other code changes.


-- 
Best regards,
Dhruva Gole <d-gole@ti.com>
Re: [PATCH V3 1/2] firmware: arm_scmi: Add support for marking certain frequencies as boost
Posted by Viresh Kumar 1 year, 11 months ago
On 11-03-24, 11:05, Dhruva Gole wrote:
> > +		if (freq > sustained_freq)
> > +			data.turbo = true;
> 
> It's simple enough that we can write it as
> data.turbo = (freq > sustained_freq_khz*1000) ? true : false;

Or:

data.turbo = freq > sustained_freq_khz * 1000;

-- 
viresh
Re: [PATCH V3 1/2] firmware: arm_scmi: Add support for marking certain frequencies as boost
Posted by Sudeep Holla 1 year, 11 months ago
On Fri, Mar 08, 2024 at 04:14:09PM +0530, Sibi Sankar wrote:
> All opps above the sustained level/frequency are treated as boost, so mark
> them accordingly.
> 
> Suggested-by: Sudeep Holla <sudeep.holla@arm.com>

Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>

--
Regards,
Sudeep