* [PATCH v8 1/3] scmi-cpufreq: Remove deferred probe
2021-02-18 22:23 [PATCH v8 0/3] CPUFreq: Add support for opp-sharing cpus Nicola Mazzucato
@ 2021-02-18 22:23 ` Nicola Mazzucato
2021-02-18 22:23 ` [PATCH v8 2/3] scmi-cpufreq: Get opp_shared_cpus from opp-v2 for EM Nicola Mazzucato
` (4 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Nicola Mazzucato @ 2021-02-18 22:23 UTC (permalink / raw)
To: linux-kernel, linux-arm-kernel, linux-pm, sudeep.holla, rjw,
vireshk, cristian.marussi
Cc: chris.redpath, ionela.voinescu, morten.rasmussen, nicola.mazzucato
The current implementation of the scmi_cpufreq_init() function returns
-EPROBE_DEFER when the OPP table is not populated. In practice the
cpufreq core cannot handle this error code.
Therefore, fix the return value and clarify the error message.
Signed-off-by: Nicola Mazzucato <nicola.mazzucato@arm.com>
---
drivers/cpufreq/scmi-cpufreq.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/cpufreq/scmi-cpufreq.c b/drivers/cpufreq/scmi-cpufreq.c
index 491a0a24fb1e..c0345120a7d5 100644
--- a/drivers/cpufreq/scmi-cpufreq.c
+++ b/drivers/cpufreq/scmi-cpufreq.c
@@ -155,8 +155,10 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy)
nr_opp = dev_pm_opp_get_opp_count(cpu_dev);
if (nr_opp <= 0) {
- dev_dbg(cpu_dev, "OPP table is not ready, deferring probe\n");
- ret = -EPROBE_DEFER;
+ dev_err(cpu_dev, "%s: No OPPs for this device: %d\n",
+ __func__, ret);
+
+ ret = -ENODEV;
goto out_free_opp;
}
--
2.27.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v8 2/3] scmi-cpufreq: Get opp_shared_cpus from opp-v2 for EM
2021-02-18 22:23 [PATCH v8 0/3] CPUFreq: Add support for opp-sharing cpus Nicola Mazzucato
2021-02-18 22:23 ` [PATCH v8 1/3] scmi-cpufreq: Remove deferred probe Nicola Mazzucato
@ 2021-02-18 22:23 ` Nicola Mazzucato
2021-02-18 22:23 ` [PATCH v8 3/3] cpufreq: blacklist Arm Vexpress platforms in cpufreq-dt-platdev Nicola Mazzucato
` (3 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Nicola Mazzucato @ 2021-02-18 22:23 UTC (permalink / raw)
To: linux-kernel, linux-arm-kernel, linux-pm, sudeep.holla, rjw,
vireshk, cristian.marussi
Cc: chris.redpath, ionela.voinescu, morten.rasmussen, nicola.mazzucato
By design, SCMI performance domains define the granularity of
performance controls, they do not describe any underlying hardware
dependencies (although they may match in many cases).
It is therefore possible to have some platforms where hardware may have
the ability to control CPU performance at different granularity and choose
to describe fine-grained performance control through SCMI.
In such situations, the energy model would be provided with inaccurate
information based on controls, while it still needs to know the
performance boundaries.
To restore correct functionality, retrieve information of CPUs under the
same performance domain from operating-points-v2 in DT, and pass it on to
EM.
Signed-off-by: Nicola Mazzucato <nicola.mazzucato@arm.com>
---
drivers/cpufreq/scmi-cpufreq.c | 74 +++++++++++++++++++++++++---------
1 file changed, 54 insertions(+), 20 deletions(-)
diff --git a/drivers/cpufreq/scmi-cpufreq.c b/drivers/cpufreq/scmi-cpufreq.c
index c0345120a7d5..5415ed52b53a 100644
--- a/drivers/cpufreq/scmi-cpufreq.c
+++ b/drivers/cpufreq/scmi-cpufreq.c
@@ -126,6 +126,7 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy)
struct scmi_data *priv;
struct cpufreq_frequency_table *freq_table;
struct em_data_callback em_cb = EM_DATA_CB(scmi_get_cpu_power);
+ cpumask_var_t opp_shared_cpus;
bool power_scale_mw;
cpu_dev = get_cpu_device(policy->cpu);
@@ -134,32 +135,64 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy)
return -ENODEV;
}
- ret = handle->perf_ops->device_opps_add(handle, cpu_dev);
- if (ret) {
- dev_warn(cpu_dev, "failed to add opps to the device\n");
- return ret;
- }
+ if (!zalloc_cpumask_var(&opp_shared_cpus, GFP_KERNEL))
+ ret = -ENOMEM;
+ /* Obtain CPUs that share SCMI performance controls */
ret = scmi_get_sharing_cpus(cpu_dev, policy->cpus);
if (ret) {
dev_warn(cpu_dev, "failed to get sharing cpumask\n");
- return ret;
+ goto out_free_cpumask;
}
- ret = dev_pm_opp_set_sharing_cpus(cpu_dev, policy->cpus);
- if (ret) {
- dev_err(cpu_dev, "%s: failed to mark OPPs as shared: %d\n",
- __func__, ret);
- return ret;
+ /*
+ * Obtain CPUs that share performance levels.
+ * The OPP 'sharing cpus' info may come from DT through an empty opp
+ * table and opp-shared.
+ */
+ ret = dev_pm_opp_of_get_sharing_cpus(cpu_dev, opp_shared_cpus);
+ if (ret || !cpumask_weight(opp_shared_cpus)) {
+ /*
+ * Either opp-table is not set or no opp-shared was found.
+ * Use the CPU mask from SCMI to designate CPUs sharing an OPP
+ * table.
+ */
+ cpumask_copy(opp_shared_cpus, policy->cpus);
}
+ /*
+ * A previous CPU may have marked OPPs as shared for a few CPUs, based on
+ * what OPP core provided. If the current CPU is part of those few, then
+ * there is no need to add OPPs again.
+ */
nr_opp = dev_pm_opp_get_opp_count(cpu_dev);
if (nr_opp <= 0) {
- dev_err(cpu_dev, "%s: No OPPs for this device: %d\n",
- __func__, ret);
-
- ret = -ENODEV;
- goto out_free_opp;
+ ret = handle->perf_ops->device_opps_add(handle, cpu_dev);
+ if (ret) {
+ dev_warn(cpu_dev, "failed to add opps to the device\n");
+ goto out_free_cpumask;
+ }
+
+ nr_opp = dev_pm_opp_get_opp_count(cpu_dev);
+ if (nr_opp <= 0) {
+ dev_err(cpu_dev, "%s: No OPPs for this device: %d\n",
+ __func__, ret);
+
+ ret = -ENODEV;
+ goto out_free_opp;
+ }
+
+ ret = dev_pm_opp_set_sharing_cpus(cpu_dev, opp_shared_cpus);
+ if (ret) {
+ dev_err(cpu_dev, "%s: failed to mark OPPs as shared: %d\n",
+ __func__, ret);
+
+ goto out_free_opp;
+ }
+
+ power_scale_mw = handle->perf_ops->power_scale_mw_get(handle);
+ em_dev_register_perf_domain(cpu_dev, nr_opp, &em_cb,
+ opp_shared_cpus, power_scale_mw);
}
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
@@ -192,17 +225,18 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy)
policy->fast_switch_possible =
handle->perf_ops->fast_switch_possible(handle, cpu_dev);
- power_scale_mw = handle->perf_ops->power_scale_mw_get(handle);
- em_dev_register_perf_domain(cpu_dev, nr_opp, &em_cb, policy->cpus,
- power_scale_mw);
-
+ free_cpumask_var(opp_shared_cpus);
return 0;
out_free_priv:
kfree(priv);
+
out_free_opp:
dev_pm_opp_remove_all_dynamic(cpu_dev);
+out_free_cpumask:
+ free_cpumask_var(opp_shared_cpus);
+
return ret;
}
--
2.27.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v8 3/3] cpufreq: blacklist Arm Vexpress platforms in cpufreq-dt-platdev
2021-02-18 22:23 [PATCH v8 0/3] CPUFreq: Add support for opp-sharing cpus Nicola Mazzucato
2021-02-18 22:23 ` [PATCH v8 1/3] scmi-cpufreq: Remove deferred probe Nicola Mazzucato
2021-02-18 22:23 ` [PATCH v8 2/3] scmi-cpufreq: Get opp_shared_cpus from opp-v2 for EM Nicola Mazzucato
@ 2021-02-18 22:23 ` Nicola Mazzucato
2021-02-19 4:19 ` [PATCH v8 0/3] CPUFreq: Add support for opp-sharing cpus Viresh Kumar
` (2 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Nicola Mazzucato @ 2021-02-18 22:23 UTC (permalink / raw)
To: linux-kernel, linux-arm-kernel, linux-pm, sudeep.holla, rjw,
vireshk, cristian.marussi
Cc: chris.redpath, ionela.voinescu, morten.rasmussen, nicola.mazzucato
From: Sudeep Holla <sudeep.holla@arm.com>
Add "arm,vexpress" to cpufreq-dt-platdev blacklist since the actual
scaling is handled by the firmware cpufreq drivers(scpi, scmi and
vexpress-spc).
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
drivers/cpufreq/cpufreq-dt-platdev.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/cpufreq/cpufreq-dt-platdev.c b/drivers/cpufreq/cpufreq-dt-platdev.c
index bd2db0188cbb..91e6a0c10dbf 100644
--- a/drivers/cpufreq/cpufreq-dt-platdev.c
+++ b/drivers/cpufreq/cpufreq-dt-platdev.c
@@ -103,6 +103,8 @@ static const struct of_device_id whitelist[] __initconst = {
static const struct of_device_id blacklist[] __initconst = {
{ .compatible = "allwinner,sun50i-h6", },
+ { .compatible = "arm,vexpress", },
+
{ .compatible = "calxeda,highbank", },
{ .compatible = "calxeda,ecx-2000", },
--
2.27.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v8 0/3] CPUFreq: Add support for opp-sharing cpus
2021-02-18 22:23 [PATCH v8 0/3] CPUFreq: Add support for opp-sharing cpus Nicola Mazzucato
` (2 preceding siblings ...)
2021-02-18 22:23 ` [PATCH v8 3/3] cpufreq: blacklist Arm Vexpress platforms in cpufreq-dt-platdev Nicola Mazzucato
@ 2021-02-19 4:19 ` Viresh Kumar
2021-02-19 19:16 ` Sudeep Holla
2021-03-09 11:59 ` Sudeep Holla
2021-03-23 9:30 ` Sudeep Holla
5 siblings, 1 reply; 10+ messages in thread
From: Viresh Kumar @ 2021-02-19 4:19 UTC (permalink / raw)
To: Nicola Mazzucato
Cc: linux-pm, vireshk, rjw, linux-kernel, cristian.marussi,
sudeep.holla, chris.redpath, ionela.voinescu, morten.rasmussen,
linux-arm-kernel
On 18-02-21, 22:23, Nicola Mazzucato wrote:
> Hi Viresh,
>
> In this V8 I have addressed your comments:
> - correct the goto in patch 1/3
> - improve comment in patch 2/3 for dev_pm_opp_get_opp_count()
LGTM. I will apply them after the merge window is over. Thanks.
--
viresh
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v8 0/3] CPUFreq: Add support for opp-sharing cpus
2021-02-19 4:19 ` [PATCH v8 0/3] CPUFreq: Add support for opp-sharing cpus Viresh Kumar
@ 2021-02-19 19:16 ` Sudeep Holla
2021-02-22 4:39 ` Viresh Kumar
0 siblings, 1 reply; 10+ messages in thread
From: Sudeep Holla @ 2021-02-19 19:16 UTC (permalink / raw)
To: Viresh Kumar
Cc: cristian.marussi, linux-pm, vireshk, rjw, linux-kernel,
Nicola Mazzucato, Sudeep Holla, chris.redpath, ionela.voinescu,
morten.rasmussen, linux-arm-kernel
Hi Viresh,
On Fri, Feb 19, 2021 at 09:49:44AM +0530, Viresh Kumar wrote:
> On 18-02-21, 22:23, Nicola Mazzucato wrote:
> > Hi Viresh,
> >
> > In this V8 I have addressed your comments:
> > - correct the goto in patch 1/3
> > - improve comment in patch 2/3 for dev_pm_opp_get_opp_count()
>
> LGTM. I will apply them after the merge window is over. Thanks.
I am planning to merge the series on scmi[1] which changes scmi-cpufreq.c
and will conflict with these changes I think. If possible either,
1. Share a branch with these changes that I can merge or
2. I can take patch 1/3 and 2/3 with other scmi changes with your Ack.
I am fine either way, let me know by v5.12-rc1
--
Regards,
Sudeep
[1] https://lore.kernel.org/linux-arm-kernel/20210202221555.41167-1-cristian.marussi@arm.com/
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v8 0/3] CPUFreq: Add support for opp-sharing cpus
2021-02-19 19:16 ` Sudeep Holla
@ 2021-02-22 4:39 ` Viresh Kumar
2021-02-22 11:14 ` Sudeep Holla
0 siblings, 1 reply; 10+ messages in thread
From: Viresh Kumar @ 2021-02-22 4:39 UTC (permalink / raw)
To: Sudeep Holla
Cc: cristian.marussi, linux-pm, vireshk, rjw, linux-kernel,
Nicola Mazzucato, chris.redpath, ionela.voinescu,
morten.rasmussen, linux-arm-kernel
On 19-02-21, 19:16, Sudeep Holla wrote:
> Hi Viresh,
>
> On Fri, Feb 19, 2021 at 09:49:44AM +0530, Viresh Kumar wrote:
> > On 18-02-21, 22:23, Nicola Mazzucato wrote:
> > > Hi Viresh,
> > >
> > > In this V8 I have addressed your comments:
> > > - correct the goto in patch 1/3
> > > - improve comment in patch 2/3 for dev_pm_opp_get_opp_count()
> >
> > LGTM. I will apply them after the merge window is over. Thanks.
>
> I am planning to merge the series on scmi[1] which changes scmi-cpufreq.c
> and will conflict with these changes I think. If possible either,
>
> 1. Share a branch with these changes that I can merge or
> 2. I can take patch 1/3 and 2/3 with other scmi changes with your Ack.
>
> I am fine either way, let me know by v5.12-rc1
I have applied 3/3, you can take first two and add my Ack.
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
--
viresh
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v8 0/3] CPUFreq: Add support for opp-sharing cpus
2021-02-22 4:39 ` Viresh Kumar
@ 2021-02-22 11:14 ` Sudeep Holla
0 siblings, 0 replies; 10+ messages in thread
From: Sudeep Holla @ 2021-02-22 11:14 UTC (permalink / raw)
To: Viresh Kumar
Cc: cristian.marussi, linux-pm, vireshk, rjw, linux-kernel,
Nicola Mazzucato, Sudeep Holla, chris.redpath, ionela.voinescu,
morten.rasmussen, linux-arm-kernel
On Mon, Feb 22, 2021 at 10:09:04AM +0530, Viresh Kumar wrote:
> On 19-02-21, 19:16, Sudeep Holla wrote:
> > Hi Viresh,
> >
> > On Fri, Feb 19, 2021 at 09:49:44AM +0530, Viresh Kumar wrote:
> > > On 18-02-21, 22:23, Nicola Mazzucato wrote:
> > > > Hi Viresh,
> > > >
> > > > In this V8 I have addressed your comments:
> > > > - correct the goto in patch 1/3
> > > > - improve comment in patch 2/3 for dev_pm_opp_get_opp_count()
> > >
> > > LGTM. I will apply them after the merge window is over. Thanks.
> >
> > I am planning to merge the series on scmi[1] which changes scmi-cpufreq.c
> > and will conflict with these changes I think. If possible either,
> >
> > 1. Share a branch with these changes that I can merge or
> > 2. I can take patch 1/3 and 2/3 with other scmi changes with your Ack.
> >
> > I am fine either way, let me know by v5.12-rc1
>
> I have applied 3/3, you can take first two and add my Ack.
>
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
>
Thanks Viresh, I will pick after v5.12-rc1
--
Regards,
Sudeep
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v8 0/3] CPUFreq: Add support for opp-sharing cpus
2021-02-18 22:23 [PATCH v8 0/3] CPUFreq: Add support for opp-sharing cpus Nicola Mazzucato
` (3 preceding siblings ...)
2021-02-19 4:19 ` [PATCH v8 0/3] CPUFreq: Add support for opp-sharing cpus Viresh Kumar
@ 2021-03-09 11:59 ` Sudeep Holla
2021-03-23 9:30 ` Sudeep Holla
5 siblings, 0 replies; 10+ messages in thread
From: Sudeep Holla @ 2021-03-09 11:59 UTC (permalink / raw)
To: Nicola Mazzucato, cristian.marussi, rjw, linux-arm-kernel,
linux-kernel, vireshk, linux-pm
Cc: Sudeep Holla, chris.redpath, morten.rasmussen, ionela.voinescu
On Thu, 18 Feb 2021 22:23:23 +0000, Nicola Mazzucato wrote:
> In this V8 I have addressed your comments:
> - correct the goto in patch 1/3
> - improve comment in patch 2/3 for dev_pm_opp_get_opp_count()
>
> Many thanks,
> Nicola
>
> [...]
Applied the first 2 patches to sudeep.holla/linux (for-next/scmi), thanks!
[1/3] scmi-cpufreq: Remove deferred probe
https://git.kernel.org/sudeep.holla/c/2a3390d53b
[2/3] scmi-cpufreq: Get opp_shared_cpus from opp-v2 for EM
https://git.kernel.org/sudeep.holla/c/dac7a57d2a
--
Regards,
Sudeep
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v8 0/3] CPUFreq: Add support for opp-sharing cpus
2021-02-18 22:23 [PATCH v8 0/3] CPUFreq: Add support for opp-sharing cpus Nicola Mazzucato
` (4 preceding siblings ...)
2021-03-09 11:59 ` Sudeep Holla
@ 2021-03-23 9:30 ` Sudeep Holla
5 siblings, 0 replies; 10+ messages in thread
From: Sudeep Holla @ 2021-03-23 9:30 UTC (permalink / raw)
To: linux-pm, linux-arm-kernel, vireshk, Nicola Mazzucato, rjw,
cristian.marussi, linux-kernel
Cc: Sudeep Holla, ionela.voinescu, chris.redpath, morten.rasmussen
On Thu, 18 Feb 2021 22:23:23 +0000, Nicola Mazzucato wrote:
> In this V8 I have addressed your comments:
> - correct the goto in patch 1/3
> - improve comment in patch 2/3 for dev_pm_opp_get_opp_count()
>
> Many thanks,
> Nicola
>
> [...]
(New commit info after rebase to v5.12-rc2 for obvious reasons)
Applied to sudeep.holla/linux (for-next/scmi), thanks!
[1/3] scmi-cpufreq: Remove deferred probe
https://git.kernel.org/sudeep.holla/c/71a37cd6a5
[2/3] scmi-cpufreq: Get opp_shared_cpus from opp-v2 for EM
https://git.kernel.org/sudeep.holla/c/80a064dbd5
--
Regards,
Sudeep
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 10+ messages in thread