linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V3 0/2] cpufreq: scmi: Add boost frequency support
@ 2024-03-08 10:44 Sibi Sankar
  2024-03-08 10:44 ` [PATCH V3 1/2] firmware: arm_scmi: Add support for marking certain frequencies as boost Sibi Sankar
  2024-03-08 10:44 ` [PATCH V3 2/2] cpufreq: scmi: Enable boost support Sibi Sankar
  0 siblings, 2 replies; 9+ messages in thread
From: Sibi Sankar @ 2024-03-08 10:44 UTC (permalink / raw)
  To: sudeep.holla, cristian.marussi, rafael, viresh.kumar,
	morten.rasmussen, dietmar.eggemann, lukasz.luba, sboyd
  Cc: linux-arm-kernel, linux-pm, linux-kernel, quic_mdtipton,
	linux-arm-msm, nm, Sibi Sankar

This series adds provision to mark dynamic opps as boost capable and adds
boost frequency support to the scmi cpufreq driver.

V3:
* Don't set per-policy boost flags from the cpufreq driver. [Viresh]
* Drop patch 1 since Viresh already pulled it in.
* Drop depends on bug link. [Viresh]

V2:
* Document boost flag. [Lukasz]
* Remove sustained_freq check. [Pierre]
* simplify sustained_freq_khz calculation. [Sudeep]
* fix default per-policy state. [Dietmar]
* fix typo in commit message in patch 3.

Sibi Sankar (2):
  firmware: arm_scmi: Add support for marking certain frequencies as
    boost
  cpufreq: scmi: Enable boost support

 drivers/cpufreq/scmi-cpufreq.c   | 20 +++++++++++++++++++-
 drivers/firmware/arm_scmi/perf.c |  8 +++++++-
 2 files changed, 26 insertions(+), 2 deletions(-)

-- 
2.34.1


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

* [PATCH V3 1/2] firmware: arm_scmi: Add support for marking certain frequencies as boost
  2024-03-08 10:44 [PATCH V3 0/2] cpufreq: scmi: Add boost frequency support Sibi Sankar
@ 2024-03-08 10:44 ` Sibi Sankar
  2024-03-08 13:59   ` Sudeep Holla
  2024-03-11  5:35   ` Dhruva Gole
  2024-03-08 10:44 ` [PATCH V3 2/2] cpufreq: scmi: Enable boost support Sibi Sankar
  1 sibling, 2 replies; 9+ messages in thread
From: Sibi Sankar @ 2024-03-08 10:44 UTC (permalink / raw)
  To: sudeep.holla, cristian.marussi, rafael, viresh.kumar,
	morten.rasmussen, dietmar.eggemann, lukasz.luba, sboyd
  Cc: linux-arm-kernel, linux-pm, linux-kernel, quic_mdtipton,
	linux-arm-msm, nm, Sibi Sankar

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


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

* [PATCH V3 2/2] cpufreq: scmi: Enable boost support
  2024-03-08 10:44 [PATCH V3 0/2] cpufreq: scmi: Add boost frequency support Sibi Sankar
  2024-03-08 10:44 ` [PATCH V3 1/2] firmware: arm_scmi: Add support for marking certain frequencies as boost Sibi Sankar
@ 2024-03-08 10:44 ` Sibi Sankar
  2024-03-08 14:06   ` Sudeep Holla
  1 sibling, 1 reply; 9+ messages in thread
From: Sibi Sankar @ 2024-03-08 10:44 UTC (permalink / raw)
  To: sudeep.holla, cristian.marussi, rafael, viresh.kumar,
	morten.rasmussen, dietmar.eggemann, lukasz.luba, sboyd
  Cc: linux-arm-kernel, linux-pm, linux-kernel, quic_mdtipton,
	linux-arm-msm, nm, Sibi Sankar

The X1E80100 SoC hosts a number of cpu boost frequencies, so let's enable
boost support if the freq_table has any opps marked as turbo in it.

Signed-off-by: Sibi Sankar <quic_sibis@quicinc.com>
---

v3:
* Don't set per-policy boost flags from the cpufreq driver. [Viresh]

 drivers/cpufreq/scmi-cpufreq.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/cpufreq/scmi-cpufreq.c b/drivers/cpufreq/scmi-cpufreq.c
index 0b483bd0d3ca..3b4f6bfb2f4c 100644
--- a/drivers/cpufreq/scmi-cpufreq.c
+++ b/drivers/cpufreq/scmi-cpufreq.c
@@ -30,6 +30,7 @@ struct scmi_data {
 
 static struct scmi_protocol_handle *ph;
 static const struct scmi_perf_proto_ops *perf_ops;
+static struct cpufreq_driver scmi_cpufreq_driver;
 
 static unsigned int scmi_cpufreq_get_rate(unsigned int cpu)
 {
@@ -167,6 +168,12 @@ scmi_get_rate_limit(u32 domain, bool has_fast_switch)
 	return rate_limit;
 }
 
+static struct freq_attr *scmi_cpufreq_hw_attr[] = {
+	&cpufreq_freq_attr_scaling_available_freqs,
+	NULL,
+	NULL,
+};
+
 static int scmi_cpufreq_init(struct cpufreq_policy *policy)
 {
 	int ret, nr_opp, domain;
@@ -276,6 +283,17 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy)
 	policy->transition_delay_us =
 		scmi_get_rate_limit(domain, policy->fast_switch_possible);
 
+	if (policy_has_boost_freq(policy)) {
+		ret = cpufreq_enable_boost_support();
+		if (ret) {
+			dev_warn(cpu_dev, "failed to enable boost: %d\n", ret);
+			goto out_free_opp;
+		} else {
+			scmi_cpufreq_hw_attr[1] = &cpufreq_freq_attr_scaling_boost_freqs;
+			scmi_cpufreq_driver.boost_enabled = true;
+		}
+	}
+
 	return 0;
 
 out_free_opp:
@@ -334,7 +352,7 @@ static struct cpufreq_driver scmi_cpufreq_driver = {
 		  CPUFREQ_NEED_INITIAL_FREQ_CHECK |
 		  CPUFREQ_IS_COOLING_DEV,
 	.verify	= cpufreq_generic_frequency_table_verify,
-	.attr	= cpufreq_generic_attr,
+	.attr	= scmi_cpufreq_hw_attr,
 	.target_index	= scmi_cpufreq_set_target,
 	.fast_switch	= scmi_cpufreq_fast_switch,
 	.get	= scmi_cpufreq_get_rate,
-- 
2.34.1


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

* Re: [PATCH V3 1/2] firmware: arm_scmi: Add support for marking certain frequencies as boost
  2024-03-08 10:44 ` [PATCH V3 1/2] firmware: arm_scmi: Add support for marking certain frequencies as boost Sibi Sankar
@ 2024-03-08 13:59   ` Sudeep Holla
  2024-03-11  5:35   ` Dhruva Gole
  1 sibling, 0 replies; 9+ messages in thread
From: Sudeep Holla @ 2024-03-08 13:59 UTC (permalink / raw)
  To: Sibi Sankar
  Cc: cristian.marussi, rafael, viresh.kumar, morten.rasmussen,
	dietmar.eggemann, lukasz.luba, sboyd, linux-arm-kernel, linux-pm,
	linux-kernel, quic_mdtipton, linux-arm-msm, nm

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

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

* Re: [PATCH V3 2/2] cpufreq: scmi: Enable boost support
  2024-03-08 10:44 ` [PATCH V3 2/2] cpufreq: scmi: Enable boost support Sibi Sankar
@ 2024-03-08 14:06   ` Sudeep Holla
  2024-03-11  4:55     ` Viresh Kumar
  0 siblings, 1 reply; 9+ messages in thread
From: Sudeep Holla @ 2024-03-08 14:06 UTC (permalink / raw)
  To: Sibi Sankar
  Cc: cristian.marussi, rafael, viresh.kumar, morten.rasmussen,
	dietmar.eggemann, lukasz.luba, sboyd, linux-arm-kernel, linux-pm,
	linux-kernel, quic_mdtipton, linux-arm-msm, nm

On Fri, Mar 08, 2024 at 04:14:10PM +0530, Sibi Sankar wrote:
> The X1E80100 SoC hosts a number of cpu boost frequencies, so let's enable
> boost support if the freq_table has any opps marked as turbo in it.
>

I had asked if you could put the information about how and when the boost
frequencies are used, it would be useful for reference purposes when someone
attempts to use this feature. But it is not a blocker, just good to have
info.

Also I would not sure specific platform name, just refer as certain platforms
as it such information becomes stale soon.

Anyways apart for those nits on the commit message, this looks good.

Reviewed-by: <viresh.kumar@linaro.org>

I am assuming Viresh might take both these changes for via his tree. If not,
I can take it for v6.10 after v6.9-rc1

-- 
Regards,
Sudeep

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

* Re: [PATCH V3 2/2] cpufreq: scmi: Enable boost support
  2024-03-08 14:06   ` Sudeep Holla
@ 2024-03-11  4:55     ` Viresh Kumar
  2024-03-11  9:04       ` Sudeep Holla
  0 siblings, 1 reply; 9+ messages in thread
From: Viresh Kumar @ 2024-03-11  4:55 UTC (permalink / raw)
  To: Sudeep Holla
  Cc: Sibi Sankar, cristian.marussi, rafael, morten.rasmussen,
	dietmar.eggemann, lukasz.luba, sboyd, linux-arm-kernel, linux-pm,
	linux-kernel, quic_mdtipton, linux-arm-msm, nm

On 08-03-24, 14:06, Sudeep Holla wrote:
> Anyways apart for those nits on the commit message, this looks good.
> 
> Reviewed-by: <viresh.kumar@linaro.org>

:)

-- 
viresh

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

* Re: [PATCH V3 1/2] firmware: arm_scmi: Add support for marking certain frequencies as boost
  2024-03-08 10:44 ` [PATCH V3 1/2] firmware: arm_scmi: Add support for marking certain frequencies as boost Sibi Sankar
  2024-03-08 13:59   ` Sudeep Holla
@ 2024-03-11  5:35   ` Dhruva Gole
  2024-03-11  5:49     ` Viresh Kumar
  1 sibling, 1 reply; 9+ messages in thread
From: Dhruva Gole @ 2024-03-11  5:35 UTC (permalink / raw)
  To: Sibi Sankar
  Cc: sudeep.holla, cristian.marussi, rafael, viresh.kumar,
	morten.rasmussen, dietmar.eggemann, lukasz.luba, sboyd,
	linux-arm-kernel, linux-pm, linux-kernel, quic_mdtipton,
	linux-arm-msm, nm

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>

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

* Re: [PATCH V3 1/2] firmware: arm_scmi: Add support for marking certain frequencies as boost
  2024-03-11  5:35   ` Dhruva Gole
@ 2024-03-11  5:49     ` Viresh Kumar
  0 siblings, 0 replies; 9+ messages in thread
From: Viresh Kumar @ 2024-03-11  5:49 UTC (permalink / raw)
  To: Dhruva Gole
  Cc: Sibi Sankar, sudeep.holla, cristian.marussi, rafael,
	morten.rasmussen, dietmar.eggemann, lukasz.luba, sboyd,
	linux-arm-kernel, linux-pm, linux-kernel, quic_mdtipton,
	linux-arm-msm, nm

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

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

* Re: [PATCH V3 2/2] cpufreq: scmi: Enable boost support
  2024-03-11  4:55     ` Viresh Kumar
@ 2024-03-11  9:04       ` Sudeep Holla
  0 siblings, 0 replies; 9+ messages in thread
From: Sudeep Holla @ 2024-03-11  9:04 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Sibi Sankar, cristian.marussi, rafael, morten.rasmussen,
	dietmar.eggemann, lukasz.luba, sboyd, linux-arm-kernel, linux-pm,
	linux-kernel, quic_mdtipton, linux-arm-msm, nm

On Mon, Mar 11, 2024 at 10:25:13AM +0530, Viresh Kumar wrote:
> On 08-03-24, 14:06, Sudeep Holla wrote:
> > Anyways apart for those nits on the commit message, this looks good.
> > 
> > Reviewed-by: <viresh.kumar@linaro.org>
> 
> :)
>

😉

So stupid of me, I wanted to make sure you were in to and seem to have
copied the same address for my reviewed by. Sorry for that, obviously
I meant:

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

--
Regards,
Sudeep

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

end of thread, other threads:[~2024-03-11  9:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-08 10:44 [PATCH V3 0/2] cpufreq: scmi: Add boost frequency support Sibi Sankar
2024-03-08 10:44 ` [PATCH V3 1/2] firmware: arm_scmi: Add support for marking certain frequencies as boost Sibi Sankar
2024-03-08 13:59   ` Sudeep Holla
2024-03-11  5:35   ` Dhruva Gole
2024-03-11  5:49     ` Viresh Kumar
2024-03-08 10:44 ` [PATCH V3 2/2] cpufreq: scmi: Enable boost support Sibi Sankar
2024-03-08 14:06   ` Sudeep Holla
2024-03-11  4:55     ` Viresh Kumar
2024-03-11  9:04       ` Sudeep Holla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).