diff mbox series

[1/2] Documentation: power: Add description about new callback for EM registration

Message ID 20211102180144.1647-1-lukasz.luba@arm.com (mailing list archive)
State Mainlined, archived
Headers show
Series [1/2] Documentation: power: Add description about new callback for EM registration | expand

Commit Message

Lukasz Luba Nov. 2, 2021, 6:01 p.m. UTC
The Energy Model (EM) registration for CPUs should now be done using
a dedicated callback added recently into CPUFreq framework and drivers.

Commit c17495b01b72 ("cpufreq: Add callback to register with energy model")

The callback guaranties that the EM registration is called at the right
time during driver setup. To avoid mistakes update the documentation
to align with the existing code implementation.

Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
---
 Documentation/power/energy-model.rst | 31 ++++++++++++++--------------
 1 file changed, 16 insertions(+), 15 deletions(-)

Comments

Lukasz Luba Nov. 9, 2021, 10:38 a.m. UTC | #1
Hi Rafael,


On 11/2/21 6:01 PM, Lukasz Luba wrote:
> The Energy Model (EM) registration for CPUs should now be done using
> a dedicated callback added recently into CPUFreq framework and drivers.
> 
> Commit c17495b01b72 ("cpufreq: Add callback to register with energy model")
> 
> The callback guaranties that the EM registration is called at the right
> time during driver setup. To avoid mistakes update the documentation
> to align with the existing code implementation.
> 
> Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
> ---
>   Documentation/power/energy-model.rst | 31 ++++++++++++++--------------
>   1 file changed, 16 insertions(+), 15 deletions(-)
> 


Gentle ping. Could you have a look at these documentation
two patches and maybe pick them, please?
They are trying to solve some confusion discussed with our partners
recently.

Regards,
Lukasz
Rafael J. Wysocki Nov. 10, 2021, 8:28 p.m. UTC | #2
On Tue, Nov 9, 2021 at 11:38 AM Lukasz Luba <lukasz.luba@arm.com> wrote:
>
> Hi Rafael,
>
>
> On 11/2/21 6:01 PM, Lukasz Luba wrote:
> > The Energy Model (EM) registration for CPUs should now be done using
> > a dedicated callback added recently into CPUFreq framework and drivers.
> >
> > Commit c17495b01b72 ("cpufreq: Add callback to register with energy model")
> >
> > The callback guaranties that the EM registration is called at the right
> > time during driver setup. To avoid mistakes update the documentation
> > to align with the existing code implementation.
> >
> > Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
> > ---
> >   Documentation/power/energy-model.rst | 31 ++++++++++++++--------------
> >   1 file changed, 16 insertions(+), 15 deletions(-)
> >
>
>
> Gentle ping. Could you have a look at these documentation
> two patches and maybe pick them, please?
> They are trying to solve some confusion discussed with our partners
> recently.

Both applied as 5.16-rc material now, thanks!
Lukasz Luba Nov. 10, 2021, 8:50 p.m. UTC | #3
On 11/10/21 8:28 PM, Rafael J. Wysocki wrote:
> On Tue, Nov 9, 2021 at 11:38 AM Lukasz Luba <lukasz.luba@arm.com> wrote:
>>
>> Hi Rafael,
>>
>>
>> On 11/2/21 6:01 PM, Lukasz Luba wrote:
>>> The Energy Model (EM) registration for CPUs should now be done using
>>> a dedicated callback added recently into CPUFreq framework and drivers.
>>>
>>> Commit c17495b01b72 ("cpufreq: Add callback to register with energy model")
>>>
>>> The callback guaranties that the EM registration is called at the right
>>> time during driver setup. To avoid mistakes update the documentation
>>> to align with the existing code implementation.
>>>
>>> Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
>>> ---
>>>    Documentation/power/energy-model.rst | 31 ++++++++++++++--------------
>>>    1 file changed, 16 insertions(+), 15 deletions(-)
>>>
>>
>>
>> Gentle ping. Could you have a look at these documentation
>> two patches and maybe pick them, please?
>> They are trying to solve some confusion discussed with our partners
>> recently.
> 
> Both applied as 5.16-rc material now, thanks!
> 

Thank you Rafael!
diff mbox series

Patch

diff --git a/Documentation/power/energy-model.rst b/Documentation/power/energy-model.rst
index 8a2788afe89b..7af0e1760962 100644
--- a/Documentation/power/energy-model.rst
+++ b/Documentation/power/energy-model.rst
@@ -138,6 +138,10 @@  or in Section 2.4
 3. Example driver
 -----------------
 
+The CPUFreq framework supports dedicated callback for registering
+the EM for a given CPU(s) 'policy' object: cpufreq_driver::register_em().
+That callback has to be implemented properly for a given driver,
+because the framework would call it at the right time during setup.
 This section provides a simple example of a CPUFreq driver registering a
 performance domain in the Energy Model framework using the (fake) 'foo'
 protocol. The driver implements an est_power() function to be provided to the
@@ -167,25 +171,22 @@  EM framework::
   20		return 0;
   21	}
   22
-  23	static int foo_cpufreq_init(struct cpufreq_policy *policy)
+  23	static void foo_cpufreq_register_em(struct cpufreq_policy *policy)
   24	{
   25		struct em_data_callback em_cb = EM_DATA_CB(est_power);
   26		struct device *cpu_dev;
-  27		int nr_opp, ret;
+  27		int nr_opp;
   28
   29		cpu_dev = get_cpu_device(cpumask_first(policy->cpus));
   30
-  31     	/* Do the actual CPUFreq init work ... */
-  32     	ret = do_foo_cpufreq_init(policy);
-  33     	if (ret)
-  34     		return ret;
-  35
-  36     	/* Find the number of OPPs for this policy */
-  37     	nr_opp = foo_get_nr_opp(policy);
+  31     	/* Find the number of OPPs for this policy */
+  32     	nr_opp = foo_get_nr_opp(policy);
+  33
+  34     	/* And register the new performance domain */
+  35     	em_dev_register_perf_domain(cpu_dev, nr_opp, &em_cb, policy->cpus,
+  36					    true);
+  37	}
   38
-  39     	/* And register the new performance domain */
-  40     	em_dev_register_perf_domain(cpu_dev, nr_opp, &em_cb, policy->cpus,
-  41					    true);
-  42
-  43	        return 0;
-  44	}
+  39	static struct cpufreq_driver foo_cpufreq_driver = {
+  40		.register_em = foo_cpufreq_register_em,
+  41	};