mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Punit Agrawal <punit.agrawal@arm.com>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, edubezval@gmail.com,
	dawei.chien@mediatek.com, javi.merino@arm.com, rjw@rjwysocki.net,
	Sudeep Holla <sudeep.holla@arm.com>
Subject: Re: [PATCH v5 3/3] cpufreq: arm_big_little: Add support to register a cpufreq cooling device
Date: Wed, 18 Nov 2015 13:33:13 +0000	[thread overview]
Message-ID: <9hh8u5vph46.fsf@e105922-lin.cambridge.arm.com> (raw)
In-Reply-To: <20151118054216.GE7336@ubuntu> (Viresh Kumar's message of "Wed, 18 Nov 2015 11:12:40 +0530")

Viresh Kumar <viresh.kumar@linaro.org> writes:

> On 17-11-15, 12:06, Punit Agrawal wrote:
>> Register passive cooling devices when initialising cpufreq on
>> big.LITTLE systems. If the device tree provides a dynamic power
>> coefficient for the CPUs then the bound cooling device will support
>> the extensions that allow it to be used with all the existing thermal
>> governors including the power allocator governor.
>> 
>> A cooling device will be created per individual frequency domain and
>> can be bound to thermal zones via the thermal DT bindings.
>> 
>> Signed-off-by: Punit Agrawal <punit.agrawal@arm.com>
>> Cc: Viresh Kumar <viresh.kumar@linaro.org>
>> Cc: Sudeep Holla <sudeep.holla@arm.com>
>> Cc: Eduardo Valentin <edubezval@gmail.com>
>> ---
>>  drivers/cpufreq/Kconfig.arm      |  2 ++
>>  drivers/cpufreq/arm_big_little.c | 41 ++++++++++++++++++++++++++++++++++++++++
>>  2 files changed, 43 insertions(+)
>> 
>> diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm
>> index 1582c1c..0e0052e 100644
>> --- a/drivers/cpufreq/Kconfig.arm
>> +++ b/drivers/cpufreq/Kconfig.arm
>> @@ -6,6 +6,8 @@
>>  config ARM_BIG_LITTLE_CPUFREQ
>>  	tristate "Generic ARM big LITTLE CPUfreq driver"
>>  	depends on (ARM_CPU_TOPOLOGY || ARM64) && HAVE_CLK
>> +	# if CPU_THERMAL is on and THERMAL=m, ARM_BIT_LITTLE_CPUFREQ cannot be =y
>> +	depends on !CPU_THERMAL || THERMAL
>>  	select PM_OPP
>>  	help
>>  	  This enables the Generic CPUfreq driver for ARM big.LITTLE platforms.
>> diff --git a/drivers/cpufreq/arm_big_little.c b/drivers/cpufreq/arm_big_little.c
>> index c5d256c..c251247 100644
>> --- a/drivers/cpufreq/arm_big_little.c
>> +++ b/drivers/cpufreq/arm_big_little.c
>> @@ -23,6 +23,7 @@
>>  #include <linux/cpu.h>
>>  #include <linux/cpufreq.h>
>>  #include <linux/cpumask.h>
>> +#include <linux/cpu_cooling.h>
>>  #include <linux/export.h>
>>  #include <linux/module.h>
>>  #include <linux/mutex.h>
>> @@ -55,6 +56,7 @@ static bool bL_switching_enabled;
>>  #define ACTUAL_FREQ(cluster, freq)  ((cluster == A7_CLUSTER) ? freq << 1 : freq)
>>  #define VIRT_FREQ(cluster, freq)    ((cluster == A7_CLUSTER) ? freq >> 1 : freq)
>>  
>> +static struct thermal_cooling_device *cdev[MAX_CLUSTERS];
>>  static struct cpufreq_arm_bL_ops *arm_bL_ops;
>>  static struct clk *clk[MAX_CLUSTERS];
>>  static struct cpufreq_frequency_table *freq_table[MAX_CLUSTERS + 1];
>> @@ -493,6 +495,12 @@ static int bL_cpufreq_init(struct cpufreq_policy *policy)
>>  static int bL_cpufreq_exit(struct cpufreq_policy *policy)
>>  {
>>  	struct device *cpu_dev;
>> +	int cur_cluster = cpu_to_cluster(policy->cpu);
>> +
>> +	if (cur_cluster < MAX_CLUSTERS) {
>> +		cpufreq_cooling_unregister(cdev[cur_cluster]);
>> +		cdev[cur_cluster] = NULL;
>> +	}
>>  
>>  	cpu_dev = get_cpu_device(policy->cpu);
>>  	if (!cpu_dev) {
>> @@ -507,6 +515,38 @@ static int bL_cpufreq_exit(struct cpufreq_policy *policy)
>>  	return 0;
>>  }
>>  
>> +static void bL_cpufreq_ready(struct cpufreq_policy *policy)
>> +{
>> +	struct device *cpu_dev = get_cpu_device(policy->cpu);
>> +	int cur_cluster = cpu_to_cluster(policy->cpu);
>> +	struct device_node *np;
>> +
>> +	/* Do not register a cpu_cooling device if we are in IKS mode */
>> +	if (cur_cluster >= MAX_CLUSTERS)
>> +		return;
>> +
>> +	np = of_node_get(cpu_dev->of_node);
>> +	if (WARN_ON(!np))
>> +		return;
>> +
>> +	if (of_find_property(np, "#cooling-cells", NULL)) {
>> +		u32 power_coefficient = 0;
>> +
>> +		of_property_read_u32(np, "dynamic-power-coefficient",
>> +				     &power_coefficient);
>> +
>> +		cdev[cur_cluster] = of_cpufreq_power_cooling_register(np,
>> +				policy->related_cpus, power_coefficient, NULL);
>> +		if (IS_ERR(cdev[cur_cluster])) {
>> +			dev_err(cpu_dev,
>> +				"running cpufreq without cooling device: %ld\n",
>> +				PTR_ERR(cdev[cur_cluster]));
>> +			cdev[cur_cluster] = NULL;
>> +		}
>> +	}
>> +	of_node_put(np);
>> +}
>> +
>>  static struct cpufreq_driver bL_cpufreq_driver = {
>>  	.name			= "arm-big-little",
>>  	.flags			= CPUFREQ_STICKY |
>> @@ -517,6 +557,7 @@ static struct cpufreq_driver bL_cpufreq_driver = {
>>  	.get			= bL_cpufreq_get_rate,
>>  	.init			= bL_cpufreq_init,
>>  	.exit			= bL_cpufreq_exit,
>> +	.ready			= bL_cpufreq_ready,
>>  	.attr			= cpufreq_generic_attr,
>>  };
>
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

Thanks for the Ack.

Will you or Rafael be picking up the series or do they need to go via
arm-soc?

  reply	other threads:[~2015-11-18 13:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-17 12:06 [PATCH v5 0/3] Dynamic power model from device tree Punit Agrawal
2015-11-17 12:06 ` [PATCH v5 1/3] devicetree: bindings: Add optional dynamic-power-coefficient property Punit Agrawal
2015-11-17 12:06 ` [PATCH v5 2/3] cpufreq-dt: Supply power coefficient when registering cooling devices Punit Agrawal
2015-11-17 12:06 ` [PATCH v5 3/3] cpufreq: arm_big_little: Add support to register a cpufreq cooling device Punit Agrawal
2015-11-18  5:42   ` Viresh Kumar
2015-11-18 13:33     ` Punit Agrawal [this message]
2015-11-18 14:04       ` Viresh Kumar
2015-12-14 23:55         ` Rafael J. Wysocki

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=9hh8u5vph46.fsf@e105922-lin.cambridge.arm.com \
    --to=punit.agrawal@arm.com \
    --cc=dawei.chien@mediatek.com \
    --cc=devicetree@vger.kernel.org \
    --cc=edubezval@gmail.com \
    --cc=javi.merino@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=sudeep.holla@arm.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®