All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukasz Luba <lukasz.luba@arm.com>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Rafael Wysocki <rjw@rjwysocki.net>,
	Vincent Donnefort <vincent.donnefort@arm.com>,
	linux-pm@vger.kernel.org,
	Vincent Guittot <vincent.guittot@linaro.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/8] cpufreq: Auto-register with energy model if asked
Date: Tue, 10 Aug 2021 10:36:57 +0100	[thread overview]
Message-ID: <f96f852f-0d73-7ad2-d7a9-eab6a5b7f454@arm.com> (raw)
In-Reply-To: <b48e2c944db072c220a1b0ae0c3d94eb1c4da7ab.1628579170.git.viresh.kumar@linaro.org>



On 8/10/21 8:36 AM, Viresh Kumar wrote:
> Many cpufreq drivers register with the energy model for each policy and
> do exactly the same thing. Follow the footsteps of thermal-cooling, to
> get it done from the cpufreq core itself.
> 
> Provide a cpufreq driver flag so drivers can ask the cpufreq core to
> register with the EM core on their behalf. This allows us to get rid of
> duplicated code in the drivers.
> 
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
>   drivers/cpufreq/cpufreq.c | 9 +++++++++
>   include/linux/cpufreq.h   | 6 ++++++
>   2 files changed, 15 insertions(+)
> 
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 06c526d66dd3..a060dc2aa2f2 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -23,6 +23,7 @@
>   #include <linux/kernel_stat.h>
>   #include <linux/module.h>
>   #include <linux/mutex.h>
> +#include <linux/pm_opp.h>
>   #include <linux/pm_qos.h>
>   #include <linux/slab.h>
>   #include <linux/suspend.h>
> @@ -1511,6 +1512,11 @@ static int cpufreq_online(unsigned int cpu)
>   	if (cpufreq_thermal_control_enabled(cpufreq_driver))
>   		policy->cdev = of_cpufreq_cooling_register(policy);

The of_cpufreq_cooling_register() should be called after the EM
is present for the CPU device. When you check that function,
you will see that we call
em_cpu_get(policy->cpu)
to get the EM pointer. Otherwise IPA might fail.

>   
> +	if (cpufreq_driver->flags & CPUFREQ_REGISTER_WITH_EM) {
> +		dev_pm_opp_of_register_em(get_cpu_device(policy->cpu),
> +					  policy->related_cpus);
> +	}
> +

So please move these new code above the thermal registration few lines
above.

>   	pr_debug("initialization complete\n");
>   
>   	return 0;
> @@ -1602,6 +1608,9 @@ static int cpufreq_offline(unsigned int cpu)
>   		goto unlock;
>   	}
>   
> +	if (cpufreq_driver->flags & CPUFREQ_REGISTER_WITH_EM)
> +		dev_pm_opp_of_unregister_em(get_cpu_device(cpu));
> +

Here is similar situation. Move the EM unregister after the thermal is
done. For consistency it's OK, the real EM struct won't be freed
for CPUs (due to scheduler reasons), though.

>   	if (cpufreq_thermal_control_enabled(cpufreq_driver)) {
>   		cpufreq_cooling_unregister(policy->cdev);
>   		policy->cdev = NULL;
> diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
> index 9fd719475fcd..f11723cd4cca 100644
> --- a/include/linux/cpufreq.h
> +++ b/include/linux/cpufreq.h
> @@ -424,6 +424,12 @@ struct cpufreq_driver {
>    */
>   #define CPUFREQ_NO_AUTO_DYNAMIC_SWITCHING	BIT(6)
>   
> +/*
> + * Set by drivers that want the core to automatically register the CPU device
> + * with Energy Model.
> + */
> +#define CPUFREQ_REGISTER_WITH_EM		BIT(7)
> +
>   int cpufreq_register_driver(struct cpufreq_driver *driver_data);
>   int cpufreq_unregister_driver(struct cpufreq_driver *driver_data);
>   
> 

  reply	other threads:[~2021-08-10  9:37 UTC|newest]

Thread overview: 91+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-10  7:36 [PATCH 0/8] cpufreq: Auto-register with energy model Viresh Kumar
2021-08-10  7:36 ` Viresh Kumar
2021-08-10  7:36 ` Viresh Kumar
2021-08-10  7:36 ` [PATCH 1/8] cpufreq: Auto-register with energy model if asked Viresh Kumar
2021-08-10  9:36   ` Lukasz Luba [this message]
2021-08-10  9:38     ` Viresh Kumar
2021-08-10 15:33       ` Lukasz Luba
2021-08-10  7:36 ` [PATCH 2/8] cpufreq: dt: Use auto-registration for energy model Viresh Kumar
2021-08-10 10:19   ` Lukasz Luba
2021-08-10  7:36 ` [PATCH 3/8] cpufreq: imx6q: " Viresh Kumar
2021-08-10  7:36   ` Viresh Kumar
2021-08-10 10:20   ` Lukasz Luba
2021-08-10 10:20     ` Lukasz Luba
2021-08-10  7:36 ` [PATCH 4/8] cpufreq: mediatek: " Viresh Kumar
2021-08-10  7:36   ` Viresh Kumar
2021-08-10  7:36   ` Viresh Kumar
2021-08-10 10:20   ` Lukasz Luba
2021-08-10 10:20     ` Lukasz Luba
2021-08-10 10:20     ` Lukasz Luba
2021-08-10  7:36 ` [PATCH 5/8] cpufreq: omap: " Viresh Kumar
2021-08-10 10:24   ` Lukasz Luba
2021-08-10  7:36 ` [PATCH 6/8] cpufreq: qcom-cpufreq-hw: " Viresh Kumar
2021-08-10 10:26   ` Lukasz Luba
2021-08-10  7:36 ` [PATCH 7/8] cpufreq: scpi: " Viresh Kumar
2021-08-10  7:36   ` Viresh Kumar
2021-08-10 10:27   ` Lukasz Luba
2021-08-10 10:27     ` Lukasz Luba
2021-08-11  2:40   ` Sudeep Holla
2021-08-11  2:40     ` Sudeep Holla
2021-08-10  7:36 ` [PATCH 8/8] cpufreq: vexpress: " Viresh Kumar
2021-08-10  7:36   ` Viresh Kumar
2021-08-10 10:05   ` Lukasz Luba
2021-08-10 10:05     ` Lukasz Luba
2021-08-10 10:06     ` Viresh Kumar
2021-08-10 10:06       ` Viresh Kumar
2021-08-10 10:11       ` Lukasz Luba
2021-08-10 10:11         ` Lukasz Luba
2021-08-10 10:12         ` Viresh Kumar
2021-08-10 10:12           ` Viresh Kumar
2021-08-10 10:30   ` Lukasz Luba
2021-08-10 10:30     ` Lukasz Luba
2021-08-11  2:40   ` Sudeep Holla
2021-08-11  2:40     ` Sudeep Holla
2021-08-10  9:17 ` [PATCH 0/8] cpufreq: Auto-register with " Lukasz Luba
2021-08-10  9:17   ` Lukasz Luba
2021-08-10  9:17   ` Lukasz Luba
2021-08-10  9:27   ` Viresh Kumar
2021-08-10  9:27     ` Viresh Kumar
2021-08-10  9:27     ` Viresh Kumar
2021-08-10  9:35     ` Lukasz Luba
2021-08-10  9:35       ` Lukasz Luba
2021-08-10  9:35       ` Lukasz Luba
2021-08-10 12:35 ` Quentin Perret
2021-08-10 12:35   ` Quentin Perret
2021-08-10 12:35   ` Quentin Perret
2021-08-10 13:25   ` Lukasz Luba
2021-08-10 13:25     ` Lukasz Luba
2021-08-10 13:25     ` Lukasz Luba
2021-08-10 13:53     ` Quentin Perret
2021-08-10 13:53       ` Quentin Perret
2021-08-10 13:53       ` Quentin Perret
2021-08-11  5:18   ` Viresh Kumar
2021-08-11  5:18     ` Viresh Kumar
2021-08-11  5:18     ` Viresh Kumar
2021-08-11  5:34     ` Viresh Kumar
2021-08-11  5:34       ` Viresh Kumar
2021-08-11  5:34       ` Viresh Kumar
2021-08-11  9:48       ` Quentin Perret
2021-08-11  9:48         ` Quentin Perret
2021-08-11  9:48         ` Quentin Perret
2021-08-11  9:53         ` Viresh Kumar
2021-08-11  9:53           ` Viresh Kumar
2021-08-11  9:53           ` Viresh Kumar
2021-08-11 10:12           ` Quentin Perret
2021-08-11 10:12             ` Quentin Perret
2021-08-11 10:12             ` Quentin Perret
2021-08-11 10:14             ` Viresh Kumar
2021-08-11 10:14               ` Viresh Kumar
2021-08-11 10:14               ` Viresh Kumar
2021-08-11  8:37     ` Quentin Perret
2021-08-11  8:37       ` Quentin Perret
2021-08-11  8:37       ` Quentin Perret
2021-08-11  9:13       ` Viresh Kumar
2021-08-11  9:13         ` Viresh Kumar
2021-08-11  9:13         ` Viresh Kumar
2021-08-11  9:34         ` Quentin Perret
2021-08-11  9:34           ` Quentin Perret
2021-08-11  9:34           ` Quentin Perret
2021-08-11  9:36           ` Viresh Kumar
2021-08-11  9:36             ` Viresh Kumar
2021-08-11  9:36             ` Viresh Kumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f96f852f-0d73-7ad2-d7a9-eab6a5b7f454@arm.com \
    --to=lukasz.luba@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=vincent.donnefort@arm.com \
    --cc=vincent.guittot@linaro.org \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.