* [PATCH V2] cpufreq: qoriq: Register cooling device based on device tree
@ 2015-11-26 6:27 Jia Hongtao
[not found] ` <1448519249-11449-1-git-send-email-hongtao.jia-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2015-11-26 9:08 ` Viresh Kumar
0 siblings, 2 replies; 5+ messages in thread
From: Jia Hongtao @ 2015-11-26 6:27 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>
---
Changes for V2:
* Using ->ready callback for cpu cooling device registering.
drivers/cpufreq/qoriq-cpufreq.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/drivers/cpufreq/qoriq-cpufreq.c b/drivers/cpufreq/qoriq-cpufreq.c
index 4f53fa2..a39f868 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,30 @@ 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 (WARN_ON(!np))
+ return;
+
+ 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 +294,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] 5+ messages in thread
* Re: [PATCH V2] cpufreq: qoriq: Register cooling device based on device tree
[not found] ` <1448519249-11449-1-git-send-email-hongtao.jia-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
@ 2015-11-26 8:32 ` Denis Kirjanov
2015-11-26 8:46 ` Hongtao Jia
0 siblings, 1 reply; 5+ messages in thread
From: Denis Kirjanov @ 2015-11-26 8:32 UTC (permalink / raw)
To: Jia Hongtao
Cc: edubezval-Re5JQEeQqe8AvxtiuMwx3w,
viresh.kumar-QSEj5FYQhm4dnm+yROfE0A,
scottwood-KZfg59tc24xl57MIdRCFDg,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-pm-u79uwXL29TY76Z2rM5mHXA
On 11/26/15, Jia Hongtao <hongtao.jia-KZfg59tc24xl57MIdRCFDg@public.gmane.org> 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>
> ---
> Changes for V2:
> * Using ->ready callback for cpu cooling device registering.
>
> drivers/cpufreq/qoriq-cpufreq.c | 27 +++++++++++++++++++++++++++
> 1 file changed, 27 insertions(+)
>
> diff --git a/drivers/cpufreq/qoriq-cpufreq.c
> b/drivers/cpufreq/qoriq-cpufreq.c
> index 4f53fa2..a39f868 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,30 @@ 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 (WARN_ON(!np))
> + return;
I doubt that WARN_ON is necessary here. Do you know the exact case
where the np is 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 +294,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
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
--
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] 5+ messages in thread
* RE: [PATCH V2] cpufreq: qoriq: Register cooling device based on device tree
2015-11-26 8:32 ` Denis Kirjanov
@ 2015-11-26 8:46 ` Hongtao Jia
0 siblings, 0 replies; 5+ messages in thread
From: Hongtao Jia @ 2015-11-26 8:46 UTC (permalink / raw)
To: Denis Kirjanov
Cc: edubezval@gmail.com, viresh.kumar@linaro.org, Scott Wood,
devicetree@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
linux-pm@vger.kernel.org
> -----Original Message-----
> From: Denis Kirjanov [mailto:kda@linux-powerpc.org]
> Sent: Thursday, November 26, 2015 4:32 PM
> To: Jia Hongtao-B38951
> Cc: edubezval@gmail.com; viresh.kumar@linaro.org; Wood Scott-B07421;
> devicetree@vger.kernel.org; linuxppc-dev@lists.ozlabs.org; linux-
> pm@vger.kernel.org
> Subject: Re: [PATCH V2] cpufreq: qoriq: Register cooling device based on
> device tree
>
> On 11/26/15, Jia Hongtao <hongtao.jia@freescale.com> 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>
> > ---
> > Changes for V2:
> > * Using ->ready callback for cpu cooling device registering.
> >
> > drivers/cpufreq/qoriq-cpufreq.c | 27 +++++++++++++++++++++++++++
> > 1 file changed, 27 insertions(+)
> >
> > diff --git a/drivers/cpufreq/qoriq-cpufreq.c
> > b/drivers/cpufreq/qoriq-cpufreq.c index 4f53fa2..a39f868 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,30 @@ 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 (WARN_ON(!np))
> > + return;
> I doubt that WARN_ON is necessary here. Do you know the exact case where
> the np is NULL?
This seems not necessary as you said.
If no one else has the opposite opinion I will remove it.
Thanks.
> > +
> > + 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 +294,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
> >
> > _______________________________________________
> > Linuxppc-dev mailing list
> > Linuxppc-dev@lists.ozlabs.org
> > https://lists.ozlabs.org/listinfo/linuxppc-dev
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH V2] cpufreq: qoriq: Register cooling device based on device tree
2015-11-26 6:27 [PATCH V2] cpufreq: qoriq: Register cooling device based on device tree Jia Hongtao
[not found] ` <1448519249-11449-1-git-send-email-hongtao.jia-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
@ 2015-11-26 9:08 ` Viresh Kumar
2015-11-26 9:29 ` Hongtao Jia
1 sibling, 1 reply; 5+ messages in thread
From: Viresh Kumar @ 2015-11-26 9:08 UTC (permalink / raw)
To: Jia Hongtao; +Cc: edubezval, linux-pm, linuxppc-dev, devicetree, scottwood
On 26-11-15, 14:27, Jia Hongtao wrote:
> +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 (WARN_ON(!np))
> + return;
Drop this and add my:
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
--
viresh
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH V2] cpufreq: qoriq: Register cooling device based on device tree
2015-11-26 9:08 ` Viresh Kumar
@ 2015-11-26 9:29 ` Hongtao Jia
0 siblings, 0 replies; 5+ messages in thread
From: Hongtao Jia @ 2015-11-26 9:29 UTC (permalink / raw)
To: Viresh Kumar
Cc: edubezval@gmail.com, linux-pm@vger.kernel.org,
linuxppc-dev@lists.ozlabs.org, devicetree@vger.kernel.org,
Scott Wood
Thanks.
I just sent the new patch.
> -----Original Message-----
> From: Viresh Kumar [mailto:viresh.kumar@linaro.org]
> Sent: Thursday, November 26, 2015 5:08 PM
> To: Jia Hongtao-B38951
> Cc: edubezval@gmail.com; linux-pm@vger.kernel.org; linuxppc-
> dev@lists.ozlabs.org; devicetree@vger.kernel.org; Wood Scott-B07421
> Subject: Re: [PATCH V2] cpufreq: qoriq: Register cooling device based on
> device tree
>
> On 26-11-15, 14:27, Jia Hongtao wrote:
> > +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 (WARN_ON(!np))
> > + return;
>
> Drop this and add my:
>
> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
>
> --
> viresh
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-11-26 9:29 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-26 6:27 [PATCH V2] cpufreq: qoriq: Register cooling device based on device tree Jia Hongtao
[not found] ` <1448519249-11449-1-git-send-email-hongtao.jia-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2015-11-26 8:32 ` Denis Kirjanov
2015-11-26 8:46 ` Hongtao Jia
2015-11-26 9:08 ` Viresh Kumar
2015-11-26 9:29 ` Hongtao Jia
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox