devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V3] cpufreq: qoriq: Register cooling device based on device tree
@ 2015-11-26  9:21 Jia Hongtao
       [not found] ` <1448529671-48216-1-git-send-email-hongtao.jia-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
  0 siblings, 1 reply; 17+ messages in thread
From: Jia Hongtao @ 2015-11-26  9:21 UTC (permalink / raw)
  To: edubezval, viresh.kumar
  Cc: linux-pm, linuxppc-dev, devicetree, scottwood, hongtao.jia

Register the qoriq cpufreq driver as a cooling device, based on the
thermal device tree framework. When temperature crosses the passive trip
point cpufreq is used to throttle CPUs.

Signed-off-by: Jia Hongtao <hongtao.jia@freescale.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
---
Changes for V3:
* Removed unnecessary cpu node NULL check.

Changes for V2:
* Using ->ready callback for cpu cooling device registering.

 drivers/cpufreq/qoriq-cpufreq.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/drivers/cpufreq/qoriq-cpufreq.c b/drivers/cpufreq/qoriq-cpufreq.c
index 4f53fa2..cb6a62c 100644
--- a/drivers/cpufreq/qoriq-cpufreq.c
+++ b/drivers/cpufreq/qoriq-cpufreq.c
@@ -12,6 +12,7 @@
 
 #include <linux/clk.h>
 #include <linux/cpufreq.h>
+#include <linux/cpu_cooling.h>
 #include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
@@ -33,6 +34,7 @@
 struct cpu_data {
 	struct clk **pclk;
 	struct cpufreq_frequency_table *table;
+	struct thermal_cooling_device *cdev;
 };
 
 /*
@@ -260,6 +262,27 @@ static int qoriq_cpufreq_target(struct cpufreq_policy *policy,
 	return clk_set_parent(policy->clk, parent);
 }
 
+
+static void qoriq_cpufreq_ready(struct cpufreq_policy *policy)
+{
+	struct cpu_data *cpud = policy->driver_data;
+	struct device_node *np = of_get_cpu_node(policy->cpu, NULL);
+
+	if (of_find_property(np, "#cooling-cells", NULL)) {
+		cpud->cdev = of_cpufreq_cooling_register(np,
+							 policy->related_cpus);
+
+		if (IS_ERR(cpud->cdev)) {
+			pr_err("Failed to register cooling device cpu%d: %ld\n",
+					policy->cpu, PTR_ERR(cpud->cdev));
+
+			cpud->cdev = NULL;
+		}
+	}
+
+	of_node_put(np);
+}
+
 static struct cpufreq_driver qoriq_cpufreq_driver = {
 	.name		= "qoriq_cpufreq",
 	.flags		= CPUFREQ_CONST_LOOPS,
@@ -268,6 +291,7 @@ static struct cpufreq_driver qoriq_cpufreq_driver = {
 	.verify		= cpufreq_generic_frequency_table_verify,
 	.target_index	= qoriq_cpufreq_target,
 	.get		= cpufreq_generic_get,
+	.ready		= qoriq_cpufreq_ready,
 	.attr		= cpufreq_generic_attr,
 };
 
-- 
2.1.0.27.g96db324


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

* Re: [PATCH V3] cpufreq: qoriq: Register cooling device based on device tree
       [not found] ` <1448529671-48216-1-git-send-email-hongtao.jia-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
@ 2015-12-14 23:58   ` Rafael J. Wysocki
       [not found]     ` <1697588.dLcbZBRWO4-sKB8Sp2ER+y1GS7QM15AGw@public.gmane.org>
  0 siblings, 1 reply; 17+ messages in thread
From: Rafael J. Wysocki @ 2015-12-14 23:58 UTC (permalink / raw)
  To: Jia Hongtao
  Cc: edubezval-Re5JQEeQqe8AvxtiuMwx3w,
	viresh.kumar-QSEj5FYQhm4dnm+yROfE0A,
	linux-pm-u79uwXL29TY76Z2rM5mHXA,
	linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	scottwood-KZfg59tc24xl57MIdRCFDg

On Thursday, November 26, 2015 05:21:11 PM Jia Hongtao wrote:
> Register the qoriq cpufreq driver as a cooling device, based on the
> thermal device tree framework. When temperature crosses the passive trip
> point cpufreq is used to throttle CPUs.
> 
> Signed-off-by: Jia Hongtao <hongtao.jia-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
> Reviewed-by: Viresh Kumar <viresh.kumar-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>

Applied, thanks!

Rafael

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH V3] cpufreq: qoriq: Register cooling device based on device tree
       [not found]     ` <1697588.dLcbZBRWO4-sKB8Sp2ER+y1GS7QM15AGw@public.gmane.org>
@ 2015-12-18 22:32       ` Arnd Bergmann
  2016-01-11 14:54         ` 答复: " Hongtao Jia
  2016-02-26 18:04         ` Li Yang
  0 siblings, 2 replies; 17+ messages in thread
From: Arnd Bergmann @ 2015-12-18 22:32 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Jia Hongtao, edubezval-Re5JQEeQqe8AvxtiuMwx3w,
	viresh.kumar-QSEj5FYQhm4dnm+yROfE0A,
	linux-pm-u79uwXL29TY76Z2rM5mHXA,
	linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	scottwood-KZfg59tc24xl57MIdRCFDg

On Tuesday 15 December 2015 00:58:26 Rafael J. Wysocki wrote:
> On Thursday, November 26, 2015 05:21:11 PM Jia Hongtao wrote:
> > Register the qoriq cpufreq driver as a cooling device, based on the
> > thermal device tree framework. When temperature crosses the passive trip
> > point cpufreq is used to throttle CPUs.
> > 
> > Signed-off-by: Jia Hongtao <hongtao.jia-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
> > Reviewed-by: Viresh Kumar <viresh.kumar-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> 
> Applied, thanks!
> 

I got a randconfig build error today:

drivers/built-in.o: In function `qoriq_cpufreq_ready':
debugfs.c:(.text+0x1f4688): undefined reference to `of_cpufreq_cooling_register'

CONFIG_OF=y
CONFIG_QORIQ_CPUFREQ=y
CONFIG_THERMAL=m
CONFIG_THERMAL_OF=y

I think you need a 'depends on THERMAL' to prevent the driver from
being built-in when THERMAL=m.

	Arnd
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* 答复: [PATCH V3] cpufreq: qoriq: Register cooling device based on device tree
  2015-12-18 22:32       ` Arnd Bergmann
@ 2016-01-11 14:54         ` Hongtao Jia
  2016-01-11 17:34           ` Scott Wood
  2016-02-26 18:04         ` Li Yang
  1 sibling, 1 reply; 17+ messages in thread
From: Hongtao Jia @ 2016-01-11 14:54 UTC (permalink / raw)
  To: Arnd Bergmann, Rafael J. Wysocki
  Cc: devicetree@vger.kernel.org, linux-pm@vger.kernel.org,
	viresh.kumar@linaro.org, Jia Hongtao, edubezval@gmail.com,
	Scott Wood, linuxppc-dev@lists.ozlabs.org

Sorry for the late response. I got a knee surgery to do.
See comments at the end.

> -----邮件原件-----
> 发件人: Arnd Bergmann [mailto:arnd@arndb.de]
> 发送时间: Saturday, December 19, 2015 6:33 AM
> 收件人: Rafael J. Wysocki <rjw@rjwysocki.net>
> 抄送: Jia Hongtao <hongtao.jia@freescale.com>; edubezval@gmail.com;
> viresh.kumar@linaro.org; linux-pm@vger.kernel.org; linuxppc-
> dev@lists.ozlabs.org; devicetree@vger.kernel.org; Scott Wood
> <scottwood@freescale.com>
> 主题: Re: [PATCH V3] cpufreq: qoriq: Register cooling device based on device
> tree
> 
> On Tuesday 15 December 2015 00:58:26 Rafael J. Wysocki wrote:
> > On Thursday, November 26, 2015 05:21:11 PM Jia Hongtao wrote:
> > > Register the qoriq cpufreq driver as a cooling device, based on the
> > > thermal device tree framework. When temperature crosses the passive
> > > trip point cpufreq is used to throttle CPUs.
> > >
> > > Signed-off-by: Jia Hongtao <hongtao.jia@freescale.com>
> > > Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
> >
> > Applied, thanks!
> >
> 
> I got a randconfig build error today:
> 
> drivers/built-in.o: In function `qoriq_cpufreq_ready':
> debugfs.c:(.text+0x1f4688): undefined reference to
> `of_cpufreq_cooling_register'
> 
> CONFIG_OF=y
> CONFIG_QORIQ_CPUFREQ=y
> CONFIG_THERMAL=m
> CONFIG_THERMAL_OF=y
> 
> I think you need a 'depends on THERMAL' to prevent the driver from being
> built-in when THERMAL=m.
> 
> 	Arnd

Correct. I need to add following lines to the Kconfig file:
depends on !CPU_THERMAL || THERMAL=y

Hi Rafael,
Should I send a new patch include this fix or send a fix patch?

Thanks.
-Hongtao.
_______________________________________________
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

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

* Re: 答复: [PATCH V3] cpufreq: qoriq: Register cooling device based on device tree
  2016-01-11 14:54         ` 答复: " Hongtao Jia
@ 2016-01-11 17:34           ` Scott Wood
  2016-01-11 21:13             ` Arnd Bergmann
  0 siblings, 1 reply; 17+ messages in thread
From: Scott Wood @ 2016-01-11 17:34 UTC (permalink / raw)
  To: Hongtao Jia, Arnd Bergmann, Rafael J. Wysocki
  Cc: devicetree@vger.kernel.org, linux-pm@vger.kernel.org, Scott Wood,
	viresh.kumar@linaro.org, Hongtao Jia, edubezval@gmail.com,
	linuxppc-dev@lists.ozlabs.org

On 01/11/2016 08:54 AM, Hongtao Jia wrote:
> Sorry for the late response. I got a knee surgery to do.
> See comments at the end.
> 
>> -----邮件原件-----
>> 发件人: Arnd Bergmann [mailto:arnd@arndb.de]
>> 发送时间: Saturday, December 19, 2015 6:33 AM
>> 收件人: Rafael J. Wysocki <rjw@rjwysocki.net>
>> 抄送: Jia Hongtao <hongtao.jia@freescale.com>; edubezval@gmail.com;
>> viresh.kumar@linaro.org; linux-pm@vger.kernel.org; linuxppc-
>> dev@lists.ozlabs.org; devicetree@vger.kernel.org; Scott Wood
>> <scottwood@freescale.com>
>> 主题: Re: [PATCH V3] cpufreq: qoriq: Register cooling device based on device
>> tree
>>
>> On Tuesday 15 December 2015 00:58:26 Rafael J. Wysocki wrote:
>>> On Thursday, November 26, 2015 05:21:11 PM Jia Hongtao wrote:
>>>> Register the qoriq cpufreq driver as a cooling device, based on the
>>>> thermal device tree framework. When temperature crosses the passive
>>>> trip point cpufreq is used to throttle CPUs.
>>>>
>>>> Signed-off-by: Jia Hongtao <hongtao.jia@freescale.com>
>>>> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
>>>
>>> Applied, thanks!
>>>
>>
>> I got a randconfig build error today:
>>
>> drivers/built-in.o: In function `qoriq_cpufreq_ready':
>> debugfs.c:(.text+0x1f4688): undefined reference to
>> `of_cpufreq_cooling_register'
>>
>> CONFIG_OF=y
>> CONFIG_QORIQ_CPUFREQ=y
>> CONFIG_THERMAL=m
>> CONFIG_THERMAL_OF=y
>>
>> I think you need a 'depends on THERMAL' to prevent the driver from being
>> built-in when THERMAL=m.
>>
>> Arnd
> 
> Correct. I need to add following lines to the Kconfig file:
> depends on !CPU_THERMAL || THERMAL=y
> 
> Hi Rafael,
> Should I send a new patch include this fix or send a fix patch?

Why THERMAL=y and not just THERMAL, which would allow building this
driver as a module?

-Scott

_______________________________________________
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

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

* Re: 答复: [PATCH V3] cpufreq: qoriq: Register cooling device based on device tree
  2016-01-11 17:34           ` Scott Wood
@ 2016-01-11 21:13             ` Arnd Bergmann
  0 siblings, 0 replies; 17+ messages in thread
From: Arnd Bergmann @ 2016-01-11 21:13 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: Scott Wood, Hongtao Jia, Rafael J. Wysocki,
	devicetree@vger.kernel.org, linux-pm@vger.kernel.org, Scott Wood,
	viresh.kumar@linaro.org, Hongtao Jia, edubezval@gmail.com

On Monday 11 January 2016 17:34:52 Scott Wood wrote:
> >>
> >> I think you need a 'depends on THERMAL' to prevent the driver from being
> >> built-in when THERMAL=m.
> >>
> >> Arnd
> > 
> > Correct. I need to add following lines to the Kconfig file:
> > depends on !CPU_THERMAL || THERMAL=y
> > 
> > Hi Rafael,
> > Should I send a new patch include this fix or send a fix patch?
> 
> Why THERMAL=y and not just THERMAL, which would allow building this
> driver as a module?

Right, that would be better, and it is what all other drivers do.

For some reason, some drivers depend on !CPU_THERMAL and others
depend on !THERMAL_OF here, and I think the result is the same, but
we are a bit inconsistent here. CPU_THERMAL cannot be set if THERMAL_OF
is disabled, and the header file only uses the 'extern' declaration
if both are set.

	Arnd

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

* Re: [PATCH V3] cpufreq: qoriq: Register cooling device based on device tree
  2015-12-18 22:32       ` Arnd Bergmann
  2016-01-11 14:54         ` 答复: " Hongtao Jia
@ 2016-02-26 18:04         ` Li Yang
  2016-02-26 20:20           ` Arnd Bergmann
  1 sibling, 1 reply; 17+ messages in thread
From: Li Yang @ 2016-02-26 18:04 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Rafael J. Wysocki, Jia Hongtao, edubezval, viresh.kumar,
	linux-pm@vger.kernel.org, linuxppc-dev, devicetree, Scott Wood

On Fri, Dec 18, 2015 at 4:32 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> On Tuesday 15 December 2015 00:58:26 Rafael J. Wysocki wrote:
>> On Thursday, November 26, 2015 05:21:11 PM Jia Hongtao wrote:
>> > Register the qoriq cpufreq driver as a cooling device, based on the
>> > thermal device tree framework. When temperature crosses the passive trip
>> > point cpufreq is used to throttle CPUs.
>> >
>> > Signed-off-by: Jia Hongtao <hongtao.jia@freescale.com>
>> > Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
>>
>> Applied, thanks!
>>
>
> I got a randconfig build error today:
>
> drivers/built-in.o: In function `qoriq_cpufreq_ready':
> debugfs.c:(.text+0x1f4688): undefined reference to `of_cpufreq_cooling_register'
>
> CONFIG_OF=y
> CONFIG_QORIQ_CPUFREQ=y
> CONFIG_THERMAL=m
> CONFIG_THERMAL_OF=y
>
> I think you need a 'depends on THERMAL' to prevent the driver from
> being built-in when THERMAL=m.

Maybe this is not the best approach.  The cpufreq feature itself
should be working independently without thermal framework.  I think we
should make the qoriq_cpufreq_ready() defined as null function if
THERMAL is not defined.

Regards,
Leo

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

* Re: [PATCH V3] cpufreq: qoriq: Register cooling device based on device tree
  2016-02-26 18:04         ` Li Yang
@ 2016-02-26 20:20           ` Arnd Bergmann
  2016-02-26 23:07             ` Li Yang
  0 siblings, 1 reply; 17+ messages in thread
From: Arnd Bergmann @ 2016-02-26 20:20 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: Li Yang, devicetree, linux-pm@vger.kernel.org, Rafael J. Wysocki,
	Jia Hongtao, edubezval, viresh.kumar, Scott Wood

On Friday 26 February 2016 12:04:59 Li Yang wrote:
> On Fri, Dec 18, 2015 at 4:32 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> > On Tuesday 15 December 2015 00:58:26 Rafael J. Wysocki wrote:
> >> On Thursday, November 26, 2015 05:21:11 PM Jia Hongtao wrote:
> >> > Register the qoriq cpufreq driver as a cooling device, based on the
> >> > thermal device tree framework. When temperature crosses the passive trip
> >> > point cpufreq is used to throttle CPUs.
> >> >
> >> > Signed-off-by: Jia Hongtao <hongtao.jia@freescale.com>
> >> > Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
> >>
> >> Applied, thanks!
> >>
> >
> > I got a randconfig build error today:
> >
> > drivers/built-in.o: In function `qoriq_cpufreq_ready':
> > debugfs.c:(.text+0x1f4688): undefined reference to `of_cpufreq_cooling_register'
> >
> > CONFIG_OF=y
> > CONFIG_QORIQ_CPUFREQ=y
> > CONFIG_THERMAL=m
> > CONFIG_THERMAL_OF=y
> >
> > I think you need a 'depends on THERMAL' to prevent the driver from
> > being built-in when THERMAL=m.
> 
> Maybe this is not the best approach.  The cpufreq feature itself
> should be working independently without thermal framework.  I think we
> should make the qoriq_cpufreq_ready() defined as null function if
> THERMAL is not defined.

It already does this when CONFIG_THERMAL is not defined, and my
patch doesn't change that. I'm not sure what you are asking for now.

Do you want to allow using the cpufreq driver as a built-in driver
even when the thermal code is in a module, and then silently skip
all thermal management as if it was turned off?

That would be this patch:

diff --git a/include/linux/cpu_cooling.h b/include/linux/cpu_cooling.h
index c156f5082758..a8d9241fc1bb 100644
--- a/include/linux/cpu_cooling.h
+++ b/include/linux/cpu_cooling.h
@@ -48,7 +48,7 @@ cpufreq_power_cooling_register(const struct cpumask *clip_cpus,
  * @np: a valid struct device_node to the cooling device device tree node.
  * @clip_cpus: cpumask of cpus where the frequency constraints will happen
  */
-#ifdef CONFIG_THERMAL_OF
+#if IS_REACHABLE(CONFIG_THERMAL_OF)
 struct thermal_cooling_device *
 of_cpufreq_cooling_register(struct device_node *np,
 			    const struct cpumask *clip_cpus);


but my feeling is that this would cause more surprises when users
find their thermal management is not active even though it was
enabled in Kconfig and the thermal module gets loaded.

	Arnd

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

* Re: [PATCH V3] cpufreq: qoriq: Register cooling device based on device tree
  2016-02-26 20:20           ` Arnd Bergmann
@ 2016-02-26 23:07             ` Li Yang
  2016-02-26 23:16               ` Arnd Bergmann
  0 siblings, 1 reply; 17+ messages in thread
From: Li Yang @ 2016-02-26 23:07 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linuxppc-dev, devicetree, linux-pm@vger.kernel.org,
	Rafael J. Wysocki, Jia Hongtao, Eduardo Valentin, Viresh Kumar,
	Scott Wood

On Fri, Feb 26, 2016 at 2:20 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> On Friday 26 February 2016 12:04:59 Li Yang wrote:
>> On Fri, Dec 18, 2015 at 4:32 PM, Arnd Bergmann <arnd@arndb.de> wrote:
>> > On Tuesday 15 December 2015 00:58:26 Rafael J. Wysocki wrote:
>> >> On Thursday, November 26, 2015 05:21:11 PM Jia Hongtao wrote:
>> >> > Register the qoriq cpufreq driver as a cooling device, based on the
>> >> > thermal device tree framework. When temperature crosses the passive trip
>> >> > point cpufreq is used to throttle CPUs.
>> >> >
>> >> > Signed-off-by: Jia Hongtao <hongtao.jia@freescale.com>
>> >> > Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
>> >>
>> >> Applied, thanks!
>> >>
>> >
>> > I got a randconfig build error today:
>> >
>> > drivers/built-in.o: In function `qoriq_cpufreq_ready':
>> > debugfs.c:(.text+0x1f4688): undefined reference to `of_cpufreq_cooling_register'
>> >
>> > CONFIG_OF=y
>> > CONFIG_QORIQ_CPUFREQ=y
>> > CONFIG_THERMAL=m
>> > CONFIG_THERMAL_OF=y
>> >
>> > I think you need a 'depends on THERMAL' to prevent the driver from
>> > being built-in when THERMAL=m.
>>
>> Maybe this is not the best approach.  The cpufreq feature itself
>> should be working independently without thermal framework.  I think we
>> should make the qoriq_cpufreq_ready() defined as null function if
>> THERMAL is not defined.
>
> It already does this when CONFIG_THERMAL is not defined, and my
> patch doesn't change that. I'm not sure what you are asking for now.

Oh.  Actually I didn't see you just sent a patch for this.  I
accidentally get into this topic when I tried to find out why cpufreq
is not working on ARMv8 platforms.  I didn't notice that
of_cpufreq_cooling_register() is already ifdef-ed.

>
> Do you want to allow using the cpufreq driver as a built-in driver
> even when the thermal code is in a module, and then silently skip
> all thermal management as if it was turned off?

Having thermal code to be built as module and qoriq_cpufreq to be
built-in is a valid situation.  Making cpufreq not possible to be used
when thermal is a module doesn't seem to be right.

>
> That would be this patch:
>
> diff --git a/include/linux/cpu_cooling.h b/include/linux/cpu_cooling.h
> index c156f5082758..a8d9241fc1bb 100644
> --- a/include/linux/cpu_cooling.h
> +++ b/include/linux/cpu_cooling.h
> @@ -48,7 +48,7 @@ cpufreq_power_cooling_register(const struct cpumask *clip_cpus,
>   * @np: a valid struct device_node to the cooling device device tree node.
>   * @clip_cpus: cpumask of cpus where the frequency constraints will happen
>   */
> -#ifdef CONFIG_THERMAL_OF
> +#if IS_REACHABLE(CONFIG_THERMAL_OF)
>  struct thermal_cooling_device *
>  of_cpufreq_cooling_register(struct device_node *np,
>                             const struct cpumask *clip_cpus);
>
>
> but my feeling is that this would cause more surprises when users
> find their thermal management is not active even though it was
> enabled in Kconfig and the thermal module gets loaded.

I don't have a perfect solution either.  But I think this is still
better than making cpufreq not usable.  The cpufreq driver will print
out an error message if thermal is not reachable.  Maybe this can
relief the confusion a little bit?

Regards,
Leo

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

* Re: [PATCH V3] cpufreq: qoriq: Register cooling device based on device tree
  2016-02-26 23:07             ` Li Yang
@ 2016-02-26 23:16               ` Arnd Bergmann
  2016-02-26 23:31                 ` Li Yang
  0 siblings, 1 reply; 17+ messages in thread
From: Arnd Bergmann @ 2016-02-26 23:16 UTC (permalink / raw)
  To: Li Yang
  Cc: linuxppc-dev, devicetree, linux-pm@vger.kernel.org,
	Rafael J. Wysocki, Jia Hongtao, Eduardo Valentin, Viresh Kumar,
	Scott Wood

On Friday 26 February 2016 17:07:09 Li Yang wrote:
> 
> I don't have a perfect solution either.  But I think this is still
> better than making cpufreq not usable.  The cpufreq driver will print
> out an error message if thermal is not reachable.  Maybe this can
> relief the confusion a little bit?

With my patch, the configuration will just force the cpufreq
driver to be a loadable module as well if thermal is a module,
so the dependency can be resolved by loading the thermal module first.

I think that is really the best way around the problem, and it
matches what other platforms do for the same problem.

	Arnd

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

* Re: [PATCH V3] cpufreq: qoriq: Register cooling device based on device tree
  2016-02-26 23:16               ` Arnd Bergmann
@ 2016-02-26 23:31                 ` Li Yang
       [not found]                   ` <CADRPPNSASmfxS=BWKvOxGKyCiqno9YvOuAfBaHwKL-Y=jQ2Dzw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 17+ messages in thread
From: Li Yang @ 2016-02-26 23:31 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linuxppc-dev, devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Rafael J. Wysocki, Jia Hongtao, Eduardo Valentin, Viresh Kumar,
	Scott Wood

On Fri, Feb 26, 2016 at 5:16 PM, Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org> wrote:
> On Friday 26 February 2016 17:07:09 Li Yang wrote:
>>
>> I don't have a perfect solution either.  But I think this is still
>> better than making cpufreq not usable.  The cpufreq driver will print
>> out an error message if thermal is not reachable.  Maybe this can
>> relief the confusion a little bit?
>
> With my patch, the configuration will just force the cpufreq
> driver to be a loadable module as well if thermal is a module,
> so the dependency can be resolved by loading the thermal module first.

It would be perfect if this it true.  But I tried with the following
change, it just makes QORIQ_CPUFREQ non-selectable if THERMAL=m.

diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig
index dcb972a38fbc..ca05037dd565 100644
--- a/drivers/cpufreq/Kconfig
+++ b/drivers/cpufreq/Kconfig
@@ -297,6 +297,7 @@ endif
 config QORIQ_CPUFREQ
        tristate "CPU frequency scaling driver for Freescale QorIQ SoCs"
        depends on OF && COMMON_CLK && (PPC_E500MC || ARM)
+       depends on !CPU_THERMAL || THERMAL=y
        select CLK_QORIQ
        help
          This adds the CPUFreq driver support for Freescale QorIQ SoCs

Regards,
Leo
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH V3] cpufreq: qoriq: Register cooling device based on device tree
       [not found]                   ` <CADRPPNSASmfxS=BWKvOxGKyCiqno9YvOuAfBaHwKL-Y=jQ2Dzw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2016-02-27  0:04                     ` Li Yang
  2016-02-27  0:08                       ` Scott Wood
  0 siblings, 1 reply; 17+ messages in thread
From: Li Yang @ 2016-02-27  0:04 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linuxppc-dev, devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Rafael J. Wysocki, Jia Hongtao, Eduardo Valentin, Viresh Kumar,
	Scott Wood

On Fri, Feb 26, 2016 at 5:31 PM, Li Yang <leoli-KZfg59tc24xl57MIdRCFDg@public.gmane.org> wrote:
> On Fri, Feb 26, 2016 at 5:16 PM, Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org> wrote:
>> On Friday 26 February 2016 17:07:09 Li Yang wrote:
>>>
>>> I don't have a perfect solution either.  But I think this is still
>>> better than making cpufreq not usable.  The cpufreq driver will print
>>> out an error message if thermal is not reachable.  Maybe this can
>>> relief the confusion a little bit?
>>
>> With my patch, the configuration will just force the cpufreq
>> driver to be a loadable module as well if thermal is a module,
>> so the dependency can be resolved by loading the thermal module first.
>
> It would be perfect if this it true.  But I tried with the following
> change, it just makes QORIQ_CPUFREQ non-selectable if THERMAL=m.
>
> diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig
> index dcb972a38fbc..ca05037dd565 100644
> --- a/drivers/cpufreq/Kconfig
> +++ b/drivers/cpufreq/Kconfig
> @@ -297,6 +297,7 @@ endif
>  config QORIQ_CPUFREQ
>         tristate "CPU frequency scaling driver for Freescale QorIQ SoCs"
>         depends on OF && COMMON_CLK && (PPC_E500MC || ARM)
> +       depends on !CPU_THERMAL || THERMAL=y
>         select CLK_QORIQ
>         help
>           This adds the CPUFreq driver support for Freescale QorIQ SoCs


I find we can achieve your desired result with the following change instead:

+       depends on (THERMAL=m && m) || THERMAL=y || THERMAL=n

Regards,
Leo
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH V3] cpufreq: qoriq: Register cooling device based on device tree
  2016-02-27  0:04                     ` Li Yang
@ 2016-02-27  0:08                       ` Scott Wood
       [not found]                         ` <1456531704.5360.53.camel-fOR+EgIDQEHk1uMJSBkQmQ@public.gmane.org>
  0 siblings, 1 reply; 17+ messages in thread
From: Scott Wood @ 2016-02-27  0:08 UTC (permalink / raw)
  To: Li Yang, Arnd Bergmann
  Cc: linuxppc-dev, devicetree, linux-pm@vger.kernel.org,
	Rafael J. Wysocki, Jia Hongtao, Eduardo Valentin, Viresh Kumar

On Fri, 2016-02-26 at 18:04 -0600, Li Yang wrote:
> On Fri, Feb 26, 2016 at 5:31 PM, Li Yang <leoli@freescale.com> wrote:
> > On Fri, Feb 26, 2016 at 5:16 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> > > On Friday 26 February 2016 17:07:09 Li Yang wrote:
> > > > 
> > > > I don't have a perfect solution either.  But I think this is still
> > > > better than making cpufreq not usable.  The cpufreq driver will print
> > > > out an error message if thermal is not reachable.  Maybe this can
> > > > relief the confusion a little bit?
> > > 
> > > With my patch, the configuration will just force the cpufreq
> > > driver to be a loadable module as well if thermal is a module,
> > > so the dependency can be resolved by loading the thermal module first.
> > 
> > It would be perfect if this it true.  But I tried with the following
> > change, it just makes QORIQ_CPUFREQ non-selectable if THERMAL=m.
> > 
> > diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig
> > index dcb972a38fbc..ca05037dd565 100644
> > --- a/drivers/cpufreq/Kconfig
> > +++ b/drivers/cpufreq/Kconfig
> > @@ -297,6 +297,7 @@ endif
> >  config QORIQ_CPUFREQ
> >         tristate "CPU frequency scaling driver for Freescale QorIQ SoCs"
> >         depends on OF && COMMON_CLK && (PPC_E500MC || ARM)
> > +       depends on !CPU_THERMAL || THERMAL=y
> >         select CLK_QORIQ
> >         help
> >           This adds the CPUFreq driver support for Freescale QorIQ SoCs
> 
> 
> I find we can achieve your desired result with the following change instead:
> 
> +       depends on (THERMAL=m && m) || THERMAL=y || THERMAL=n

"depends on THERMAL || !THERMAL" should also work.

-Scott


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

* Re: [PATCH V3] cpufreq: qoriq: Register cooling device based on device tree
       [not found]                         ` <1456531704.5360.53.camel-fOR+EgIDQEHk1uMJSBkQmQ@public.gmane.org>
@ 2016-02-27  0:41                           ` Li Yang
  2016-02-29 10:05                             ` Arnd Bergmann
  0 siblings, 1 reply; 17+ messages in thread
From: Li Yang @ 2016-02-27  0:41 UTC (permalink / raw)
  To: Scott Wood
  Cc: Arnd Bergmann, linuxppc-dev, devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Rafael J. Wysocki, Jia Hongtao, Eduardo Valentin, Viresh Kumar

On Fri, Feb 26, 2016 at 6:08 PM, Scott Wood <oss-fOR+EgIDQEHk1uMJSBkQmQ@public.gmane.org> wrote:
> On Fri, 2016-02-26 at 18:04 -0600, Li Yang wrote:
>> On Fri, Feb 26, 2016 at 5:31 PM, Li Yang <leoli-KZfg59tc24xl57MIdRCFDg@public.gmane.org> wrote:
>> > On Fri, Feb 26, 2016 at 5:16 PM, Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org> wrote:
>> > > On Friday 26 February 2016 17:07:09 Li Yang wrote:
>> > > >
>> > > > I don't have a perfect solution either.  But I think this is still
>> > > > better than making cpufreq not usable.  The cpufreq driver will print
>> > > > out an error message if thermal is not reachable.  Maybe this can
>> > > > relief the confusion a little bit?
>> > >
>> > > With my patch, the configuration will just force the cpufreq
>> > > driver to be a loadable module as well if thermal is a module,
>> > > so the dependency can be resolved by loading the thermal module first.
>> >
>> > It would be perfect if this it true.  But I tried with the following
>> > change, it just makes QORIQ_CPUFREQ non-selectable if THERMAL=m.
>> >
>> > diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig
>> > index dcb972a38fbc..ca05037dd565 100644
>> > --- a/drivers/cpufreq/Kconfig
>> > +++ b/drivers/cpufreq/Kconfig
>> > @@ -297,6 +297,7 @@ endif
>> >  config QORIQ_CPUFREQ
>> >         tristate "CPU frequency scaling driver for Freescale QorIQ SoCs"
>> >         depends on OF && COMMON_CLK && (PPC_E500MC || ARM)
>> > +       depends on !CPU_THERMAL || THERMAL=y
>> >         select CLK_QORIQ
>> >         help
>> >           This adds the CPUFreq driver support for Freescale QorIQ SoCs
>>
>>
>> I find we can achieve your desired result with the following change instead:
>>
>> +       depends on (THERMAL=m && m) || THERMAL=y || THERMAL=n
>
> "depends on THERMAL || !THERMAL" should also work.

Right.  And this is more simpler.

Regards,
Leo
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH V3] cpufreq: qoriq: Register cooling device based on device tree
  2016-02-27  0:41                           ` Li Yang
@ 2016-02-29 10:05                             ` Arnd Bergmann
  2016-02-29 14:33                               ` Rafael J. Wysocki
  0 siblings, 1 reply; 17+ messages in thread
From: Arnd Bergmann @ 2016-02-29 10:05 UTC (permalink / raw)
  To: Li Yang
  Cc: Scott Wood, linuxppc-dev, devicetree, linux-pm@vger.kernel.org,
	Rafael J. Wysocki, Jia Hongtao, Eduardo Valentin, Viresh Kumar

On Friday 26 February 2016 18:41:06 Li Yang wrote:
> >> >
> >> > It would be perfect if this it true.  But I tried with the following
> >> > change, it just makes QORIQ_CPUFREQ non-selectable if THERMAL=m.
> >> >
> >> > diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig
> >> > index dcb972a38fbc..ca05037dd565 100644
> >> > --- a/drivers/cpufreq/Kconfig
> >> > +++ b/drivers/cpufreq/Kconfig
> >> > @@ -297,6 +297,7 @@ endif
> >> >  config QORIQ_CPUFREQ
> >> >         tristate "CPU frequency scaling driver for Freescale QorIQ SoCs"
> >> >         depends on OF && COMMON_CLK && (PPC_E500MC || ARM)
> >> > +       depends on !CPU_THERMAL || THERMAL=y
> >> >         select CLK_QORIQ
> >> >         help
> >> >           This adds the CPUFreq driver support for Freescale QorIQ SoCs
> >>

Oops.

> >> I find we can achieve your desired result with the following change instead:
> >>
> >> +       depends on (THERMAL=m && m) || THERMAL=y || THERMAL=n
> >
> > "depends on THERMAL || !THERMAL" should also work.
> 
> Right.  And this is more simpler.


Note the check on !CPU_THERMAL rather than !THERMAL in my patch, that
part was correct. I think the line should be

	depends on !CPU_THERMAL || THERMAL

as some other drivers do. I must have copied the line
from ARM_MT8173_CPUFREQ, which is a 'bool' symbol, when
it should have been the same as ARM_BIG_LITTLE_CPUFREQ and
CPUFREQ_DT.

	Arnd

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

* Re: [PATCH V3] cpufreq: qoriq: Register cooling device based on device tree
  2016-02-29 10:05                             ` Arnd Bergmann
@ 2016-02-29 14:33                               ` Rafael J. Wysocki
  2016-02-29 14:39                                 ` Arnd Bergmann
  0 siblings, 1 reply; 17+ messages in thread
From: Rafael J. Wysocki @ 2016-02-29 14:33 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Li Yang, Scott Wood, linuxppc-dev, devicetree@vger.kernel.org,
	linux-pm@vger.kernel.org, Rafael J. Wysocki, Jia Hongtao,
	Eduardo Valentin, Viresh Kumar

On Mon, Feb 29, 2016 at 11:05 AM, Arnd Bergmann <arnd@arndb.de> wrote:
> On Friday 26 February 2016 18:41:06 Li Yang wrote:
>> >> >
>> >> > It would be perfect if this it true.  But I tried with the following
>> >> > change, it just makes QORIQ_CPUFREQ non-selectable if THERMAL=m.
>> >> >
>> >> > diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig
>> >> > index dcb972a38fbc..ca05037dd565 100644
>> >> > --- a/drivers/cpufreq/Kconfig
>> >> > +++ b/drivers/cpufreq/Kconfig
>> >> > @@ -297,6 +297,7 @@ endif
>> >> >  config QORIQ_CPUFREQ
>> >> >         tristate "CPU frequency scaling driver for Freescale QorIQ SoCs"
>> >> >         depends on OF && COMMON_CLK && (PPC_E500MC || ARM)
>> >> > +       depends on !CPU_THERMAL || THERMAL=y
>> >> >         select CLK_QORIQ
>> >> >         help
>> >> >           This adds the CPUFreq driver support for Freescale QorIQ SoCs
>> >>
>
> Oops.
>
>> >> I find we can achieve your desired result with the following change instead:
>> >>
>> >> +       depends on (THERMAL=m && m) || THERMAL=y || THERMAL=n
>> >
>> > "depends on THERMAL || !THERMAL" should also work.
>>
>> Right.  And this is more simpler.
>
>
> Note the check on !CPU_THERMAL rather than !THERMAL in my patch, that
> part was correct. I think the line should be
>
>         depends on !CPU_THERMAL || THERMAL
>
> as some other drivers do. I must have copied the line
> from ARM_MT8173_CPUFREQ, which is a 'bool' symbol, when
> it should have been the same as ARM_BIG_LITTLE_CPUFREQ and
> CPUFREQ_DT.

OK, so any chance to update the patch?

Thanks,
Rafael

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

* Re: [PATCH V3] cpufreq: qoriq: Register cooling device based on device tree
  2016-02-29 14:33                               ` Rafael J. Wysocki
@ 2016-02-29 14:39                                 ` Arnd Bergmann
  0 siblings, 0 replies; 17+ messages in thread
From: Arnd Bergmann @ 2016-02-29 14:39 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Li Yang, Scott Wood, linuxppc-dev, devicetree@vger.kernel.org,
	linux-pm@vger.kernel.org, Rafael J. Wysocki, Jia Hongtao,
	Eduardo Valentin, Viresh Kumar

On Monday 29 February 2016 15:33:37 Rafael J. Wysocki wrote:
> >
> > Note the check on !CPU_THERMAL rather than !THERMAL in my patch, that
> > part was correct. I think the line should be
> >
> >         depends on !CPU_THERMAL || THERMAL
> >
> > as some other drivers do. I must have copied the line
> > from ARM_MT8173_CPUFREQ, which is a 'bool' symbol, when
> > it should have been the same as ARM_BIG_LITTLE_CPUFREQ and
> > CPUFREQ_DT.
> 
> OK, so any chance to update the patch?
> 

I've committed the update locally now, and will follow up tomorrow
with a new patch, unless it causes another build-time regression.

I'll also send the respective update for the mediatek driver, making
that a tristate option.

	Arnd

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

end of thread, other threads:[~2016-02-29 14:39 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-26  9:21 [PATCH V3] cpufreq: qoriq: Register cooling device based on device tree Jia Hongtao
     [not found] ` <1448529671-48216-1-git-send-email-hongtao.jia-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2015-12-14 23:58   ` Rafael J. Wysocki
     [not found]     ` <1697588.dLcbZBRWO4-sKB8Sp2ER+y1GS7QM15AGw@public.gmane.org>
2015-12-18 22:32       ` Arnd Bergmann
2016-01-11 14:54         ` 答复: " Hongtao Jia
2016-01-11 17:34           ` Scott Wood
2016-01-11 21:13             ` Arnd Bergmann
2016-02-26 18:04         ` Li Yang
2016-02-26 20:20           ` Arnd Bergmann
2016-02-26 23:07             ` Li Yang
2016-02-26 23:16               ` Arnd Bergmann
2016-02-26 23:31                 ` Li Yang
     [not found]                   ` <CADRPPNSASmfxS=BWKvOxGKyCiqno9YvOuAfBaHwKL-Y=jQ2Dzw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-02-27  0:04                     ` Li Yang
2016-02-27  0:08                       ` Scott Wood
     [not found]                         ` <1456531704.5360.53.camel-fOR+EgIDQEHk1uMJSBkQmQ@public.gmane.org>
2016-02-27  0:41                           ` Li Yang
2016-02-29 10:05                             ` Arnd Bergmann
2016-02-29 14:33                               ` Rafael J. Wysocki
2016-02-29 14:39                                 ` Arnd Bergmann

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).