All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 0/9] cpufreq: Add flag to auto-register as cooling device
@ 2019-01-29  4:55 ` Amit Kucheria
  0 siblings, 0 replies; 32+ messages in thread
From: Amit Kucheria @ 2019-01-29  4:55 UTC (permalink / raw)
  To: linux-kernel
  Cc: Rafael J. Wysocki, Daniel Lezcano, Eduardo Valentin,
	Matthias Brugger, Sudeep Holla, Viresh Kumar, Zhang Rui,
	moderated list:ARM/Mediatek SoC support,
	moderated list:ARM/Mediatek SoC support,
	open list:CPU FREQUENCY SCALING FRAMEWORK

Add a flag for cpufreq drivers to tell cpufreq core to auto-register
themselves as a thermal cooling device.

There series converts over all the drivers except arm_big_little.c.
Tested on SDM845 with the qcom-cpufreq-hw driver. Only compile-tested the
others.

Things needing fixing (but not a blocker for the series):
 - Look at how to detect that we're not in IKS mode in arm_big_little's
   .ready callback.

Changes since v4:
 - Added IS_ENABLED guards in cpufreq.c
 - Changed flag name to CPUFREQ_IS_COOLING_DEV
 - Collected various review tags

Changes since v3:
 - Got rid of wrapper function to register/unregister cooling devices.
   Directly call the function in cpufreq.c

Changes since v2:
 - Get rid of #ifdef'ery and let the pointer exist in all cases
 - Get rid of (!CPU_THERMAL || THERMAL) dependency in all cpufreq drivers'
   Kconfig

Changes since v1:
- Fix compilation failures with allmodconfig
- Get rid of #ifdef in cpufreq.c
- Removed miscellaneous patches and sent them separately
- Merged patches 1 and 2 from v1

Amit Kucheria (9):
  thermal: cpu_cooling: Require thermal core to be compiled in
  cpufreq: Auto-register the driver as a thermal cooling device if asked
  cpufreq: qcom-hw: Register as a cpufreq cooling device
  cpufreq: imx6q: Use auto-registration of thermal cooling device
  cpufreq: cpufreq-dt: Use auto-registration of thermal cooling device
  cpufreq: mediatek: Use auto-registration of thermal cooling device
  cpufreq: qoriq: Use auto-registration of thermal cooling device
  cpufreq: scmi: Use auto-registration of thermal cooling device
  cpufreq: scpi: Use auto-registration of thermal cooling device

 drivers/cpufreq/Kconfig            |  3 ---
 drivers/cpufreq/Kconfig.arm        |  5 -----
 drivers/cpufreq/cpufreq-dt.c       | 14 ++------------
 drivers/cpufreq/cpufreq.c          | 13 +++++++++++++
 drivers/cpufreq/imx6q-cpufreq.c    | 24 ++----------------------
 drivers/cpufreq/mediatek-cpufreq.c | 14 ++------------
 drivers/cpufreq/qcom-cpufreq-hw.c  |  3 ++-
 drivers/cpufreq/qoriq-cpufreq.c    | 15 ++-------------
 drivers/cpufreq/scmi-cpufreq.c     | 14 ++------------
 drivers/cpufreq/scpi-cpufreq.c     | 14 ++------------
 drivers/thermal/Kconfig            |  1 +
 include/linux/cpufreq.h            |  9 +++++++++
 12 files changed, 37 insertions(+), 92 deletions(-)

-- 
2.17.1


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

* [PATCH v5 0/9] cpufreq: Add flag to auto-register as cooling device
@ 2019-01-29  4:55 ` Amit Kucheria
  0 siblings, 0 replies; 32+ messages in thread
From: Amit Kucheria @ 2019-01-29  4:55 UTC (permalink / raw)
  To: linux-kernel
  Cc: open list:CPU FREQUENCY SCALING FRAMEWORK, Viresh Kumar,
	Daniel Lezcano, Rafael J. Wysocki, Eduardo Valentin,
	moderated list:ARM/Mediatek SoC support, Sudeep Holla,
	Matthias Brugger, Zhang Rui,
	moderated list:ARM/Mediatek SoC support

Add a flag for cpufreq drivers to tell cpufreq core to auto-register
themselves as a thermal cooling device.

There series converts over all the drivers except arm_big_little.c.
Tested on SDM845 with the qcom-cpufreq-hw driver. Only compile-tested the
others.

Things needing fixing (but not a blocker for the series):
 - Look at how to detect that we're not in IKS mode in arm_big_little's
   .ready callback.

Changes since v4:
 - Added IS_ENABLED guards in cpufreq.c
 - Changed flag name to CPUFREQ_IS_COOLING_DEV
 - Collected various review tags

Changes since v3:
 - Got rid of wrapper function to register/unregister cooling devices.
   Directly call the function in cpufreq.c

Changes since v2:
 - Get rid of #ifdef'ery and let the pointer exist in all cases
 - Get rid of (!CPU_THERMAL || THERMAL) dependency in all cpufreq drivers'
   Kconfig

Changes since v1:
- Fix compilation failures with allmodconfig
- Get rid of #ifdef in cpufreq.c
- Removed miscellaneous patches and sent them separately
- Merged patches 1 and 2 from v1

Amit Kucheria (9):
  thermal: cpu_cooling: Require thermal core to be compiled in
  cpufreq: Auto-register the driver as a thermal cooling device if asked
  cpufreq: qcom-hw: Register as a cpufreq cooling device
  cpufreq: imx6q: Use auto-registration of thermal cooling device
  cpufreq: cpufreq-dt: Use auto-registration of thermal cooling device
  cpufreq: mediatek: Use auto-registration of thermal cooling device
  cpufreq: qoriq: Use auto-registration of thermal cooling device
  cpufreq: scmi: Use auto-registration of thermal cooling device
  cpufreq: scpi: Use auto-registration of thermal cooling device

 drivers/cpufreq/Kconfig            |  3 ---
 drivers/cpufreq/Kconfig.arm        |  5 -----
 drivers/cpufreq/cpufreq-dt.c       | 14 ++------------
 drivers/cpufreq/cpufreq.c          | 13 +++++++++++++
 drivers/cpufreq/imx6q-cpufreq.c    | 24 ++----------------------
 drivers/cpufreq/mediatek-cpufreq.c | 14 ++------------
 drivers/cpufreq/qcom-cpufreq-hw.c  |  3 ++-
 drivers/cpufreq/qoriq-cpufreq.c    | 15 ++-------------
 drivers/cpufreq/scmi-cpufreq.c     | 14 ++------------
 drivers/cpufreq/scpi-cpufreq.c     | 14 ++------------
 drivers/thermal/Kconfig            |  1 +
 include/linux/cpufreq.h            |  9 +++++++++
 12 files changed, 37 insertions(+), 92 deletions(-)

-- 
2.17.1

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

* [PATCH v5 0/9] cpufreq: Add flag to auto-register as cooling device
@ 2019-01-29  4:55 ` Amit Kucheria
  0 siblings, 0 replies; 32+ messages in thread
From: Amit Kucheria @ 2019-01-29  4:55 UTC (permalink / raw)
  To: linux-kernel
  Cc: open list:CPU FREQUENCY SCALING FRAMEWORK, Viresh Kumar,
	Daniel Lezcano, Rafael J. Wysocki, Eduardo Valentin,
	moderated list:ARM/Mediatek SoC support, Sudeep Holla,
	Matthias Brugger, Zhang Rui,
	moderated list:ARM/Mediatek SoC support

Add a flag for cpufreq drivers to tell cpufreq core to auto-register
themselves as a thermal cooling device.

There series converts over all the drivers except arm_big_little.c.
Tested on SDM845 with the qcom-cpufreq-hw driver. Only compile-tested the
others.

Things needing fixing (but not a blocker for the series):
 - Look at how to detect that we're not in IKS mode in arm_big_little's
   .ready callback.

Changes since v4:
 - Added IS_ENABLED guards in cpufreq.c
 - Changed flag name to CPUFREQ_IS_COOLING_DEV
 - Collected various review tags

Changes since v3:
 - Got rid of wrapper function to register/unregister cooling devices.
   Directly call the function in cpufreq.c

Changes since v2:
 - Get rid of #ifdef'ery and let the pointer exist in all cases
 - Get rid of (!CPU_THERMAL || THERMAL) dependency in all cpufreq drivers'
   Kconfig

Changes since v1:
- Fix compilation failures with allmodconfig
- Get rid of #ifdef in cpufreq.c
- Removed miscellaneous patches and sent them separately
- Merged patches 1 and 2 from v1

Amit Kucheria (9):
  thermal: cpu_cooling: Require thermal core to be compiled in
  cpufreq: Auto-register the driver as a thermal cooling device if asked
  cpufreq: qcom-hw: Register as a cpufreq cooling device
  cpufreq: imx6q: Use auto-registration of thermal cooling device
  cpufreq: cpufreq-dt: Use auto-registration of thermal cooling device
  cpufreq: mediatek: Use auto-registration of thermal cooling device
  cpufreq: qoriq: Use auto-registration of thermal cooling device
  cpufreq: scmi: Use auto-registration of thermal cooling device
  cpufreq: scpi: Use auto-registration of thermal cooling device

 drivers/cpufreq/Kconfig            |  3 ---
 drivers/cpufreq/Kconfig.arm        |  5 -----
 drivers/cpufreq/cpufreq-dt.c       | 14 ++------------
 drivers/cpufreq/cpufreq.c          | 13 +++++++++++++
 drivers/cpufreq/imx6q-cpufreq.c    | 24 ++----------------------
 drivers/cpufreq/mediatek-cpufreq.c | 14 ++------------
 drivers/cpufreq/qcom-cpufreq-hw.c  |  3 ++-
 drivers/cpufreq/qoriq-cpufreq.c    | 15 ++-------------
 drivers/cpufreq/scmi-cpufreq.c     | 14 ++------------
 drivers/cpufreq/scpi-cpufreq.c     | 14 ++------------
 drivers/thermal/Kconfig            |  1 +
 include/linux/cpufreq.h            |  9 +++++++++
 12 files changed, 37 insertions(+), 92 deletions(-)

-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v5 1/9] thermal: cpu_cooling: Require thermal core to be compiled in
  2019-01-29  4:55 ` Amit Kucheria
  (?)
  (?)
@ 2019-01-29  4:55 ` Amit Kucheria
  2019-01-30 23:53   ` Rafael J. Wysocki
  -1 siblings, 1 reply; 32+ messages in thread
From: Amit Kucheria @ 2019-01-29  4:55 UTC (permalink / raw)
  To: linux-kernel
  Cc: Rafael J. Wysocki, Viresh Kumar, Zhang Rui, Eduardo Valentin,
	Daniel Lezcano, Sudeep Holla, Taniya Das, Anson Huang, linux-pm

The CPU cooling driver (cpu_cooling.c) allows the platform's cpufreq
driver to register as a cooling device and cool down the platform by
throttling the CPU frequency. In order to be able to auto-register a
cpufreq driver as a cooling device from the cpufreq core, we need access
to code inside cpu_cooling.c which, in turn, accesses code inside
thermal core.

CPU_FREQ is a bool while THERMAL is tristate.  In some configurations
(e.g. allmodconfig), CONFIG_THERMAL ends up as a module while
CONFIG_CPU_FREQ is compiled in. This leads to following error:

drivers/cpufreq/cpufreq.o: In function `cpufreq_offline':
cpufreq.c:(.text+0x407c): undefined reference to `cpufreq_cooling_unregister'
drivers/cpufreq/cpufreq.o: In function `cpufreq_online':
cpufreq.c:(.text+0x70c0): undefined reference to `of_cpufreq_cooling_register'

Given that platforms using CPU_THERMAL usually want it compiled-in so it
is available early in boot, make CPU_THERMAL depend on THERMAL being
compiled-in instead of allowing it to be a module.

As a result of this change, get rid of the ugly (!CPU_THERMAL ||
THERMAL) dependency in all cpufreq drivers using CPU_THERMAL.

Suggested-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/Kconfig     | 3 ---
 drivers/cpufreq/Kconfig.arm | 5 -----
 drivers/thermal/Kconfig     | 1 +
 3 files changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig
index 608af20a3494..b22e6bba71f1 100644
--- a/drivers/cpufreq/Kconfig
+++ b/drivers/cpufreq/Kconfig
@@ -207,8 +207,6 @@ comment "CPU frequency scaling drivers"
 config CPUFREQ_DT
 	tristate "Generic DT based cpufreq driver"
 	depends on HAVE_CLK && OF
-	# if CPU_THERMAL is on and THERMAL=m, CPUFREQ_DT cannot be =y:
-	depends on !CPU_THERMAL || THERMAL
 	select CPUFREQ_DT_PLATDEV
 	select PM_OPP
 	help
@@ -327,7 +325,6 @@ endif
 config QORIQ_CPUFREQ
 	tristate "CPU frequency scaling driver for Freescale QorIQ SoCs"
 	depends on OF && COMMON_CLK && (PPC_E500MC || ARM || ARM64)
-	depends on !CPU_THERMAL || THERMAL
 	select CLK_QORIQ
 	help
 	  This adds the CPUFreq driver support for Freescale QorIQ SoCs
diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm
index 688f10227793..ca8567c3152c 100644
--- a/drivers/cpufreq/Kconfig.arm
+++ b/drivers/cpufreq/Kconfig.arm
@@ -29,8 +29,6 @@ config ARM_ARMADA_37XX_CPUFREQ
 config ARM_BIG_LITTLE_CPUFREQ
 	tristate "Generic ARM big LITTLE CPUfreq driver"
 	depends on ARM_CPU_TOPOLOGY && 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.
@@ -38,7 +36,6 @@ config ARM_BIG_LITTLE_CPUFREQ
 config ARM_SCPI_CPUFREQ
 	tristate "SCPI based CPUfreq driver"
 	depends on ARM_SCPI_PROTOCOL && COMMON_CLK_SCPI
-	depends on !CPU_THERMAL || THERMAL
 	help
 	  This adds the CPUfreq driver support for ARM platforms using SCPI
 	  protocol for CPU power management.
@@ -93,7 +90,6 @@ config ARM_KIRKWOOD_CPUFREQ
 config ARM_MEDIATEK_CPUFREQ
 	tristate "CPU Frequency scaling support for MediaTek SoCs"
 	depends on ARCH_MEDIATEK && REGULATOR
-	depends on !CPU_THERMAL || THERMAL
 	select PM_OPP
 	help
 	  This adds the CPUFreq driver support for MediaTek SoCs.
@@ -233,7 +229,6 @@ config ARM_SA1110_CPUFREQ
 config ARM_SCMI_CPUFREQ
 	tristate "SCMI based CPUfreq driver"
 	depends on ARM_SCMI_PROTOCOL || COMPILE_TEST
-	depends on !CPU_THERMAL || THERMAL
 	select PM_OPP
 	help
 	  This adds the CPUfreq driver support for ARM platforms using SCMI
diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index 30323426902e..58bb7d72dc2b 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -152,6 +152,7 @@ config CPU_THERMAL
 	bool "generic cpu cooling support"
 	depends on CPU_FREQ
 	depends on THERMAL_OF
+	depends on THERMAL=y
 	help
 	  This implements the generic cpu cooling mechanism through frequency
 	  reduction. An ACPI version of this already exists
-- 
2.17.1


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

* [PATCH v5 2/9] cpufreq: Auto-register the driver as a thermal cooling device if asked
  2019-01-29  4:55 ` Amit Kucheria
                   ` (2 preceding siblings ...)
  (?)
@ 2019-01-29  4:55 ` Amit Kucheria
  2019-01-29  5:36   ` Viresh Kumar
  -1 siblings, 1 reply; 32+ messages in thread
From: Amit Kucheria @ 2019-01-29  4:55 UTC (permalink / raw)
  To: linux-kernel; +Cc: Rafael J. Wysocki, Viresh Kumar, Sudeep Holla, linux-pm

All cpufreq drivers do similar things to register as a cooling device.
Provide a cpufreq driver flag so drivers can just ask the cpufreq core
to register the cooling device on their behalf. This allows us to get
rid of duplicated code in the drivers.

In order to allow this, we add a struct thermal_cooling_device pointer
to struct cpufreq_policy so that drivers don't need to store it in a
private data structure.

Suggested-by: Stephen Boyd <swboyd@chromium.org>
Suggested-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
Tested-by: Matthias Kaehlcke <mka@chromium.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/cpufreq.c | 13 +++++++++++++
 include/linux/cpufreq.h   |  9 +++++++++
 2 files changed, 22 insertions(+)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index e35a886e00bc..0f9b50d3ee91 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -19,6 +19,7 @@
 
 #include <linux/cpu.h>
 #include <linux/cpufreq.h>
+#include <linux/cpu_cooling.h>
 #include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/init.h>
@@ -1318,6 +1319,11 @@ static int cpufreq_online(unsigned int cpu)
 	if (cpufreq_driver->ready)
 		cpufreq_driver->ready(policy);
 
+#if IS_ENABLED(CONFIG_CPU_THERMAL)
+	if (cpufreq_driver->flags & CPUFREQ_IS_COOLING_DEV)
+		policy->cdev = of_cpufreq_cooling_register(policy);
+#endif
+
 	pr_debug("initialization complete\n");
 
 	return 0;
@@ -1405,6 +1411,13 @@ static int cpufreq_offline(unsigned int cpu)
 		goto unlock;
 	}
 
+#if IS_ENABLED(CONFIG_CPU_THERMAL)
+	if (cpufreq_driver->flags & CPUFREQ_IS_COOLING_DEV) {
+		cpufreq_cooling_unregister(policy->cdev);
+		policy->cdev = NULL;
+	}
+#endif
+
 	if (cpufreq_driver->stop_cpu)
 		cpufreq_driver->stop_cpu(policy);
 
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index bd7fbd6a4478..6078eb07a7e4 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -151,6 +151,9 @@ struct cpufreq_policy {
 
 	/* For cpufreq driver's internal use */
 	void			*driver_data;
+
+	/* Pointer to the cooling device if used for thermal mitigation */
+	struct thermal_cooling_device *cdev;
 };
 
 /* Only for ACPI */
@@ -386,6 +389,12 @@ struct cpufreq_driver {
  */
 #define CPUFREQ_NO_AUTO_DYNAMIC_SWITCHING	BIT(6)
 
+/*
+ * Set by drivers that want the core to automatically register the cpufreq
+ * driver as a thermal cooling device.
+ */
+#define CPUFREQ_IS_COOLING_DEV			BIT(7)
+
 int cpufreq_register_driver(struct cpufreq_driver *driver_data);
 int cpufreq_unregister_driver(struct cpufreq_driver *driver_data);
 
-- 
2.17.1


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

* [PATCH v5 3/9] cpufreq: qcom-hw: Register as a cpufreq cooling device
  2019-01-29  4:55 ` Amit Kucheria
                   ` (3 preceding siblings ...)
  (?)
@ 2019-01-29  4:55 ` Amit Kucheria
  -1 siblings, 0 replies; 32+ messages in thread
From: Amit Kucheria @ 2019-01-29  4:55 UTC (permalink / raw)
  To: linux-kernel
  Cc: Rafael J. Wysocki, Viresh Kumar, Stephen Boyd, Daniel Lezcano,
	Taniya Das, linux-pm

Add the CPUFREQ_IS_COOLING_DEV flag to allow the cpufreq core to
auto-register the driver as a cooling device.

Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
Tested-by: Matthias Kaehlcke <mka@chromium.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/cpufreq/qcom-cpufreq-hw.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c
index d83939a1b3d4..c88b51304d89 100644
--- a/drivers/cpufreq/qcom-cpufreq-hw.c
+++ b/drivers/cpufreq/qcom-cpufreq-hw.c
@@ -231,7 +231,8 @@ static struct freq_attr *qcom_cpufreq_hw_attr[] = {
 
 static struct cpufreq_driver cpufreq_qcom_hw_driver = {
 	.flags		= CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK |
-			  CPUFREQ_HAVE_GOVERNOR_PER_POLICY,
+			  CPUFREQ_HAVE_GOVERNOR_PER_POLICY |
+			  CPUFREQ_IS_COOLING_DEV,
 	.verify		= cpufreq_generic_frequency_table_verify,
 	.target_index	= qcom_cpufreq_hw_target_index,
 	.get		= qcom_cpufreq_hw_get,
-- 
2.17.1


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

* [PATCH v5 4/9] cpufreq: imx6q: Use auto-registration of thermal cooling device
  2019-01-29  4:55 ` Amit Kucheria
                   ` (4 preceding siblings ...)
  (?)
@ 2019-01-29  4:55 ` Amit Kucheria
  -1 siblings, 0 replies; 32+ messages in thread
From: Amit Kucheria @ 2019-01-29  4:55 UTC (permalink / raw)
  To: linux-kernel
  Cc: Rafael J. Wysocki, Viresh Kumar, Anson Huang, Bastian Stender,
	Fabio Estevam, linux-pm

Use the CPUFREQ_IS_COOLING_DEV flag to allow cpufreq core to
automatically register as a thermal cooling device.

This allows removal of boiler plate code from the driver.

Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/cpufreq/imx6q-cpufreq.c | 24 ++----------------------
 1 file changed, 2 insertions(+), 22 deletions(-)

diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c
index 9fedf627e000..ca955713e070 100644
--- a/drivers/cpufreq/imx6q-cpufreq.c
+++ b/drivers/cpufreq/imx6q-cpufreq.c
@@ -9,7 +9,6 @@
 #include <linux/clk.h>
 #include <linux/cpu.h>
 #include <linux/cpufreq.h>
-#include <linux/cpu_cooling.h>
 #include <linux/err.h>
 #include <linux/module.h>
 #include <linux/nvmem-consumer.h>
@@ -52,7 +51,6 @@ static struct clk_bulk_data clks[] = {
 };
 
 static struct device *cpu_dev;
-static struct thermal_cooling_device *cdev;
 static bool free_opp;
 static struct cpufreq_frequency_table *freq_table;
 static unsigned int max_freq;
@@ -193,16 +191,6 @@ static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index)
 	return 0;
 }
 
-static void imx6q_cpufreq_ready(struct cpufreq_policy *policy)
-{
-	cdev = of_cpufreq_cooling_register(policy);
-
-	if (!cdev)
-		dev_err(cpu_dev,
-			"running cpufreq without cooling device: %ld\n",
-			PTR_ERR(cdev));
-}
-
 static int imx6q_cpufreq_init(struct cpufreq_policy *policy)
 {
 	int ret;
@@ -214,22 +202,14 @@ static int imx6q_cpufreq_init(struct cpufreq_policy *policy)
 	return ret;
 }
 
-static int imx6q_cpufreq_exit(struct cpufreq_policy *policy)
-{
-	cpufreq_cooling_unregister(cdev);
-
-	return 0;
-}
-
 static struct cpufreq_driver imx6q_cpufreq_driver = {
-	.flags = CPUFREQ_NEED_INITIAL_FREQ_CHECK,
+	.flags = CPUFREQ_NEED_INITIAL_FREQ_CHECK |
+		 CPUFREQ_IS_COOLING_DEV,
 	.verify = cpufreq_generic_frequency_table_verify,
 	.target_index = imx6q_set_target,
 	.get = cpufreq_generic_get,
 	.init = imx6q_cpufreq_init,
-	.exit = imx6q_cpufreq_exit,
 	.name = "imx6q-cpufreq",
-	.ready = imx6q_cpufreq_ready,
 	.attr = cpufreq_generic_attr,
 	.suspend = cpufreq_generic_suspend,
 };
-- 
2.17.1


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

* [PATCH v5 5/9] cpufreq: cpufreq-dt: Use auto-registration of thermal cooling device
  2019-01-29  4:55 ` Amit Kucheria
                   ` (5 preceding siblings ...)
  (?)
@ 2019-01-29  4:55 ` Amit Kucheria
  -1 siblings, 0 replies; 32+ messages in thread
From: Amit Kucheria @ 2019-01-29  4:55 UTC (permalink / raw)
  To: linux-kernel; +Cc: Rafael J. Wysocki, Viresh Kumar, Daniel Lezcano, linux-pm

Use the CPUFREQ_IS_COOLING_DEV flag to allow cpufreq core to
automatically register as a thermal cooling device.

This allows removal of boiler plate code from the driver.

Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/cpufreq/cpufreq-dt.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c
index e58bfcb1169e..7ba392911cd0 100644
--- a/drivers/cpufreq/cpufreq-dt.c
+++ b/drivers/cpufreq/cpufreq-dt.c
@@ -13,7 +13,6 @@
 
 #include <linux/clk.h>
 #include <linux/cpu.h>
-#include <linux/cpu_cooling.h>
 #include <linux/cpufreq.h>
 #include <linux/cpumask.h>
 #include <linux/err.h>
@@ -30,7 +29,6 @@
 struct private_data {
 	struct opp_table *opp_table;
 	struct device *cpu_dev;
-	struct thermal_cooling_device *cdev;
 	const char *reg_name;
 	bool have_static_opps;
 };
@@ -301,7 +299,6 @@ static int cpufreq_exit(struct cpufreq_policy *policy)
 {
 	struct private_data *priv = policy->driver_data;
 
-	cpufreq_cooling_unregister(priv->cdev);
 	dev_pm_opp_free_cpufreq_table(priv->cpu_dev, &policy->freq_table);
 	if (priv->have_static_opps)
 		dev_pm_opp_of_cpumask_remove_table(policy->related_cpus);
@@ -314,21 +311,14 @@ static int cpufreq_exit(struct cpufreq_policy *policy)
 	return 0;
 }
 
-static void cpufreq_ready(struct cpufreq_policy *policy)
-{
-	struct private_data *priv = policy->driver_data;
-
-	priv->cdev = of_cpufreq_cooling_register(policy);
-}
-
 static struct cpufreq_driver dt_cpufreq_driver = {
-	.flags = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK,
+	.flags = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK |
+		 CPUFREQ_IS_COOLING_DEV,
 	.verify = cpufreq_generic_frequency_table_verify,
 	.target_index = set_target,
 	.get = cpufreq_generic_get,
 	.init = cpufreq_init,
 	.exit = cpufreq_exit,
-	.ready = cpufreq_ready,
 	.name = "cpufreq-dt",
 	.attr = cpufreq_dt_attr,
 	.suspend = cpufreq_generic_suspend,
-- 
2.17.1


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

* [PATCH v5 6/9] cpufreq: mediatek: Use auto-registration of thermal cooling device
  2019-01-29  4:55 ` Amit Kucheria
@ 2019-01-29  4:55   ` Amit Kucheria
  -1 siblings, 0 replies; 32+ messages in thread
From: Amit Kucheria @ 2019-01-29  4:55 UTC (permalink / raw)
  To: linux-kernel
  Cc: Rafael J. Wysocki, Viresh Kumar, Matthias Brugger,
	Daniel Lezcano, Sean Wang, linux-pm, linux-arm-kernel,
	linux-mediatek

Use the CPUFREQ_IS_COOLING_DEV flag to allow cpufreq core to
automatically register as a thermal cooling device.

This allows removal of boiler plate code from the driver.

Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/cpufreq/mediatek-cpufreq.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/cpufreq/mediatek-cpufreq.c b/drivers/cpufreq/mediatek-cpufreq.c
index eb8920d39818..4229fcc31310 100644
--- a/drivers/cpufreq/mediatek-cpufreq.c
+++ b/drivers/cpufreq/mediatek-cpufreq.c
@@ -14,7 +14,6 @@
 
 #include <linux/clk.h>
 #include <linux/cpu.h>
-#include <linux/cpu_cooling.h>
 #include <linux/cpufreq.h>
 #include <linux/cpumask.h>
 #include <linux/module.h>
@@ -48,7 +47,6 @@ struct mtk_cpu_dvfs_info {
 	struct regulator *sram_reg;
 	struct clk *cpu_clk;
 	struct clk *inter_clk;
-	struct thermal_cooling_device *cdev;
 	struct list_head list_head;
 	int intermediate_voltage;
 	bool need_voltage_tracking;
@@ -307,13 +305,6 @@ static int mtk_cpufreq_set_target(struct cpufreq_policy *policy,
 
 #define DYNAMIC_POWER "dynamic-power-coefficient"
 
-static void mtk_cpufreq_ready(struct cpufreq_policy *policy)
-{
-	struct mtk_cpu_dvfs_info *info = policy->driver_data;
-
-	info->cdev = of_cpufreq_cooling_register(policy);
-}
-
 static int mtk_cpu_dvfs_info_init(struct mtk_cpu_dvfs_info *info, int cpu)
 {
 	struct device *cpu_dev;
@@ -472,7 +463,6 @@ static int mtk_cpufreq_exit(struct cpufreq_policy *policy)
 {
 	struct mtk_cpu_dvfs_info *info = policy->driver_data;
 
-	cpufreq_cooling_unregister(info->cdev);
 	dev_pm_opp_free_cpufreq_table(info->cpu_dev, &policy->freq_table);
 
 	return 0;
@@ -480,13 +470,13 @@ static int mtk_cpufreq_exit(struct cpufreq_policy *policy)
 
 static struct cpufreq_driver mtk_cpufreq_driver = {
 	.flags = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK |
-		 CPUFREQ_HAVE_GOVERNOR_PER_POLICY,
+		 CPUFREQ_HAVE_GOVERNOR_PER_POLICY |
+		 CPUFREQ_IS_COOLING_DEV,
 	.verify = cpufreq_generic_frequency_table_verify,
 	.target_index = mtk_cpufreq_set_target,
 	.get = cpufreq_generic_get,
 	.init = mtk_cpufreq_init,
 	.exit = mtk_cpufreq_exit,
-	.ready = mtk_cpufreq_ready,
 	.name = "mtk-cpufreq",
 	.attr = cpufreq_generic_attr,
 };
-- 
2.17.1


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

* [PATCH v5 6/9] cpufreq: mediatek: Use auto-registration of thermal cooling device
@ 2019-01-29  4:55   ` Amit Kucheria
  0 siblings, 0 replies; 32+ messages in thread
From: Amit Kucheria @ 2019-01-29  4:55 UTC (permalink / raw)
  To: linux-kernel
  Cc: Sean Wang, linux-pm, Viresh Kumar, Daniel Lezcano,
	Rafael J. Wysocki, linux-mediatek, Matthias Brugger,
	linux-arm-kernel

Use the CPUFREQ_IS_COOLING_DEV flag to allow cpufreq core to
automatically register as a thermal cooling device.

This allows removal of boiler plate code from the driver.

Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/cpufreq/mediatek-cpufreq.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/cpufreq/mediatek-cpufreq.c b/drivers/cpufreq/mediatek-cpufreq.c
index eb8920d39818..4229fcc31310 100644
--- a/drivers/cpufreq/mediatek-cpufreq.c
+++ b/drivers/cpufreq/mediatek-cpufreq.c
@@ -14,7 +14,6 @@
 
 #include <linux/clk.h>
 #include <linux/cpu.h>
-#include <linux/cpu_cooling.h>
 #include <linux/cpufreq.h>
 #include <linux/cpumask.h>
 #include <linux/module.h>
@@ -48,7 +47,6 @@ struct mtk_cpu_dvfs_info {
 	struct regulator *sram_reg;
 	struct clk *cpu_clk;
 	struct clk *inter_clk;
-	struct thermal_cooling_device *cdev;
 	struct list_head list_head;
 	int intermediate_voltage;
 	bool need_voltage_tracking;
@@ -307,13 +305,6 @@ static int mtk_cpufreq_set_target(struct cpufreq_policy *policy,
 
 #define DYNAMIC_POWER "dynamic-power-coefficient"
 
-static void mtk_cpufreq_ready(struct cpufreq_policy *policy)
-{
-	struct mtk_cpu_dvfs_info *info = policy->driver_data;
-
-	info->cdev = of_cpufreq_cooling_register(policy);
-}
-
 static int mtk_cpu_dvfs_info_init(struct mtk_cpu_dvfs_info *info, int cpu)
 {
 	struct device *cpu_dev;
@@ -472,7 +463,6 @@ static int mtk_cpufreq_exit(struct cpufreq_policy *policy)
 {
 	struct mtk_cpu_dvfs_info *info = policy->driver_data;
 
-	cpufreq_cooling_unregister(info->cdev);
 	dev_pm_opp_free_cpufreq_table(info->cpu_dev, &policy->freq_table);
 
 	return 0;
@@ -480,13 +470,13 @@ static int mtk_cpufreq_exit(struct cpufreq_policy *policy)
 
 static struct cpufreq_driver mtk_cpufreq_driver = {
 	.flags = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK |
-		 CPUFREQ_HAVE_GOVERNOR_PER_POLICY,
+		 CPUFREQ_HAVE_GOVERNOR_PER_POLICY |
+		 CPUFREQ_IS_COOLING_DEV,
 	.verify = cpufreq_generic_frequency_table_verify,
 	.target_index = mtk_cpufreq_set_target,
 	.get = cpufreq_generic_get,
 	.init = mtk_cpufreq_init,
 	.exit = mtk_cpufreq_exit,
-	.ready = mtk_cpufreq_ready,
 	.name = "mtk-cpufreq",
 	.attr = cpufreq_generic_attr,
 };
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v5 7/9] cpufreq: qoriq: Use auto-registration of thermal cooling device
  2019-01-29  4:55 ` Amit Kucheria
                   ` (7 preceding siblings ...)
  (?)
@ 2019-01-29  4:55 ` Amit Kucheria
  -1 siblings, 0 replies; 32+ messages in thread
From: Amit Kucheria @ 2019-01-29  4:55 UTC (permalink / raw)
  To: linux-kernel
  Cc: Rafael J. Wysocki, Viresh Kumar, Daniel Lezcano, Markus Elfring,
	linux-pm

Use the CPUFREQ_IS_COOLING_DEV flag to allow cpufreq core to
automatically register as a thermal cooling device.

This allows removal of boiler plate code from the driver.

Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/cpufreq/qoriq-cpufreq.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/cpufreq/qoriq-cpufreq.c b/drivers/cpufreq/qoriq-cpufreq.c
index 3d773f64b4df..4295e5476264 100644
--- a/drivers/cpufreq/qoriq-cpufreq.c
+++ b/drivers/cpufreq/qoriq-cpufreq.c
@@ -13,7 +13,6 @@
 #include <linux/clk.h>
 #include <linux/clk-provider.h>
 #include <linux/cpufreq.h>
-#include <linux/cpu_cooling.h>
 #include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
@@ -31,7 +30,6 @@
 struct cpu_data {
 	struct clk **pclk;
 	struct cpufreq_frequency_table *table;
-	struct thermal_cooling_device *cdev;
 };
 
 /*
@@ -239,7 +237,6 @@ static int qoriq_cpufreq_cpu_exit(struct cpufreq_policy *policy)
 {
 	struct cpu_data *data = policy->driver_data;
 
-	cpufreq_cooling_unregister(data->cdev);
 	kfree(data->pclk);
 	kfree(data->table);
 	kfree(data);
@@ -258,23 +255,15 @@ 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;
-
-	cpud->cdev = of_cpufreq_cooling_register(policy);
-}
-
 static struct cpufreq_driver qoriq_cpufreq_driver = {
 	.name		= "qoriq_cpufreq",
-	.flags		= CPUFREQ_CONST_LOOPS,
+	.flags		= CPUFREQ_CONST_LOOPS |
+			  CPUFREQ_IS_COOLING_DEV,
 	.init		= qoriq_cpufreq_cpu_init,
 	.exit		= qoriq_cpufreq_cpu_exit,
 	.verify		= cpufreq_generic_frequency_table_verify,
 	.target_index	= qoriq_cpufreq_target,
 	.get		= cpufreq_generic_get,
-	.ready		= qoriq_cpufreq_ready,
 	.attr		= cpufreq_generic_attr,
 };
 
-- 
2.17.1


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

* [PATCH v5 8/9] cpufreq: scmi: Use auto-registration of thermal cooling device
  2019-01-29  4:55 ` Amit Kucheria
@ 2019-01-29  4:55   ` Amit Kucheria
  -1 siblings, 0 replies; 32+ messages in thread
From: Amit Kucheria @ 2019-01-29  4:55 UTC (permalink / raw)
  To: linux-kernel
  Cc: Sudeep Holla, Rafael J. Wysocki, Viresh Kumar, linux-arm-kernel,
	linux-pm

Use the CPUFREQ_IS_COOLING_DEV flag to allow cpufreq core to
automatically register as a thermal cooling device.

This allows removal of boiler plate code from the driver.

Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
Acked-by: Sudeep Holla <sudeep.holla@arm.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/cpufreq/scmi-cpufreq.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/cpufreq/scmi-cpufreq.c b/drivers/cpufreq/scmi-cpufreq.c
index 242c3370544e..66b633b48eb1 100644
--- a/drivers/cpufreq/scmi-cpufreq.c
+++ b/drivers/cpufreq/scmi-cpufreq.c
@@ -11,7 +11,6 @@
 #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/pm_opp.h>
@@ -22,7 +21,6 @@
 struct scmi_data {
 	int domain_id;
 	struct device *cpu_dev;
-	struct thermal_cooling_device *cdev;
 };
 
 static const struct scmi_handle *handle;
@@ -185,7 +183,6 @@ static int scmi_cpufreq_exit(struct cpufreq_policy *policy)
 {
 	struct scmi_data *priv = policy->driver_data;
 
-	cpufreq_cooling_unregister(priv->cdev);
 	dev_pm_opp_free_cpufreq_table(priv->cpu_dev, &policy->freq_table);
 	kfree(priv);
 	dev_pm_opp_remove_all_dynamic(priv->cpu_dev);
@@ -193,17 +190,11 @@ static int scmi_cpufreq_exit(struct cpufreq_policy *policy)
 	return 0;
 }
 
-static void scmi_cpufreq_ready(struct cpufreq_policy *policy)
-{
-	struct scmi_data *priv = policy->driver_data;
-
-	priv->cdev = of_cpufreq_cooling_register(policy);
-}
-
 static struct cpufreq_driver scmi_cpufreq_driver = {
 	.name	= "scmi",
 	.flags	= CPUFREQ_STICKY | CPUFREQ_HAVE_GOVERNOR_PER_POLICY |
-		  CPUFREQ_NEED_INITIAL_FREQ_CHECK,
+		  CPUFREQ_NEED_INITIAL_FREQ_CHECK |
+		  CPUFREQ_IS_COOLING_DEV,
 	.verify	= cpufreq_generic_frequency_table_verify,
 	.attr	= cpufreq_generic_attr,
 	.target_index	= scmi_cpufreq_set_target,
@@ -211,7 +202,6 @@ static struct cpufreq_driver scmi_cpufreq_driver = {
 	.get	= scmi_cpufreq_get_rate,
 	.init	= scmi_cpufreq_init,
 	.exit	= scmi_cpufreq_exit,
-	.ready	= scmi_cpufreq_ready,
 };
 
 static int scmi_cpufreq_probe(struct scmi_device *sdev)
-- 
2.17.1


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

* [PATCH v5 8/9] cpufreq: scmi: Use auto-registration of thermal cooling device
@ 2019-01-29  4:55   ` Amit Kucheria
  0 siblings, 0 replies; 32+ messages in thread
From: Amit Kucheria @ 2019-01-29  4:55 UTC (permalink / raw)
  To: linux-kernel
  Cc: Viresh Kumar, linux-pm, Rafael J. Wysocki, linux-arm-kernel,
	Sudeep Holla

Use the CPUFREQ_IS_COOLING_DEV flag to allow cpufreq core to
automatically register as a thermal cooling device.

This allows removal of boiler plate code from the driver.

Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
Acked-by: Sudeep Holla <sudeep.holla@arm.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/cpufreq/scmi-cpufreq.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/cpufreq/scmi-cpufreq.c b/drivers/cpufreq/scmi-cpufreq.c
index 242c3370544e..66b633b48eb1 100644
--- a/drivers/cpufreq/scmi-cpufreq.c
+++ b/drivers/cpufreq/scmi-cpufreq.c
@@ -11,7 +11,6 @@
 #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/pm_opp.h>
@@ -22,7 +21,6 @@
 struct scmi_data {
 	int domain_id;
 	struct device *cpu_dev;
-	struct thermal_cooling_device *cdev;
 };
 
 static const struct scmi_handle *handle;
@@ -185,7 +183,6 @@ static int scmi_cpufreq_exit(struct cpufreq_policy *policy)
 {
 	struct scmi_data *priv = policy->driver_data;
 
-	cpufreq_cooling_unregister(priv->cdev);
 	dev_pm_opp_free_cpufreq_table(priv->cpu_dev, &policy->freq_table);
 	kfree(priv);
 	dev_pm_opp_remove_all_dynamic(priv->cpu_dev);
@@ -193,17 +190,11 @@ static int scmi_cpufreq_exit(struct cpufreq_policy *policy)
 	return 0;
 }
 
-static void scmi_cpufreq_ready(struct cpufreq_policy *policy)
-{
-	struct scmi_data *priv = policy->driver_data;
-
-	priv->cdev = of_cpufreq_cooling_register(policy);
-}
-
 static struct cpufreq_driver scmi_cpufreq_driver = {
 	.name	= "scmi",
 	.flags	= CPUFREQ_STICKY | CPUFREQ_HAVE_GOVERNOR_PER_POLICY |
-		  CPUFREQ_NEED_INITIAL_FREQ_CHECK,
+		  CPUFREQ_NEED_INITIAL_FREQ_CHECK |
+		  CPUFREQ_IS_COOLING_DEV,
 	.verify	= cpufreq_generic_frequency_table_verify,
 	.attr	= cpufreq_generic_attr,
 	.target_index	= scmi_cpufreq_set_target,
@@ -211,7 +202,6 @@ static struct cpufreq_driver scmi_cpufreq_driver = {
 	.get	= scmi_cpufreq_get_rate,
 	.init	= scmi_cpufreq_init,
 	.exit	= scmi_cpufreq_exit,
-	.ready	= scmi_cpufreq_ready,
 };
 
 static int scmi_cpufreq_probe(struct scmi_device *sdev)
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v5 9/9] cpufreq: scpi: Use auto-registration of thermal cooling device
  2019-01-29  4:55 ` Amit Kucheria
@ 2019-01-29  4:55   ` Amit Kucheria
  -1 siblings, 0 replies; 32+ messages in thread
From: Amit Kucheria @ 2019-01-29  4:55 UTC (permalink / raw)
  To: linux-kernel
  Cc: Sudeep Holla, Rafael J. Wysocki, Viresh Kumar, Daniel Lezcano,
	linux-arm-kernel, linux-pm

Use the CPUFREQ_IS_COOLING_DEV flag to allow cpufreq core to
automatically register as a thermal cooling device.

This allows removal of boiler plate code from the driver.

Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
Acked-by: Sudeep Holla <sudeep.holla@arm.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/cpufreq/scpi-cpufreq.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/cpufreq/scpi-cpufreq.c b/drivers/cpufreq/scpi-cpufreq.c
index 99449738faa4..1db2f6927e13 100644
--- a/drivers/cpufreq/scpi-cpufreq.c
+++ b/drivers/cpufreq/scpi-cpufreq.c
@@ -22,7 +22,6 @@
 #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/of_platform.h>
@@ -34,7 +33,6 @@
 struct scpi_data {
 	struct clk *clk;
 	struct device *cpu_dev;
-	struct thermal_cooling_device *cdev;
 };
 
 static struct scpi_ops *scpi_ops;
@@ -186,7 +184,6 @@ static int scpi_cpufreq_exit(struct cpufreq_policy *policy)
 {
 	struct scpi_data *priv = policy->driver_data;
 
-	cpufreq_cooling_unregister(priv->cdev);
 	clk_put(priv->clk);
 	dev_pm_opp_free_cpufreq_table(priv->cpu_dev, &policy->freq_table);
 	kfree(priv);
@@ -195,23 +192,16 @@ static int scpi_cpufreq_exit(struct cpufreq_policy *policy)
 	return 0;
 }
 
-static void scpi_cpufreq_ready(struct cpufreq_policy *policy)
-{
-	struct scpi_data *priv = policy->driver_data;
-
-	priv->cdev = of_cpufreq_cooling_register(policy);
-}
-
 static struct cpufreq_driver scpi_cpufreq_driver = {
 	.name	= "scpi-cpufreq",
 	.flags	= CPUFREQ_STICKY | CPUFREQ_HAVE_GOVERNOR_PER_POLICY |
-		  CPUFREQ_NEED_INITIAL_FREQ_CHECK,
+		  CPUFREQ_NEED_INITIAL_FREQ_CHECK |
+		  CPUFREQ_IS_COOLING_DEV,
 	.verify	= cpufreq_generic_frequency_table_verify,
 	.attr	= cpufreq_generic_attr,
 	.get	= scpi_cpufreq_get_rate,
 	.init	= scpi_cpufreq_init,
 	.exit	= scpi_cpufreq_exit,
-	.ready	= scpi_cpufreq_ready,
 	.target_index	= scpi_cpufreq_set_target,
 };
 
-- 
2.17.1


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

* [PATCH v5 9/9] cpufreq: scpi: Use auto-registration of thermal cooling device
@ 2019-01-29  4:55   ` Amit Kucheria
  0 siblings, 0 replies; 32+ messages in thread
From: Amit Kucheria @ 2019-01-29  4:55 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-pm, Viresh Kumar, Daniel Lezcano, Rafael J. Wysocki,
	Sudeep Holla, linux-arm-kernel

Use the CPUFREQ_IS_COOLING_DEV flag to allow cpufreq core to
automatically register as a thermal cooling device.

This allows removal of boiler plate code from the driver.

Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
Acked-by: Sudeep Holla <sudeep.holla@arm.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/cpufreq/scpi-cpufreq.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/cpufreq/scpi-cpufreq.c b/drivers/cpufreq/scpi-cpufreq.c
index 99449738faa4..1db2f6927e13 100644
--- a/drivers/cpufreq/scpi-cpufreq.c
+++ b/drivers/cpufreq/scpi-cpufreq.c
@@ -22,7 +22,6 @@
 #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/of_platform.h>
@@ -34,7 +33,6 @@
 struct scpi_data {
 	struct clk *clk;
 	struct device *cpu_dev;
-	struct thermal_cooling_device *cdev;
 };
 
 static struct scpi_ops *scpi_ops;
@@ -186,7 +184,6 @@ static int scpi_cpufreq_exit(struct cpufreq_policy *policy)
 {
 	struct scpi_data *priv = policy->driver_data;
 
-	cpufreq_cooling_unregister(priv->cdev);
 	clk_put(priv->clk);
 	dev_pm_opp_free_cpufreq_table(priv->cpu_dev, &policy->freq_table);
 	kfree(priv);
@@ -195,23 +192,16 @@ static int scpi_cpufreq_exit(struct cpufreq_policy *policy)
 	return 0;
 }
 
-static void scpi_cpufreq_ready(struct cpufreq_policy *policy)
-{
-	struct scpi_data *priv = policy->driver_data;
-
-	priv->cdev = of_cpufreq_cooling_register(policy);
-}
-
 static struct cpufreq_driver scpi_cpufreq_driver = {
 	.name	= "scpi-cpufreq",
 	.flags	= CPUFREQ_STICKY | CPUFREQ_HAVE_GOVERNOR_PER_POLICY |
-		  CPUFREQ_NEED_INITIAL_FREQ_CHECK,
+		  CPUFREQ_NEED_INITIAL_FREQ_CHECK |
+		  CPUFREQ_IS_COOLING_DEV,
 	.verify	= cpufreq_generic_frequency_table_verify,
 	.attr	= cpufreq_generic_attr,
 	.get	= scpi_cpufreq_get_rate,
 	.init	= scpi_cpufreq_init,
 	.exit	= scpi_cpufreq_exit,
-	.ready	= scpi_cpufreq_ready,
 	.target_index	= scpi_cpufreq_set_target,
 };
 
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v5 2/9] cpufreq: Auto-register the driver as a thermal cooling device if asked
  2019-01-29  4:55 ` [PATCH v5 2/9] cpufreq: Auto-register the driver as a thermal cooling device if asked Amit Kucheria
@ 2019-01-29  5:36   ` Viresh Kumar
  2019-01-29  5:46     ` Amit Kucheria
  0 siblings, 1 reply; 32+ messages in thread
From: Viresh Kumar @ 2019-01-29  5:36 UTC (permalink / raw)
  To: Amit Kucheria; +Cc: linux-kernel, Rafael J. Wysocki, Sudeep Holla, linux-pm

On 29-01-19, 10:25, Amit Kucheria wrote:
> All cpufreq drivers do similar things to register as a cooling device.
> Provide a cpufreq driver flag so drivers can just ask the cpufreq core
> to register the cooling device on their behalf. This allows us to get
> rid of duplicated code in the drivers.
> 
> In order to allow this, we add a struct thermal_cooling_device pointer
> to struct cpufreq_policy so that drivers don't need to store it in a
> private data structure.
> 
> Suggested-by: Stephen Boyd <swboyd@chromium.org>
> Suggested-by: Viresh Kumar <viresh.kumar@linaro.org>
> Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
> Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
> Tested-by: Matthias Kaehlcke <mka@chromium.org>
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
>  drivers/cpufreq/cpufreq.c | 13 +++++++++++++
>  include/linux/cpufreq.h   |  9 +++++++++
>  2 files changed, 22 insertions(+)
> 
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index e35a886e00bc..0f9b50d3ee91 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -19,6 +19,7 @@
>  
>  #include <linux/cpu.h>
>  #include <linux/cpufreq.h>
> +#include <linux/cpu_cooling.h>
>  #include <linux/delay.h>
>  #include <linux/device.h>
>  #include <linux/init.h>
> @@ -1318,6 +1319,11 @@ static int cpufreq_online(unsigned int cpu)
>  	if (cpufreq_driver->ready)
>  		cpufreq_driver->ready(policy);
>  
> +#if IS_ENABLED(CONFIG_CPU_THERMAL)
> +	if (cpufreq_driver->flags & CPUFREQ_IS_COOLING_DEV)
> +		policy->cdev = of_cpufreq_cooling_register(policy);
> +#endif

I am not sure if Rafael wanted it this way but maybe something like this:

        if (IS_ENABLED(CONFIG_CPU_THERMAL) &&
            cpufreq_driver->flags & CPUFREQ_IS_COOLING_DEV))
		policy->cdev = of_cpufreq_cooling_register(policy);

We never wanted ifdef hackery to be in there :)

-- 
viresh

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

* Re: [PATCH v5 2/9] cpufreq: Auto-register the driver as a thermal cooling device if asked
  2019-01-29  5:36   ` Viresh Kumar
@ 2019-01-29  5:46     ` Amit Kucheria
  2019-01-29  6:20       ` Amit Kucheria
  2019-01-29  9:13       ` Rafael J. Wysocki
  0 siblings, 2 replies; 32+ messages in thread
From: Amit Kucheria @ 2019-01-29  5:46 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Linux Kernel Mailing List, Rafael J. Wysocki, Sudeep Holla,
	Linux PM list

On Tue, Jan 29, 2019 at 11:06 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
>
> On 29-01-19, 10:25, Amit Kucheria wrote:
> > All cpufreq drivers do similar things to register as a cooling device.
> > Provide a cpufreq driver flag so drivers can just ask the cpufreq core
> > to register the cooling device on their behalf. This allows us to get
> > rid of duplicated code in the drivers.
> >
> > In order to allow this, we add a struct thermal_cooling_device pointer
> > to struct cpufreq_policy so that drivers don't need to store it in a
> > private data structure.
> >
> > Suggested-by: Stephen Boyd <swboyd@chromium.org>
> > Suggested-by: Viresh Kumar <viresh.kumar@linaro.org>
> > Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
> > Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
> > Tested-by: Matthias Kaehlcke <mka@chromium.org>
> > Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
> > ---
> >  drivers/cpufreq/cpufreq.c | 13 +++++++++++++
> >  include/linux/cpufreq.h   |  9 +++++++++
> >  2 files changed, 22 insertions(+)
> >
> > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> > index e35a886e00bc..0f9b50d3ee91 100644
> > --- a/drivers/cpufreq/cpufreq.c
> > +++ b/drivers/cpufreq/cpufreq.c
> > @@ -19,6 +19,7 @@
> >
> >  #include <linux/cpu.h>
> >  #include <linux/cpufreq.h>
> > +#include <linux/cpu_cooling.h>
> >  #include <linux/delay.h>
> >  #include <linux/device.h>
> >  #include <linux/init.h>
> > @@ -1318,6 +1319,11 @@ static int cpufreq_online(unsigned int cpu)
> >       if (cpufreq_driver->ready)
> >               cpufreq_driver->ready(policy);
> >
> > +#if IS_ENABLED(CONFIG_CPU_THERMAL)
> > +     if (cpufreq_driver->flags & CPUFREQ_IS_COOLING_DEV)
> > +             policy->cdev = of_cpufreq_cooling_register(policy);
> > +#endif
>
> I am not sure if Rafael wanted it this way but maybe something like this:
>
>         if (IS_ENABLED(CONFIG_CPU_THERMAL) &&
>             cpufreq_driver->flags & CPUFREQ_IS_COOLING_DEV))
>                 policy->cdev = of_cpufreq_cooling_register(policy);
>
> We never wanted ifdef hackery to be in there :)

OK, that makes more sense. Should I just send out a fixup patch or the
entire series?

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

* Re: [PATCH v5 2/9] cpufreq: Auto-register the driver as a thermal cooling device if asked
  2019-01-29  5:46     ` Amit Kucheria
@ 2019-01-29  6:20       ` Amit Kucheria
  2019-01-29  7:09         ` Viresh Kumar
  2019-01-29  9:13       ` Rafael J. Wysocki
  1 sibling, 1 reply; 32+ messages in thread
From: Amit Kucheria @ 2019-01-29  6:20 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Linux Kernel Mailing List, Rafael J. Wysocki, Sudeep Holla,
	Linux PM list

On Tue, Jan 29, 2019 at 11:16 AM Amit Kucheria <amit.kucheria@linaro.org> wrote:
>
> On Tue, Jan 29, 2019 at 11:06 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
> >
> > On 29-01-19, 10:25, Amit Kucheria wrote:
> > > All cpufreq drivers do similar things to register as a cooling device.
> > > Provide a cpufreq driver flag so drivers can just ask the cpufreq core
> > > to register the cooling device on their behalf. This allows us to get
> > > rid of duplicated code in the drivers.
> > >
> > > In order to allow this, we add a struct thermal_cooling_device pointer
> > > to struct cpufreq_policy so that drivers don't need to store it in a
> > > private data structure.
> > >
> > > Suggested-by: Stephen Boyd <swboyd@chromium.org>
> > > Suggested-by: Viresh Kumar <viresh.kumar@linaro.org>
> > > Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
> > > Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
> > > Tested-by: Matthias Kaehlcke <mka@chromium.org>
> > > Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
> > > ---
> > >  drivers/cpufreq/cpufreq.c | 13 +++++++++++++
> > >  include/linux/cpufreq.h   |  9 +++++++++
> > >  2 files changed, 22 insertions(+)
> > >
> > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> > > index e35a886e00bc..0f9b50d3ee91 100644
> > > --- a/drivers/cpufreq/cpufreq.c
> > > +++ b/drivers/cpufreq/cpufreq.c
> > > @@ -19,6 +19,7 @@
> > >
> > >  #include <linux/cpu.h>
> > >  #include <linux/cpufreq.h>
> > > +#include <linux/cpu_cooling.h>
> > >  #include <linux/delay.h>
> > >  #include <linux/device.h>
> > >  #include <linux/init.h>
> > > @@ -1318,6 +1319,11 @@ static int cpufreq_online(unsigned int cpu)
> > >       if (cpufreq_driver->ready)
> > >               cpufreq_driver->ready(policy);
> > >
> > > +#if IS_ENABLED(CONFIG_CPU_THERMAL)
> > > +     if (cpufreq_driver->flags & CPUFREQ_IS_COOLING_DEV)
> > > +             policy->cdev = of_cpufreq_cooling_register(policy);
> > > +#endif
> >
> > I am not sure if Rafael wanted it this way but maybe something like this:
> >
> >         if (IS_ENABLED(CONFIG_CPU_THERMAL) &&
> >             cpufreq_driver->flags & CPUFREQ_IS_COOLING_DEV))
> >                 policy->cdev = of_cpufreq_cooling_register(policy);
> >
> > We never wanted ifdef hackery to be in there :)
>
> OK, that makes more sense. Should I just send out a fixup patch or the
> entire series?

FWIW, I checked drivers/cpufreq and drivers/thermal before converting
over and there is a mixed use of #if IS_ENABLED and if(IS_ENABLED).

Perhaps we should clean it up?

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

* Re: [PATCH v5 2/9] cpufreq: Auto-register the driver as a thermal cooling device if asked
  2019-01-29  6:20       ` Amit Kucheria
@ 2019-01-29  7:09         ` Viresh Kumar
  2019-01-29  9:16           ` Rafael J. Wysocki
  0 siblings, 1 reply; 32+ messages in thread
From: Viresh Kumar @ 2019-01-29  7:09 UTC (permalink / raw)
  To: Amit Kucheria
  Cc: Linux Kernel Mailing List, Rafael J. Wysocki, Sudeep Holla,
	Linux PM list

On 29-01-19, 11:50, Amit Kucheria wrote:
> On Tue, Jan 29, 2019 at 11:16 AM Amit Kucheria <amit.kucheria@linaro.org> wrote:
> >
> > On Tue, Jan 29, 2019 at 11:06 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
> > >
> > > On 29-01-19, 10:25, Amit Kucheria wrote:
> > > > All cpufreq drivers do similar things to register as a cooling device.
> > > > Provide a cpufreq driver flag so drivers can just ask the cpufreq core
> > > > to register the cooling device on their behalf. This allows us to get
> > > > rid of duplicated code in the drivers.
> > > >
> > > > In order to allow this, we add a struct thermal_cooling_device pointer
> > > > to struct cpufreq_policy so that drivers don't need to store it in a
> > > > private data structure.
> > > >
> > > > Suggested-by: Stephen Boyd <swboyd@chromium.org>
> > > > Suggested-by: Viresh Kumar <viresh.kumar@linaro.org>
> > > > Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
> > > > Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
> > > > Tested-by: Matthias Kaehlcke <mka@chromium.org>
> > > > Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
> > > > ---
> > > >  drivers/cpufreq/cpufreq.c | 13 +++++++++++++
> > > >  include/linux/cpufreq.h   |  9 +++++++++
> > > >  2 files changed, 22 insertions(+)
> > > >
> > > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> > > > index e35a886e00bc..0f9b50d3ee91 100644
> > > > --- a/drivers/cpufreq/cpufreq.c
> > > > +++ b/drivers/cpufreq/cpufreq.c
> > > > @@ -19,6 +19,7 @@
> > > >
> > > >  #include <linux/cpu.h>
> > > >  #include <linux/cpufreq.h>
> > > > +#include <linux/cpu_cooling.h>
> > > >  #include <linux/delay.h>
> > > >  #include <linux/device.h>
> > > >  #include <linux/init.h>
> > > > @@ -1318,6 +1319,11 @@ static int cpufreq_online(unsigned int cpu)
> > > >       if (cpufreq_driver->ready)
> > > >               cpufreq_driver->ready(policy);
> > > >
> > > > +#if IS_ENABLED(CONFIG_CPU_THERMAL)
> > > > +     if (cpufreq_driver->flags & CPUFREQ_IS_COOLING_DEV)
> > > > +             policy->cdev = of_cpufreq_cooling_register(policy);
> > > > +#endif
> > >
> > > I am not sure if Rafael wanted it this way but maybe something like this:
> > >
> > >         if (IS_ENABLED(CONFIG_CPU_THERMAL) &&
> > >             cpufreq_driver->flags & CPUFREQ_IS_COOLING_DEV))
> > >                 policy->cdev = of_cpufreq_cooling_register(policy);
> > >
> > > We never wanted ifdef hackery to be in there :)
> >
> > OK, that makes more sense. Should I just send out a fixup patch or the
> > entire series?

Single patch should be fine I believe.

> FWIW, I checked drivers/cpufreq and drivers/thermal before converting
> over and there is a mixed use of #if IS_ENABLED and if(IS_ENABLED).
> 
> Perhaps we should clean it up?

No objections from me on that.

-- 
viresh

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

* Re: [PATCH v5 2/9] cpufreq: Auto-register the driver as a thermal cooling device if asked
  2019-01-29  5:46     ` Amit Kucheria
  2019-01-29  6:20       ` Amit Kucheria
@ 2019-01-29  9:13       ` Rafael J. Wysocki
  2019-01-29 20:20         ` Amit Kucheria
  1 sibling, 1 reply; 32+ messages in thread
From: Rafael J. Wysocki @ 2019-01-29  9:13 UTC (permalink / raw)
  To: Amit Kucheria
  Cc: Viresh Kumar, Linux Kernel Mailing List, Rafael J. Wysocki,
	Sudeep Holla, Linux PM list

On Tue, Jan 29, 2019 at 6:46 AM Amit Kucheria <amit.kucheria@linaro.org> wrote:
>
> On Tue, Jan 29, 2019 at 11:06 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
> >
> > On 29-01-19, 10:25, Amit Kucheria wrote:
> > > All cpufreq drivers do similar things to register as a cooling device.
> > > Provide a cpufreq driver flag so drivers can just ask the cpufreq core
> > > to register the cooling device on their behalf. This allows us to get
> > > rid of duplicated code in the drivers.
> > >
> > > In order to allow this, we add a struct thermal_cooling_device pointer
> > > to struct cpufreq_policy so that drivers don't need to store it in a
> > > private data structure.
> > >
> > > Suggested-by: Stephen Boyd <swboyd@chromium.org>
> > > Suggested-by: Viresh Kumar <viresh.kumar@linaro.org>
> > > Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
> > > Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
> > > Tested-by: Matthias Kaehlcke <mka@chromium.org>
> > > Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
> > > ---
> > >  drivers/cpufreq/cpufreq.c | 13 +++++++++++++
> > >  include/linux/cpufreq.h   |  9 +++++++++
> > >  2 files changed, 22 insertions(+)
> > >
> > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> > > index e35a886e00bc..0f9b50d3ee91 100644
> > > --- a/drivers/cpufreq/cpufreq.c
> > > +++ b/drivers/cpufreq/cpufreq.c
> > > @@ -19,6 +19,7 @@
> > >
> > >  #include <linux/cpu.h>
> > >  #include <linux/cpufreq.h>
> > > +#include <linux/cpu_cooling.h>
> > >  #include <linux/delay.h>
> > >  #include <linux/device.h>
> > >  #include <linux/init.h>
> > > @@ -1318,6 +1319,11 @@ static int cpufreq_online(unsigned int cpu)
> > >       if (cpufreq_driver->ready)
> > >               cpufreq_driver->ready(policy);
> > >
> > > +#if IS_ENABLED(CONFIG_CPU_THERMAL)
> > > +     if (cpufreq_driver->flags & CPUFREQ_IS_COOLING_DEV)
> > > +             policy->cdev = of_cpufreq_cooling_register(policy);
> > > +#endif
> >
> > I am not sure if Rafael wanted it this way but maybe something like this:
> >
> >         if (IS_ENABLED(CONFIG_CPU_THERMAL) &&
> >             cpufreq_driver->flags & CPUFREQ_IS_COOLING_DEV))
> >                 policy->cdev = of_cpufreq_cooling_register(policy);
> >
> > We never wanted ifdef hackery to be in there :)
>
> OK, that makes more sense. Should I just send out a fixup patch or the
> entire series?

Just a fixup patch, please.

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

* Re: [PATCH v5 2/9] cpufreq: Auto-register the driver as a thermal cooling device if asked
  2019-01-29  7:09         ` Viresh Kumar
@ 2019-01-29  9:16           ` Rafael J. Wysocki
  0 siblings, 0 replies; 32+ messages in thread
From: Rafael J. Wysocki @ 2019-01-29  9:16 UTC (permalink / raw)
  To: Viresh Kumar, Amit Kucheria
  Cc: Linux Kernel Mailing List, Rafael J. Wysocki, Sudeep Holla,
	Linux PM list

On Tue, Jan 29, 2019 at 8:09 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
>
> On 29-01-19, 11:50, Amit Kucheria wrote:
> > On Tue, Jan 29, 2019 at 11:16 AM Amit Kucheria <amit.kucheria@linaro.org> wrote:
> > >
> > > On Tue, Jan 29, 2019 at 11:06 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
> > > >
> > > > On 29-01-19, 10:25, Amit Kucheria wrote:
> > > > > All cpufreq drivers do similar things to register as a cooling device.
> > > > > Provide a cpufreq driver flag so drivers can just ask the cpufreq core
> > > > > to register the cooling device on their behalf. This allows us to get
> > > > > rid of duplicated code in the drivers.
> > > > >
> > > > > In order to allow this, we add a struct thermal_cooling_device pointer
> > > > > to struct cpufreq_policy so that drivers don't need to store it in a
> > > > > private data structure.
> > > > >
> > > > > Suggested-by: Stephen Boyd <swboyd@chromium.org>
> > > > > Suggested-by: Viresh Kumar <viresh.kumar@linaro.org>
> > > > > Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
> > > > > Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
> > > > > Tested-by: Matthias Kaehlcke <mka@chromium.org>
> > > > > Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
> > > > > ---
> > > > >  drivers/cpufreq/cpufreq.c | 13 +++++++++++++
> > > > >  include/linux/cpufreq.h   |  9 +++++++++
> > > > >  2 files changed, 22 insertions(+)
> > > > >
> > > > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> > > > > index e35a886e00bc..0f9b50d3ee91 100644
> > > > > --- a/drivers/cpufreq/cpufreq.c
> > > > > +++ b/drivers/cpufreq/cpufreq.c
> > > > > @@ -19,6 +19,7 @@
> > > > >
> > > > >  #include <linux/cpu.h>
> > > > >  #include <linux/cpufreq.h>
> > > > > +#include <linux/cpu_cooling.h>
> > > > >  #include <linux/delay.h>
> > > > >  #include <linux/device.h>
> > > > >  #include <linux/init.h>
> > > > > @@ -1318,6 +1319,11 @@ static int cpufreq_online(unsigned int cpu)
> > > > >       if (cpufreq_driver->ready)
> > > > >               cpufreq_driver->ready(policy);
> > > > >
> > > > > +#if IS_ENABLED(CONFIG_CPU_THERMAL)
> > > > > +     if (cpufreq_driver->flags & CPUFREQ_IS_COOLING_DEV)
> > > > > +             policy->cdev = of_cpufreq_cooling_register(policy);
> > > > > +#endif
> > > >
> > > > I am not sure if Rafael wanted it this way but maybe something like this:
> > > >
> > > >         if (IS_ENABLED(CONFIG_CPU_THERMAL) &&
> > > >             cpufreq_driver->flags & CPUFREQ_IS_COOLING_DEV))
> > > >                 policy->cdev = of_cpufreq_cooling_register(policy);
> > > >
> > > > We never wanted ifdef hackery to be in there :)
> > >
> > > OK, that makes more sense. Should I just send out a fixup patch or the
> > > entire series?
>
> Single patch should be fine I believe.
>
> > FWIW, I checked drivers/cpufreq and drivers/thermal before converting
> > over and there is a mixed use of #if IS_ENABLED and if(IS_ENABLED).
> >
> > Perhaps we should clean it up?
>
> No objections from me on that.

Generally speaking, though, "if (IS_ENABLED(SYMBOL))" can only be used
if all of the symbols in the conditional branch are defined regardless
of whether or not SYMBOL itself is defined, so careful there.

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

* Re: [PATCH v5 2/9] cpufreq: Auto-register the driver as a thermal cooling device if asked
  2019-01-29  9:13       ` Rafael J. Wysocki
@ 2019-01-29 20:20         ` Amit Kucheria
  2019-01-29 22:22           ` Rafael J. Wysocki
  0 siblings, 1 reply; 32+ messages in thread
From: Amit Kucheria @ 2019-01-29 20:20 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Viresh Kumar, Linux Kernel Mailing List, Rafael J. Wysocki,
	Sudeep Holla, Linux PM list

[-- Attachment #1: Type: text/plain, Size: 2976 bytes --]

On Tue, Jan 29, 2019 at 2:43 PM Rafael J. Wysocki <rafael@kernel.org> wrote:
>
> On Tue, Jan 29, 2019 at 6:46 AM Amit Kucheria <amit.kucheria@linaro.org> wrote:
> >
> > On Tue, Jan 29, 2019 at 11:06 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
> > >
> > > On 29-01-19, 10:25, Amit Kucheria wrote:
> > > > All cpufreq drivers do similar things to register as a cooling device.
> > > > Provide a cpufreq driver flag so drivers can just ask the cpufreq core
> > > > to register the cooling device on their behalf. This allows us to get
> > > > rid of duplicated code in the drivers.
> > > >
> > > > In order to allow this, we add a struct thermal_cooling_device pointer
> > > > to struct cpufreq_policy so that drivers don't need to store it in a
> > > > private data structure.
> > > >
> > > > Suggested-by: Stephen Boyd <swboyd@chromium.org>
> > > > Suggested-by: Viresh Kumar <viresh.kumar@linaro.org>
> > > > Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
> > > > Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
> > > > Tested-by: Matthias Kaehlcke <mka@chromium.org>
> > > > Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
> > > > ---
> > > >  drivers/cpufreq/cpufreq.c | 13 +++++++++++++
> > > >  include/linux/cpufreq.h   |  9 +++++++++
> > > >  2 files changed, 22 insertions(+)
> > > >
> > > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> > > > index e35a886e00bc..0f9b50d3ee91 100644
> > > > --- a/drivers/cpufreq/cpufreq.c
> > > > +++ b/drivers/cpufreq/cpufreq.c
> > > > @@ -19,6 +19,7 @@
> > > >
> > > >  #include <linux/cpu.h>
> > > >  #include <linux/cpufreq.h>
> > > > +#include <linux/cpu_cooling.h>
> > > >  #include <linux/delay.h>
> > > >  #include <linux/device.h>
> > > >  #include <linux/init.h>
> > > > @@ -1318,6 +1319,11 @@ static int cpufreq_online(unsigned int cpu)
> > > >       if (cpufreq_driver->ready)
> > > >               cpufreq_driver->ready(policy);
> > > >
> > > > +#if IS_ENABLED(CONFIG_CPU_THERMAL)
> > > > +     if (cpufreq_driver->flags & CPUFREQ_IS_COOLING_DEV)
> > > > +             policy->cdev = of_cpufreq_cooling_register(policy);
> > > > +#endif
> > >
> > > I am not sure if Rafael wanted it this way but maybe something like this:
> > >
> > >         if (IS_ENABLED(CONFIG_CPU_THERMAL) &&
> > >             cpufreq_driver->flags & CPUFREQ_IS_COOLING_DEV))
> > >                 policy->cdev = of_cpufreq_cooling_register(policy);
> > >
> > > We never wanted ifdef hackery to be in there :)
> >
> > OK, that makes more sense. Should I just send out a fixup patch or the
> > entire series?
>
> Just a fixup patch, please.

Please find attached a fixup patch suitable to add to the top of the
series and use git rebase --autosquash on.

The entire series with this patch squashed in and rebased on top of
today's linux-next is available for your convenience if needed[1]

Thanks,
Amit

[1] https://git.linaro.org/people/amit.kucheria/kernel.git/log/?h=up/cpufreq/auto-register-cooling-dev-v5

[-- Attachment #2: 0001-fixup-cpufreq-Auto-register-the-driver-as-a-thermal-.patch --]
[-- Type: text/x-patch, Size: 1483 bytes --]

From cb5aa5001e86f4635b39fa1e3955a530f8a0ced8 Mon Sep 17 00:00:00 2001
Message-Id: <cb5aa5001e86f4635b39fa1e3955a530f8a0ced8.1548792485.git.amit.kucheria@linaro.org>
From: Amit Kucheria <amit.kucheria@linaro.org>
Date: Wed, 30 Jan 2019 01:37:40 +0530
Subject: [PATCH] fixup! cpufreq: Auto-register the driver as a thermal cooling
 device if asked

---
 drivers/cpufreq/cpufreq.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 0f9b50d3ee91..cd574f031318 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1319,10 +1319,9 @@ static int cpufreq_online(unsigned int cpu)
 	if (cpufreq_driver->ready)
 		cpufreq_driver->ready(policy);
 
-#if IS_ENABLED(CONFIG_CPU_THERMAL)
-	if (cpufreq_driver->flags & CPUFREQ_IS_COOLING_DEV)
+	if (IS_ENABLED(CONFIG_CPU_THERMAL) &&
+	    cpufreq_driver->flags & CPUFREQ_IS_COOLING_DEV)
 		policy->cdev = of_cpufreq_cooling_register(policy);
-#endif
 
 	pr_debug("initialization complete\n");
 
@@ -1411,12 +1410,11 @@ static int cpufreq_offline(unsigned int cpu)
 		goto unlock;
 	}
 
-#if IS_ENABLED(CONFIG_CPU_THERMAL)
-	if (cpufreq_driver->flags & CPUFREQ_IS_COOLING_DEV) {
+	if (IS_ENABLED(CONFIG_CPU_THERMAL) &&
+	    cpufreq_driver->flags & CPUFREQ_IS_COOLING_DEV) {
 		cpufreq_cooling_unregister(policy->cdev);
 		policy->cdev = NULL;
 	}
-#endif
 
 	if (cpufreq_driver->stop_cpu)
 		cpufreq_driver->stop_cpu(policy);
-- 
2.17.1


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

* Re: [PATCH v5 2/9] cpufreq: Auto-register the driver as a thermal cooling device if asked
  2019-01-29 20:20         ` Amit Kucheria
@ 2019-01-29 22:22           ` Rafael J. Wysocki
  2019-01-30  5:22             ` [PATCH] " Amit Kucheria
  0 siblings, 1 reply; 32+ messages in thread
From: Rafael J. Wysocki @ 2019-01-29 22:22 UTC (permalink / raw)
  To: Amit Kucheria
  Cc: Rafael J. Wysocki, Viresh Kumar, Linux Kernel Mailing List,
	Rafael J. Wysocki, Sudeep Holla, Linux PM list

On Tue, Jan 29, 2019 at 9:20 PM Amit Kucheria <amit.kucheria@linaro.org> wrote:
>
> On Tue, Jan 29, 2019 at 2:43 PM Rafael J. Wysocki <rafael@kernel.org> wrote:
> >
> > On Tue, Jan 29, 2019 at 6:46 AM Amit Kucheria <amit.kucheria@linaro.org> wrote:
> > >
> > > On Tue, Jan 29, 2019 at 11:06 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
> > > >
> > > > On 29-01-19, 10:25, Amit Kucheria wrote:
> > > > > All cpufreq drivers do similar things to register as a cooling device.
> > > > > Provide a cpufreq driver flag so drivers can just ask the cpufreq core
> > > > > to register the cooling device on their behalf. This allows us to get
> > > > > rid of duplicated code in the drivers.
> > > > >
> > > > > In order to allow this, we add a struct thermal_cooling_device pointer
> > > > > to struct cpufreq_policy so that drivers don't need to store it in a
> > > > > private data structure.
> > > > >
> > > > > Suggested-by: Stephen Boyd <swboyd@chromium.org>
> > > > > Suggested-by: Viresh Kumar <viresh.kumar@linaro.org>
> > > > > Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
> > > > > Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
> > > > > Tested-by: Matthias Kaehlcke <mka@chromium.org>
> > > > > Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
> > > > > ---
> > > > >  drivers/cpufreq/cpufreq.c | 13 +++++++++++++
> > > > >  include/linux/cpufreq.h   |  9 +++++++++
> > > > >  2 files changed, 22 insertions(+)
> > > > >
> > > > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> > > > > index e35a886e00bc..0f9b50d3ee91 100644
> > > > > --- a/drivers/cpufreq/cpufreq.c
> > > > > +++ b/drivers/cpufreq/cpufreq.c
> > > > > @@ -19,6 +19,7 @@
> > > > >
> > > > >  #include <linux/cpu.h>
> > > > >  #include <linux/cpufreq.h>
> > > > > +#include <linux/cpu_cooling.h>
> > > > >  #include <linux/delay.h>
> > > > >  #include <linux/device.h>
> > > > >  #include <linux/init.h>
> > > > > @@ -1318,6 +1319,11 @@ static int cpufreq_online(unsigned int cpu)
> > > > >       if (cpufreq_driver->ready)
> > > > >               cpufreq_driver->ready(policy);
> > > > >
> > > > > +#if IS_ENABLED(CONFIG_CPU_THERMAL)
> > > > > +     if (cpufreq_driver->flags & CPUFREQ_IS_COOLING_DEV)
> > > > > +             policy->cdev = of_cpufreq_cooling_register(policy);
> > > > > +#endif
> > > >
> > > > I am not sure if Rafael wanted it this way but maybe something like this:
> > > >
> > > >         if (IS_ENABLED(CONFIG_CPU_THERMAL) &&
> > > >             cpufreq_driver->flags & CPUFREQ_IS_COOLING_DEV))
> > > >                 policy->cdev = of_cpufreq_cooling_register(policy);
> > > >
> > > > We never wanted ifdef hackery to be in there :)
> > >
> > > OK, that makes more sense. Should I just send out a fixup patch or the
> > > entire series?
> >
> > Just a fixup patch, please.
>
> Please find attached a fixup patch suitable to add to the top of the
> series and use git rebase --autosquash on.

This isn't Patchwork-friendly, so can you send the complete patch
instead, please?

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

* [PATCH] cpufreq: Auto-register the driver as a thermal cooling device if asked
  2019-01-29 22:22           ` Rafael J. Wysocki
@ 2019-01-30  5:22             ` Amit Kucheria
  2019-01-30  6:34               ` Viresh Kumar
  2019-01-30  7:28               ` Daniel Lezcano
  0 siblings, 2 replies; 32+ messages in thread
From: Amit Kucheria @ 2019-01-30  5:22 UTC (permalink / raw)
  To: linux-kernel; +Cc: Rafael J. Wysocki, Viresh Kumar, Sudeep Holla, linux-pm

All cpufreq drivers do similar things to register as a cooling device.
Provide a cpufreq driver flag so drivers can just ask the cpufreq core
to register the cooling device on their behalf. This allows us to get
rid of duplicated code in the drivers.

In order to allow this, we add a struct thermal_cooling_device pointer
to struct cpufreq_policy so that drivers don't need to store it in a
private data structure.

Suggested-by: Stephen Boyd <swboyd@chromium.org>
Suggested-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
Tested-by: Matthias Kaehlcke <mka@chromium.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/cpufreq.c | 11 +++++++++++
 include/linux/cpufreq.h   |  9 +++++++++
 2 files changed, 20 insertions(+)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index a8fa684f5f90..cae730264bc0 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -19,6 +19,7 @@
 
 #include <linux/cpu.h>
 #include <linux/cpufreq.h>
+#include <linux/cpu_cooling.h>
 #include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/init.h>
@@ -1316,6 +1317,10 @@ static int cpufreq_online(unsigned int cpu)
 	if (cpufreq_driver->ready)
 		cpufreq_driver->ready(policy);
 
+	if (IS_ENABLED(CONFIG_CPU_THERMAL) &&
+	    cpufreq_driver->flags & CPUFREQ_IS_COOLING_DEV)
+		policy->cdev = of_cpufreq_cooling_register(policy);
+
 	pr_debug("initialization complete\n");
 
 	return 0;
@@ -1403,6 +1408,12 @@ static int cpufreq_offline(unsigned int cpu)
 		goto unlock;
 	}
 
+	if (IS_ENABLED(CONFIG_CPU_THERMAL) &&
+	    cpufreq_driver->flags & CPUFREQ_IS_COOLING_DEV) {
+		cpufreq_cooling_unregister(policy->cdev);
+		policy->cdev = NULL;
+	}
+
 	if (cpufreq_driver->stop_cpu)
 		cpufreq_driver->stop_cpu(policy);
 
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index bd7fbd6a4478..6078eb07a7e4 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -151,6 +151,9 @@ struct cpufreq_policy {
 
 	/* For cpufreq driver's internal use */
 	void			*driver_data;
+
+	/* Pointer to the cooling device if used for thermal mitigation */
+	struct thermal_cooling_device *cdev;
 };
 
 /* Only for ACPI */
@@ -386,6 +389,12 @@ struct cpufreq_driver {
  */
 #define CPUFREQ_NO_AUTO_DYNAMIC_SWITCHING	BIT(6)
 
+/*
+ * Set by drivers that want the core to automatically register the cpufreq
+ * driver as a thermal cooling device.
+ */
+#define CPUFREQ_IS_COOLING_DEV			BIT(7)
+
 int cpufreq_register_driver(struct cpufreq_driver *driver_data);
 int cpufreq_unregister_driver(struct cpufreq_driver *driver_data);
 
-- 
2.17.1


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

* Re: [PATCH] cpufreq: Auto-register the driver as a thermal cooling device if asked
  2019-01-30  5:22             ` [PATCH] " Amit Kucheria
@ 2019-01-30  6:34               ` Viresh Kumar
  2019-01-30  7:28               ` Daniel Lezcano
  1 sibling, 0 replies; 32+ messages in thread
From: Viresh Kumar @ 2019-01-30  6:34 UTC (permalink / raw)
  To: Amit Kucheria; +Cc: linux-kernel, Rafael J. Wysocki, Sudeep Holla, linux-pm

On 30-01-19, 10:52, Amit Kucheria wrote:
> All cpufreq drivers do similar things to register as a cooling device.
> Provide a cpufreq driver flag so drivers can just ask the cpufreq core
> to register the cooling device on their behalf. This allows us to get
> rid of duplicated code in the drivers.
> 
> In order to allow this, we add a struct thermal_cooling_device pointer
> to struct cpufreq_policy so that drivers don't need to store it in a
> private data structure.
> 
> Suggested-by: Stephen Boyd <swboyd@chromium.org>
> Suggested-by: Viresh Kumar <viresh.kumar@linaro.org>
> Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
> Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
> Tested-by: Matthias Kaehlcke <mka@chromium.org>
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
>  drivers/cpufreq/cpufreq.c | 11 +++++++++++
>  include/linux/cpufreq.h   |  9 +++++++++
>  2 files changed, 20 insertions(+)

Thanks for the rework. This looks good now.

-- 
viresh

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

* Re: [PATCH] cpufreq: Auto-register the driver as a thermal cooling device if asked
  2019-01-30  5:22             ` [PATCH] " Amit Kucheria
  2019-01-30  6:34               ` Viresh Kumar
@ 2019-01-30  7:28               ` Daniel Lezcano
  1 sibling, 0 replies; 32+ messages in thread
From: Daniel Lezcano @ 2019-01-30  7:28 UTC (permalink / raw)
  To: Amit Kucheria, linux-kernel
  Cc: Rafael J. Wysocki, Viresh Kumar, Sudeep Holla, linux-pm

On 30/01/2019 06:22, Amit Kucheria wrote:
> All cpufreq drivers do similar things to register as a cooling device.
> Provide a cpufreq driver flag so drivers can just ask the cpufreq core
> to register the cooling device on their behalf. This allows us to get
> rid of duplicated code in the drivers.
> 
> In order to allow this, we add a struct thermal_cooling_device pointer
> to struct cpufreq_policy so that drivers don't need to store it in a
> private data structure.
> 
> Suggested-by: Stephen Boyd <swboyd@chromium.org>
> Suggested-by: Viresh Kumar <viresh.kumar@linaro.org>
> Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
> Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
> Tested-by: Matthias Kaehlcke <mka@chromium.org>
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>

[ ... ]

-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


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

* Re: [PATCH v5 1/9] thermal: cpu_cooling: Require thermal core to be compiled in
  2019-01-29  4:55 ` [PATCH v5 1/9] thermal: cpu_cooling: Require thermal core to be compiled in Amit Kucheria
@ 2019-01-30 23:53   ` Rafael J. Wysocki
  0 siblings, 0 replies; 32+ messages in thread
From: Rafael J. Wysocki @ 2019-01-30 23:53 UTC (permalink / raw)
  To: Amit Kucheria
  Cc: linux-kernel, Viresh Kumar, Zhang Rui, Eduardo Valentin,
	Daniel Lezcano, Sudeep Holla, Taniya Das, Anson Huang, linux-pm

On Tuesday, January 29, 2019 5:55:07 AM CET Amit Kucheria wrote:
> The CPU cooling driver (cpu_cooling.c) allows the platform's cpufreq
> driver to register as a cooling device and cool down the platform by
> throttling the CPU frequency. In order to be able to auto-register a
> cpufreq driver as a cooling device from the cpufreq core, we need access
> to code inside cpu_cooling.c which, in turn, accesses code inside
> thermal core.
> 
> CPU_FREQ is a bool while THERMAL is tristate.  In some configurations
> (e.g. allmodconfig), CONFIG_THERMAL ends up as a module while
> CONFIG_CPU_FREQ is compiled in. This leads to following error:
> 
> drivers/cpufreq/cpufreq.o: In function `cpufreq_offline':
> cpufreq.c:(.text+0x407c): undefined reference to `cpufreq_cooling_unregister'
> drivers/cpufreq/cpufreq.o: In function `cpufreq_online':
> cpufreq.c:(.text+0x70c0): undefined reference to `of_cpufreq_cooling_register'
> 
> Given that platforms using CPU_THERMAL usually want it compiled-in so it
> is available early in boot, make CPU_THERMAL depend on THERMAL being
> compiled-in instead of allowing it to be a module.
> 
> As a result of this change, get rid of the ugly (!CPU_THERMAL ||
> THERMAL) dependency in all cpufreq drivers using CPU_THERMAL.
> 
> Suggested-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
>  drivers/cpufreq/Kconfig     | 3 ---
>  drivers/cpufreq/Kconfig.arm | 5 -----
>  drivers/thermal/Kconfig     | 1 +
>  3 files changed, 1 insertion(+), 8 deletions(-)
> 
> diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig
> index 608af20a3494..b22e6bba71f1 100644
> --- a/drivers/cpufreq/Kconfig
> +++ b/drivers/cpufreq/Kconfig
> @@ -207,8 +207,6 @@ comment "CPU frequency scaling drivers"
>  config CPUFREQ_DT
>  	tristate "Generic DT based cpufreq driver"
>  	depends on HAVE_CLK && OF
> -	# if CPU_THERMAL is on and THERMAL=m, CPUFREQ_DT cannot be =y:
> -	depends on !CPU_THERMAL || THERMAL
>  	select CPUFREQ_DT_PLATDEV
>  	select PM_OPP
>  	help
> @@ -327,7 +325,6 @@ endif
>  config QORIQ_CPUFREQ
>  	tristate "CPU frequency scaling driver for Freescale QorIQ SoCs"
>  	depends on OF && COMMON_CLK && (PPC_E500MC || ARM || ARM64)
> -	depends on !CPU_THERMAL || THERMAL
>  	select CLK_QORIQ
>  	help
>  	  This adds the CPUFreq driver support for Freescale QorIQ SoCs
> diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm
> index 688f10227793..ca8567c3152c 100644
> --- a/drivers/cpufreq/Kconfig.arm
> +++ b/drivers/cpufreq/Kconfig.arm
> @@ -29,8 +29,6 @@ config ARM_ARMADA_37XX_CPUFREQ
>  config ARM_BIG_LITTLE_CPUFREQ
>  	tristate "Generic ARM big LITTLE CPUfreq driver"
>  	depends on ARM_CPU_TOPOLOGY && 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.
> @@ -38,7 +36,6 @@ config ARM_BIG_LITTLE_CPUFREQ
>  config ARM_SCPI_CPUFREQ
>  	tristate "SCPI based CPUfreq driver"
>  	depends on ARM_SCPI_PROTOCOL && COMMON_CLK_SCPI
> -	depends on !CPU_THERMAL || THERMAL
>  	help
>  	  This adds the CPUfreq driver support for ARM platforms using SCPI
>  	  protocol for CPU power management.
> @@ -93,7 +90,6 @@ config ARM_KIRKWOOD_CPUFREQ
>  config ARM_MEDIATEK_CPUFREQ
>  	tristate "CPU Frequency scaling support for MediaTek SoCs"
>  	depends on ARCH_MEDIATEK && REGULATOR
> -	depends on !CPU_THERMAL || THERMAL
>  	select PM_OPP
>  	help
>  	  This adds the CPUFreq driver support for MediaTek SoCs.
> @@ -233,7 +229,6 @@ config ARM_SA1110_CPUFREQ
>  config ARM_SCMI_CPUFREQ
>  	tristate "SCMI based CPUfreq driver"
>  	depends on ARM_SCMI_PROTOCOL || COMPILE_TEST
> -	depends on !CPU_THERMAL || THERMAL
>  	select PM_OPP
>  	help
>  	  This adds the CPUfreq driver support for ARM platforms using SCMI
> diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
> index 30323426902e..58bb7d72dc2b 100644
> --- a/drivers/thermal/Kconfig
> +++ b/drivers/thermal/Kconfig
> @@ -152,6 +152,7 @@ config CPU_THERMAL
>  	bool "generic cpu cooling support"
>  	depends on CPU_FREQ
>  	depends on THERMAL_OF
> +	depends on THERMAL=y
>  	help
>  	  This implements the generic cpu cooling mechanism through frequency
>  	  reduction. An ACPI version of this already exists
> 

Applied, thanks!



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

* Re: [PATCH v5 0/9] cpufreq: Add flag to auto-register as cooling device
  2019-01-29  4:55 ` Amit Kucheria
  (?)
@ 2019-02-06 10:32   ` Rafael J. Wysocki
  -1 siblings, 0 replies; 32+ messages in thread
From: Rafael J. Wysocki @ 2019-02-06 10:32 UTC (permalink / raw)
  To: Amit Kucheria
  Cc: linux-kernel, Daniel Lezcano, Eduardo Valentin, Matthias Brugger,
	Sudeep Holla, Viresh Kumar, Zhang Rui,
	moderated list:ARM/Mediatek SoC support,
	moderated list:ARM/Mediatek SoC support,
	open list:CPU FREQUENCY SCALING FRAMEWORK

On Tuesday, January 29, 2019 5:55:06 AM CET Amit Kucheria wrote:
> Add a flag for cpufreq drivers to tell cpufreq core to auto-register
> themselves as a thermal cooling device.
> 
> There series converts over all the drivers except arm_big_little.c.
> Tested on SDM845 with the qcom-cpufreq-hw driver. Only compile-tested the
> others.
> 
> Things needing fixing (but not a blocker for the series):
>  - Look at how to detect that we're not in IKS mode in arm_big_little's
>    .ready callback.
> 
> Changes since v4:
>  - Added IS_ENABLED guards in cpufreq.c
>  - Changed flag name to CPUFREQ_IS_COOLING_DEV
>  - Collected various review tags
> 
> Changes since v3:
>  - Got rid of wrapper function to register/unregister cooling devices.
>    Directly call the function in cpufreq.c
> 
> Changes since v2:
>  - Get rid of #ifdef'ery and let the pointer exist in all cases
>  - Get rid of (!CPU_THERMAL || THERMAL) dependency in all cpufreq drivers'
>    Kconfig
> 
> Changes since v1:
> - Fix compilation failures with allmodconfig
> - Get rid of #ifdef in cpufreq.c
> - Removed miscellaneous patches and sent them separately
> - Merged patches 1 and 2 from v1
> 
> Amit Kucheria (9):
>   thermal: cpu_cooling: Require thermal core to be compiled in
>   cpufreq: Auto-register the driver as a thermal cooling device if asked
>   cpufreq: qcom-hw: Register as a cpufreq cooling device
>   cpufreq: imx6q: Use auto-registration of thermal cooling device
>   cpufreq: cpufreq-dt: Use auto-registration of thermal cooling device
>   cpufreq: mediatek: Use auto-registration of thermal cooling device
>   cpufreq: qoriq: Use auto-registration of thermal cooling device
>   cpufreq: scmi: Use auto-registration of thermal cooling device
>   cpufreq: scpi: Use auto-registration of thermal cooling device
> 
>  drivers/cpufreq/Kconfig            |  3 ---
>  drivers/cpufreq/Kconfig.arm        |  5 -----
>  drivers/cpufreq/cpufreq-dt.c       | 14 ++------------
>  drivers/cpufreq/cpufreq.c          | 13 +++++++++++++
>  drivers/cpufreq/imx6q-cpufreq.c    | 24 ++----------------------
>  drivers/cpufreq/mediatek-cpufreq.c | 14 ++------------
>  drivers/cpufreq/qcom-cpufreq-hw.c  |  3 ++-
>  drivers/cpufreq/qoriq-cpufreq.c    | 15 ++-------------
>  drivers/cpufreq/scmi-cpufreq.c     | 14 ++------------
>  drivers/cpufreq/scpi-cpufreq.c     | 14 ++------------
>  drivers/thermal/Kconfig            |  1 +
>  include/linux/cpufreq.h            |  9 +++++++++
>  12 files changed, 37 insertions(+), 92 deletions(-)
> 
> 

I've applied the series, thanks!



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

* Re: [PATCH v5 0/9] cpufreq: Add flag to auto-register as cooling device
@ 2019-02-06 10:32   ` Rafael J. Wysocki
  0 siblings, 0 replies; 32+ messages in thread
From: Rafael J. Wysocki @ 2019-02-06 10:32 UTC (permalink / raw)
  To: Amit Kucheria
  Cc: linux-kernel, Daniel Lezcano, Eduardo Valentin, Matthias Brugger,
	Sudeep Holla, Viresh Kumar, Zhang Rui,
	moderated list:ARM/Mediatek SoC support,
	moderated list:ARM/Mediatek SoC support,
	open list:CPU FREQUENCY SCALING FRAMEWORK

On Tuesday, January 29, 2019 5:55:06 AM CET Amit Kucheria wrote:
> Add a flag for cpufreq drivers to tell cpufreq core to auto-register
> themselves as a thermal cooling device.
> 
> There series converts over all the drivers except arm_big_little.c.
> Tested on SDM845 with the qcom-cpufreq-hw driver. Only compile-tested the
> others.
> 
> Things needing fixing (but not a blocker for the series):
>  - Look at how to detect that we're not in IKS mode in arm_big_little's
>    .ready callback.
> 
> Changes since v4:
>  - Added IS_ENABLED guards in cpufreq.c
>  - Changed flag name to CPUFREQ_IS_COOLING_DEV
>  - Collected various review tags
> 
> Changes since v3:
>  - Got rid of wrapper function to register/unregister cooling devices.
>    Directly call the function in cpufreq.c
> 
> Changes since v2:
>  - Get rid of #ifdef'ery and let the pointer exist in all cases
>  - Get rid of (!CPU_THERMAL || THERMAL) dependency in all cpufreq drivers'
>    Kconfig
> 
> Changes since v1:
> - Fix compilation failures with allmodconfig
> - Get rid of #ifdef in cpufreq.c
> - Removed miscellaneous patches and sent them separately
> - Merged patches 1 and 2 from v1
> 
> Amit Kucheria (9):
>   thermal: cpu_cooling: Require thermal core to be compiled in
>   cpufreq: Auto-register the driver as a thermal cooling device if asked
>   cpufreq: qcom-hw: Register as a cpufreq cooling device
>   cpufreq: imx6q: Use auto-registration of thermal cooling device
>   cpufreq: cpufreq-dt: Use auto-registration of thermal cooling device
>   cpufreq: mediatek: Use auto-registration of thermal cooling device
>   cpufreq: qoriq: Use auto-registration of thermal cooling device
>   cpufreq: scmi: Use auto-registration of thermal cooling device
>   cpufreq: scpi: Use auto-registration of thermal cooling device
> 
>  drivers/cpufreq/Kconfig            |  3 ---
>  drivers/cpufreq/Kconfig.arm        |  5 -----
>  drivers/cpufreq/cpufreq-dt.c       | 14 ++------------
>  drivers/cpufreq/cpufreq.c          | 13 +++++++++++++
>  drivers/cpufreq/imx6q-cpufreq.c    | 24 ++----------------------
>  drivers/cpufreq/mediatek-cpufreq.c | 14 ++------------
>  drivers/cpufreq/qcom-cpufreq-hw.c  |  3 ++-
>  drivers/cpufreq/qoriq-cpufreq.c    | 15 ++-------------
>  drivers/cpufreq/scmi-cpufreq.c     | 14 ++------------
>  drivers/cpufreq/scpi-cpufreq.c     | 14 ++------------
>  drivers/thermal/Kconfig            |  1 +
>  include/linux/cpufreq.h            |  9 +++++++++
>  12 files changed, 37 insertions(+), 92 deletions(-)
> 
> 

I've applied the series, thanks!

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

* Re: [PATCH v5 0/9] cpufreq: Add flag to auto-register as cooling device
@ 2019-02-06 10:32   ` Rafael J. Wysocki
  0 siblings, 0 replies; 32+ messages in thread
From: Rafael J. Wysocki @ 2019-02-06 10:32 UTC (permalink / raw)
  To: Amit Kucheria
  Cc: open list:CPU FREQUENCY SCALING FRAMEWORK, Viresh Kumar,
	Daniel Lezcano, linux-kernel, Eduardo Valentin,
	moderated list:ARM/Mediatek SoC support, Sudeep Holla,
	Matthias Brugger, Zhang Rui,
	moderated list:ARM/Mediatek SoC support

On Tuesday, January 29, 2019 5:55:06 AM CET Amit Kucheria wrote:
> Add a flag for cpufreq drivers to tell cpufreq core to auto-register
> themselves as a thermal cooling device.
> 
> There series converts over all the drivers except arm_big_little.c.
> Tested on SDM845 with the qcom-cpufreq-hw driver. Only compile-tested the
> others.
> 
> Things needing fixing (but not a blocker for the series):
>  - Look at how to detect that we're not in IKS mode in arm_big_little's
>    .ready callback.
> 
> Changes since v4:
>  - Added IS_ENABLED guards in cpufreq.c
>  - Changed flag name to CPUFREQ_IS_COOLING_DEV
>  - Collected various review tags
> 
> Changes since v3:
>  - Got rid of wrapper function to register/unregister cooling devices.
>    Directly call the function in cpufreq.c
> 
> Changes since v2:
>  - Get rid of #ifdef'ery and let the pointer exist in all cases
>  - Get rid of (!CPU_THERMAL || THERMAL) dependency in all cpufreq drivers'
>    Kconfig
> 
> Changes since v1:
> - Fix compilation failures with allmodconfig
> - Get rid of #ifdef in cpufreq.c
> - Removed miscellaneous patches and sent them separately
> - Merged patches 1 and 2 from v1
> 
> Amit Kucheria (9):
>   thermal: cpu_cooling: Require thermal core to be compiled in
>   cpufreq: Auto-register the driver as a thermal cooling device if asked
>   cpufreq: qcom-hw: Register as a cpufreq cooling device
>   cpufreq: imx6q: Use auto-registration of thermal cooling device
>   cpufreq: cpufreq-dt: Use auto-registration of thermal cooling device
>   cpufreq: mediatek: Use auto-registration of thermal cooling device
>   cpufreq: qoriq: Use auto-registration of thermal cooling device
>   cpufreq: scmi: Use auto-registration of thermal cooling device
>   cpufreq: scpi: Use auto-registration of thermal cooling device
> 
>  drivers/cpufreq/Kconfig            |  3 ---
>  drivers/cpufreq/Kconfig.arm        |  5 -----
>  drivers/cpufreq/cpufreq-dt.c       | 14 ++------------
>  drivers/cpufreq/cpufreq.c          | 13 +++++++++++++
>  drivers/cpufreq/imx6q-cpufreq.c    | 24 ++----------------------
>  drivers/cpufreq/mediatek-cpufreq.c | 14 ++------------
>  drivers/cpufreq/qcom-cpufreq-hw.c  |  3 ++-
>  drivers/cpufreq/qoriq-cpufreq.c    | 15 ++-------------
>  drivers/cpufreq/scmi-cpufreq.c     | 14 ++------------
>  drivers/cpufreq/scpi-cpufreq.c     | 14 ++------------
>  drivers/thermal/Kconfig            |  1 +
>  include/linux/cpufreq.h            |  9 +++++++++
>  12 files changed, 37 insertions(+), 92 deletions(-)
> 
> 

I've applied the series, thanks!



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v5 6/9] cpufreq: mediatek: Use auto-registration of thermal cooling device
  2019-01-29  4:55   ` Amit Kucheria
@ 2019-02-06 13:55     ` Matthias Brugger
  -1 siblings, 0 replies; 32+ messages in thread
From: Matthias Brugger @ 2019-02-06 13:55 UTC (permalink / raw)
  To: Amit Kucheria, linux-kernel
  Cc: Rafael J. Wysocki, Viresh Kumar, Daniel Lezcano, Sean Wang,
	linux-pm, linux-arm-kernel, linux-mediatek



On 29/01/2019 05:55, Amit Kucheria wrote:
> Use the CPUFREQ_IS_COOLING_DEV flag to allow cpufreq core to
> automatically register as a thermal cooling device.
> 
> This allows removal of boiler plate code from the driver.
> 
> Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
> Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>

Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>

> ---
>  drivers/cpufreq/mediatek-cpufreq.c | 14 ++------------
>  1 file changed, 2 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/cpufreq/mediatek-cpufreq.c b/drivers/cpufreq/mediatek-cpufreq.c
> index eb8920d39818..4229fcc31310 100644
> --- a/drivers/cpufreq/mediatek-cpufreq.c
> +++ b/drivers/cpufreq/mediatek-cpufreq.c
> @@ -14,7 +14,6 @@
>  
>  #include <linux/clk.h>
>  #include <linux/cpu.h>
> -#include <linux/cpu_cooling.h>
>  #include <linux/cpufreq.h>
>  #include <linux/cpumask.h>
>  #include <linux/module.h>
> @@ -48,7 +47,6 @@ struct mtk_cpu_dvfs_info {
>  	struct regulator *sram_reg;
>  	struct clk *cpu_clk;
>  	struct clk *inter_clk;
> -	struct thermal_cooling_device *cdev;
>  	struct list_head list_head;
>  	int intermediate_voltage;
>  	bool need_voltage_tracking;
> @@ -307,13 +305,6 @@ static int mtk_cpufreq_set_target(struct cpufreq_policy *policy,
>  
>  #define DYNAMIC_POWER "dynamic-power-coefficient"
>  
> -static void mtk_cpufreq_ready(struct cpufreq_policy *policy)
> -{
> -	struct mtk_cpu_dvfs_info *info = policy->driver_data;
> -
> -	info->cdev = of_cpufreq_cooling_register(policy);
> -}
> -
>  static int mtk_cpu_dvfs_info_init(struct mtk_cpu_dvfs_info *info, int cpu)
>  {
>  	struct device *cpu_dev;
> @@ -472,7 +463,6 @@ static int mtk_cpufreq_exit(struct cpufreq_policy *policy)
>  {
>  	struct mtk_cpu_dvfs_info *info = policy->driver_data;
>  
> -	cpufreq_cooling_unregister(info->cdev);
>  	dev_pm_opp_free_cpufreq_table(info->cpu_dev, &policy->freq_table);
>  
>  	return 0;
> @@ -480,13 +470,13 @@ static int mtk_cpufreq_exit(struct cpufreq_policy *policy)
>  
>  static struct cpufreq_driver mtk_cpufreq_driver = {
>  	.flags = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK |
> -		 CPUFREQ_HAVE_GOVERNOR_PER_POLICY,
> +		 CPUFREQ_HAVE_GOVERNOR_PER_POLICY |
> +		 CPUFREQ_IS_COOLING_DEV,
>  	.verify = cpufreq_generic_frequency_table_verify,
>  	.target_index = mtk_cpufreq_set_target,
>  	.get = cpufreq_generic_get,
>  	.init = mtk_cpufreq_init,
>  	.exit = mtk_cpufreq_exit,
> -	.ready = mtk_cpufreq_ready,
>  	.name = "mtk-cpufreq",
>  	.attr = cpufreq_generic_attr,
>  };
> 

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

* Re: [PATCH v5 6/9] cpufreq: mediatek: Use auto-registration of thermal cooling device
@ 2019-02-06 13:55     ` Matthias Brugger
  0 siblings, 0 replies; 32+ messages in thread
From: Matthias Brugger @ 2019-02-06 13:55 UTC (permalink / raw)
  To: Amit Kucheria, linux-kernel
  Cc: Sean Wang, linux-pm, Viresh Kumar, Daniel Lezcano,
	Rafael J. Wysocki, linux-mediatek, linux-arm-kernel



On 29/01/2019 05:55, Amit Kucheria wrote:
> Use the CPUFREQ_IS_COOLING_DEV flag to allow cpufreq core to
> automatically register as a thermal cooling device.
> 
> This allows removal of boiler plate code from the driver.
> 
> Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
> Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>

Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>

> ---
>  drivers/cpufreq/mediatek-cpufreq.c | 14 ++------------
>  1 file changed, 2 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/cpufreq/mediatek-cpufreq.c b/drivers/cpufreq/mediatek-cpufreq.c
> index eb8920d39818..4229fcc31310 100644
> --- a/drivers/cpufreq/mediatek-cpufreq.c
> +++ b/drivers/cpufreq/mediatek-cpufreq.c
> @@ -14,7 +14,6 @@
>  
>  #include <linux/clk.h>
>  #include <linux/cpu.h>
> -#include <linux/cpu_cooling.h>
>  #include <linux/cpufreq.h>
>  #include <linux/cpumask.h>
>  #include <linux/module.h>
> @@ -48,7 +47,6 @@ struct mtk_cpu_dvfs_info {
>  	struct regulator *sram_reg;
>  	struct clk *cpu_clk;
>  	struct clk *inter_clk;
> -	struct thermal_cooling_device *cdev;
>  	struct list_head list_head;
>  	int intermediate_voltage;
>  	bool need_voltage_tracking;
> @@ -307,13 +305,6 @@ static int mtk_cpufreq_set_target(struct cpufreq_policy *policy,
>  
>  #define DYNAMIC_POWER "dynamic-power-coefficient"
>  
> -static void mtk_cpufreq_ready(struct cpufreq_policy *policy)
> -{
> -	struct mtk_cpu_dvfs_info *info = policy->driver_data;
> -
> -	info->cdev = of_cpufreq_cooling_register(policy);
> -}
> -
>  static int mtk_cpu_dvfs_info_init(struct mtk_cpu_dvfs_info *info, int cpu)
>  {
>  	struct device *cpu_dev;
> @@ -472,7 +463,6 @@ static int mtk_cpufreq_exit(struct cpufreq_policy *policy)
>  {
>  	struct mtk_cpu_dvfs_info *info = policy->driver_data;
>  
> -	cpufreq_cooling_unregister(info->cdev);
>  	dev_pm_opp_free_cpufreq_table(info->cpu_dev, &policy->freq_table);
>  
>  	return 0;
> @@ -480,13 +470,13 @@ static int mtk_cpufreq_exit(struct cpufreq_policy *policy)
>  
>  static struct cpufreq_driver mtk_cpufreq_driver = {
>  	.flags = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK |
> -		 CPUFREQ_HAVE_GOVERNOR_PER_POLICY,
> +		 CPUFREQ_HAVE_GOVERNOR_PER_POLICY |
> +		 CPUFREQ_IS_COOLING_DEV,
>  	.verify = cpufreq_generic_frequency_table_verify,
>  	.target_index = mtk_cpufreq_set_target,
>  	.get = cpufreq_generic_get,
>  	.init = mtk_cpufreq_init,
>  	.exit = mtk_cpufreq_exit,
> -	.ready = mtk_cpufreq_ready,
>  	.name = "mtk-cpufreq",
>  	.attr = cpufreq_generic_attr,
>  };
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2019-02-06 13:55 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-29  4:55 [PATCH v5 0/9] cpufreq: Add flag to auto-register as cooling device Amit Kucheria
2019-01-29  4:55 ` Amit Kucheria
2019-01-29  4:55 ` Amit Kucheria
2019-01-29  4:55 ` [PATCH v5 1/9] thermal: cpu_cooling: Require thermal core to be compiled in Amit Kucheria
2019-01-30 23:53   ` Rafael J. Wysocki
2019-01-29  4:55 ` [PATCH v5 2/9] cpufreq: Auto-register the driver as a thermal cooling device if asked Amit Kucheria
2019-01-29  5:36   ` Viresh Kumar
2019-01-29  5:46     ` Amit Kucheria
2019-01-29  6:20       ` Amit Kucheria
2019-01-29  7:09         ` Viresh Kumar
2019-01-29  9:16           ` Rafael J. Wysocki
2019-01-29  9:13       ` Rafael J. Wysocki
2019-01-29 20:20         ` Amit Kucheria
2019-01-29 22:22           ` Rafael J. Wysocki
2019-01-30  5:22             ` [PATCH] " Amit Kucheria
2019-01-30  6:34               ` Viresh Kumar
2019-01-30  7:28               ` Daniel Lezcano
2019-01-29  4:55 ` [PATCH v5 3/9] cpufreq: qcom-hw: Register as a cpufreq cooling device Amit Kucheria
2019-01-29  4:55 ` [PATCH v5 4/9] cpufreq: imx6q: Use auto-registration of thermal " Amit Kucheria
2019-01-29  4:55 ` [PATCH v5 5/9] cpufreq: cpufreq-dt: " Amit Kucheria
2019-01-29  4:55 ` [PATCH v5 6/9] cpufreq: mediatek: " Amit Kucheria
2019-01-29  4:55   ` Amit Kucheria
2019-02-06 13:55   ` Matthias Brugger
2019-02-06 13:55     ` Matthias Brugger
2019-01-29  4:55 ` [PATCH v5 7/9] cpufreq: qoriq: " Amit Kucheria
2019-01-29  4:55 ` [PATCH v5 8/9] cpufreq: scmi: " Amit Kucheria
2019-01-29  4:55   ` Amit Kucheria
2019-01-29  4:55 ` [PATCH v5 9/9] cpufreq: scpi: " Amit Kucheria
2019-01-29  4:55   ` Amit Kucheria
2019-02-06 10:32 ` [PATCH v5 0/9] cpufreq: Add flag to auto-register as " Rafael J. Wysocki
2019-02-06 10:32   ` Rafael J. Wysocki
2019-02-06 10:32   ` Rafael J. Wysocki

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.