* [RFC PATCH 0/2] thermal: Add generic devfreq cooling device
@ 2015-07-16 12:02 Chanwoo Choi
2015-07-16 12:02 ` [RFC PATCH 1/2] PM: devfreq: Add the prototype of update_devfreq() to export Chanwoo Choi
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Chanwoo Choi @ 2015-07-16 12:02 UTC (permalink / raw)
To: edubezval, rui.zhang, myungjoo.ham, kyungmin.park
Cc: ulf.hansson, khilman, robh+dt, pawel.moll, mark.rutland,
ijc+devicetree, inki.dae, l.majewski, cw00.choi, kgene.kim,
linux-pm, linux-kernel, devicetree
This patchset introduce the generic devfreq cooling device for generic thermal
framework. The devfreq devices are used ad cooling device to reduce the
overheating temperature. This patch is based on drivers/thermal/cpu_cooling.c.
The devfreq cooling device can change the ragne of the frequency table of
devfreq device according to cooling level in device tree file.
To verify the devfreq cooling device driver, I testd it with following platform:
For example,
- The Mali GPU of Exynos5433 SoC uses the devfreq framework to support the DVFS
feature and Exynos5433 contains the G3D (GPU) thermal sensor. Following example
explain the correlation between mali dt node and thermal sensor/zone.
: thermal sensor : G3D sensor of Samsung Exynos5433 [1][2]
: devfreq cooling device : Mali GPU [3]
According to the temperature of g3d thermal sensor inclued in Exynos5433,
devfreq cooling device can change the maximum frequency of Mali GPU.
1. In Exynos5433-based board dts file, Mali GPU dt node uses the devfreq
framework to suppot the DVFS feature. Following dt node includes the
both 'cooling-cells' and 'operating-points' which means the supported
frequency entries:
mali: mali@14AC0000 {
compatible = "arm,mali-midgard";
reg = <0x14AC0000 0x5000>;
interrupts = <0 282 0>, <0 283 0>, <0 281 0>;
interrupt-names = "JOB", "MMU", "GPU";
clocks = <&cmu_g3d CLK_ACLK_G3D>;
clock-names = "clk_mali";
power-domains = <&pd_g3d>;
status = "disabled";
#cooling-cells = <2>;
operating-points = <
700000 1150000
600000 1150000
550000 1125000
500000 1075000
420000 1025000
350000 1025000
266000 1000000
160000 1000000
>;
};
2. In exynos5433.dtsi, G3D thermal sensor measure the temperature of Mali GPU:
tmu_g3d: tmu@10070000 {
compatible = "samsung,exynos5433-tmu";
reg = <0x10070000 0x200>;
interrupts = <0 99 0>;
clocks = <&cmu_peris CLK_PCLK_TMU1_APBIF>,
<&cmu_peris CLK_SCLK_TMU1>;
clock-names = "tmu_apbif", "tmu_sclk";
#include "exynos5433-tmu-sensor-conf.dtsi"
status = "disabled";
};
3. In exynos5433-tmu.dtsi, thermal-zones includes both trip points and
cooling-maps of g3d thermal sensor. Following cooling-maps show the match
between each trip point and each cooling device (devfreq device of mali):
thermal-zones {
/* ...... */
g3d_thermal: g3d-thermal {
thermal-sensors = <&tmu_g3d>;
polling-delay-passive = <0>;
polling-delay = <0>;
trips {
g3d_alert_0: g3d-alert-0 {
temperature = <30000>; /* millicelsius */
hysteresis = <10000>; /* millicelsius */
type = "active";
};
g3d_alert_1: g3d-alert-1 {
temperature = <40000>; /* millicelsius */
hysteresis = <10000>; /* millicelsius */
type = "active";
};
/* ...... */
};
cooling-maps {
map0 {
/* Set maximum frequency as 550MHz */
trip = <&g3d_alert_0>;
cooling-device = <&mali 2 2>;
};
map1 {
/* Set maximum frequency as 420MHz */
trip = <&g3d_alert_1>;
cooling-device = <&mali 4 4>;
};
/* ...... */
};
};
......
};
[1] https://git.kernel.org/cgit/linux/kernel/git/kgene/linux-samsung.git/commit/?h=v4.3-next/dt64-samsung&id=ac008f6b537703bb9a6fcc3882ca4af3331aa24f
[2] https://git.kernel.org/cgit/linux/kernel/git/kgene/linux-samsung.git/commit/?h=v4.3-next/dt64-samsung&id=bcddc3a84e49ca1c646cf2081687a544a15f9218
[3] malideveloper.arm.com/downloads/drivers/TX041/r5p0-06rel0/TX041-SW-99002-r5p0-06rel0.tgz
Chanwoo Choi (2):
PM: devfreq: Add the prototype of update_devfreq() to export
thermal: devfreq_cooling: Add generic devfreq cooling device implementaion
.../devicetree/bindings/thermal/thermal.txt | 8 +-
drivers/devfreq/devfreq.c | 22 +-
drivers/thermal/Kconfig | 11 +
drivers/thermal/Makefile | 3 +
drivers/thermal/devfreq-cooling.c | 309 +++++++++++++++++++++
include/linux/devfreq-cooling.h | 80 ++++++
include/linux/devfreq.h | 7 +
7 files changed, 425 insertions(+), 15 deletions(-)
create mode 100644 drivers/thermal/devfreq-cooling.c
create mode 100644 include/linux/devfreq-cooling.h
--
1.8.5.5
^ permalink raw reply [flat|nested] 9+ messages in thread
* [RFC PATCH 1/2] PM: devfreq: Add the prototype of update_devfreq() to export
2015-07-16 12:02 [RFC PATCH 0/2] thermal: Add generic devfreq cooling device Chanwoo Choi
@ 2015-07-16 12:02 ` Chanwoo Choi
2015-07-16 12:02 ` [RFC PATCH 2/2] thermal: devfreq_cooling: Add generic devfreq cooling device implementaion Chanwoo Choi
2015-07-17 10:53 ` [RFC PATCH 0/2] thermal: Add generic devfreq cooling device Punit Agrawal
2 siblings, 0 replies; 9+ messages in thread
From: Chanwoo Choi @ 2015-07-16 12:02 UTC (permalink / raw)
To: edubezval, rui.zhang, myungjoo.ham, kyungmin.park
Cc: ulf.hansson, khilman, robh+dt, pawel.moll, mark.rutland,
ijc+devicetree, inki.dae, l.majewski, cw00.choi, kgene.kim,
linux-pm, linux-kernel, devicetree
This patch add simply the protoptye of update_devfreq() to devfreq.h header
file to export it. The some device driver (e.g., thermal cooling device) may
use the update_devfreq() to update the range of supported frequency of devfreq
device.
Cc: MyungJoo Ham <myungjoo.ham@samsung.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
---
drivers/devfreq/devfreq.c | 22 +++++++++++-----------
include/linux/devfreq.h | 7 +++++++
2 files changed, 18 insertions(+), 11 deletions(-)
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index ca1b362d77e2..2aa5e4e9df36 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -163,18 +163,17 @@ int update_devfreq(struct devfreq *devfreq)
int err = 0;
u32 flags = 0;
- if (!mutex_is_locked(&devfreq->lock)) {
- WARN(true, "devfreq->lock must be locked by the caller.\n");
- return -EINVAL;
- }
-
if (!devfreq->governor)
return -EINVAL;
+ mutex_lock(&devfreq->lock);
+
/* Reevaluate the proper frequency */
err = devfreq->governor->get_target_freq(devfreq, &freq);
- if (err)
+ if (err) {
+ mutex_unlock(&devfreq->lock);
return err;
+ }
/*
* Adjust the freuqency with user freq and QoS.
@@ -194,8 +193,10 @@ int update_devfreq(struct devfreq *devfreq)
}
err = devfreq->profile->target(devfreq->dev.parent, &freq, flags);
- if (err)
+ if (err) {
+ mutex_unlock(&devfreq->lock);
return err;
+ }
if (devfreq->profile->freq_table)
if (devfreq_update_status(devfreq, freq))
@@ -203,6 +204,9 @@ int update_devfreq(struct devfreq *devfreq)
"Couldn't update frequency transition information.\n");
devfreq->previous_freq = freq;
+
+ mutex_unlock(&devfreq->lock);
+
return err;
}
EXPORT_SYMBOL(update_devfreq);
@@ -218,14 +222,12 @@ static void devfreq_monitor(struct work_struct *work)
struct devfreq *devfreq = container_of(work,
struct devfreq, work.work);
- mutex_lock(&devfreq->lock);
err = update_devfreq(devfreq);
if (err)
dev_err(&devfreq->dev, "dvfs failed with (%d) error\n", err);
queue_delayed_work(devfreq_wq, &devfreq->work,
msecs_to_jiffies(devfreq->profile->polling_ms));
- mutex_unlock(&devfreq->lock);
}
/**
@@ -382,9 +384,7 @@ static int devfreq_notifier_call(struct notifier_block *nb, unsigned long type,
struct devfreq *devfreq = container_of(nb, struct devfreq, nb);
int ret;
- mutex_lock(&devfreq->lock);
ret = update_devfreq(devfreq);
- mutex_unlock(&devfreq->lock);
return ret;
}
diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
index ce447f0f1bad..07da551f2709 100644
--- a/include/linux/devfreq.h
+++ b/include/linux/devfreq.h
@@ -204,6 +204,8 @@ extern int devm_devfreq_register_opp_notifier(struct device *dev,
extern void devm_devfreq_unregister_opp_notifier(struct device *dev,
struct devfreq *devfreq);
+extern int update_devfreq(struct devfreq *devfreq);
+
#if IS_ENABLED(CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND)
/**
* struct devfreq_simple_ondemand_data - void *data fed to struct devfreq
@@ -289,6 +291,11 @@ static inline void devm_devfreq_unregister_opp_notifier(struct device *dev,
struct devfreq *devfreq)
{
}
+
+static inline int update_devfreq(struct devfreq *devfreq)
+{
+ return 0;
+}
#endif /* CONFIG_PM_DEVFREQ */
#endif /* __LINUX_DEVFREQ_H__ */
--
1.8.5.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [RFC PATCH 2/2] thermal: devfreq_cooling: Add generic devfreq cooling device implementaion
2015-07-16 12:02 [RFC PATCH 0/2] thermal: Add generic devfreq cooling device Chanwoo Choi
2015-07-16 12:02 ` [RFC PATCH 1/2] PM: devfreq: Add the prototype of update_devfreq() to export Chanwoo Choi
@ 2015-07-16 12:02 ` Chanwoo Choi
2015-07-17 10:53 ` [RFC PATCH 0/2] thermal: Add generic devfreq cooling device Punit Agrawal
2 siblings, 0 replies; 9+ messages in thread
From: Chanwoo Choi @ 2015-07-16 12:02 UTC (permalink / raw)
To: edubezval, rui.zhang, myungjoo.ham, kyungmin.park
Cc: ulf.hansson, khilman, robh+dt, pawel.moll, mark.rutland,
ijc+devicetree, inki.dae, l.majewski, cw00.choi, kgene.kim,
linux-pm, linux-kernel, devicetree
This patch add the generi devfreq cooling device for generic thermal framework.
The devfreq devices are used ad cooling device to reduce the overheating
temperature. This patch is based on drivers/thermal/cpu_cooling.c. The devfreq
cooling device can change the ragne of the frequency table of devfreq device
according to cooling level in device tree file.
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Eduardo Valentin <edubezval@gmail.com>
Cc: MyungJoo Ham <myungjoo.ham@samsung.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
---
.../devicetree/bindings/thermal/thermal.txt | 8 +-
drivers/thermal/Kconfig | 11 +
drivers/thermal/Makefile | 3 +
drivers/thermal/devfreq-cooling.c | 309 +++++++++++++++++++++
include/linux/devfreq-cooling.h | 80 ++++++
5 files changed, 407 insertions(+), 4 deletions(-)
create mode 100644 drivers/thermal/devfreq-cooling.c
create mode 100644 include/linux/devfreq-cooling.h
diff --git a/Documentation/devicetree/bindings/thermal/thermal.txt b/Documentation/devicetree/bindings/thermal/thermal.txt
index 8a49362dea6e..4201fb606cb2 100644
--- a/Documentation/devicetree/bindings/thermal/thermal.txt
+++ b/Documentation/devicetree/bindings/thermal/thermal.txt
@@ -43,10 +43,10 @@ Required property:
Cooling devices are nodes providing control on power dissipation. There
are essentially two ways to provide control on power dissipation. First
is by means of regulating device performance, which is known as passive
-cooling. A typical passive cooling is a CPU that has dynamic voltage and
-frequency scaling (DVFS), and uses lower frequencies as cooling states.
-Second is by means of activating devices in order to remove
-the dissipated heat, which is known as active cooling, e.g. regulating
+cooling. A typical passive cooling is a CPU and Devfreq device that has
+dynamic voltage and frequency scaling (DVFS), and uses lower frequencies
+as cooling states. Second is by means of activating devices in order to
+remove the dissipated heat, which is known as active cooling, e.g. regulating
fan speeds. In both cases, cooling devices shall have a way to determine
the state of cooling in which the device is.
diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index 118938ee8552..764502d83de7 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -137,6 +137,17 @@ config CPU_THERMAL
If you want this support, you should say Y here.
+config DEVFREQ_THERMAL
+ bool "generic devfreq cooling support"
+ depends on PM_DEVFREQ
+ depends on THERMAL_OF
+ help
+ This implements the generic devfreq cooling mechanism through frequency
+ reduction. This will be useful for platforms using the generic thermal
+ interface.
+
+ If you want this support, you should say Y here.
+
config CLOCK_THERMAL
bool "Generic clock cooling support"
depends on COMMON_CLK
diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
index 535dfee1496f..c5ca0cc3ff95 100644
--- a/drivers/thermal/Makefile
+++ b/drivers/thermal/Makefile
@@ -19,6 +19,9 @@ thermal_sys-$(CONFIG_THERMAL_GOV_POWER_ALLOCATOR) += power_allocator.o
# cpufreq cooling
thermal_sys-$(CONFIG_CPU_THERMAL) += cpu_cooling.o
+# devfreq cooling
+thermal_sys-$(CONFIG_DEVFREQ_THERMAL) += devfreq-cooling.o
+
# clock cooling
thermal_sys-$(CONFIG_CLOCK_THERMAL) += clock_cooling.o
diff --git a/drivers/thermal/devfreq-cooling.c b/drivers/thermal/devfreq-cooling.c
new file mode 100644
index 000000000000..c2fb2160189a
--- /dev/null
+++ b/drivers/thermal/devfreq-cooling.c
@@ -0,0 +1,309 @@
+/*
+ * linux/drivers/thermal/devfreq-cooling.c
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd
+ * Author: Chanwoo Choi <cw00.choi@samsung.com>
+ *
+ * This driver is based on drivers/thermal/cpu_cooling.c.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+#include <linux/module.h>
+#include <linux/err.h>
+#include <linux/slab.h>
+#include <linux/thermal.h>
+#include <linux/devfreq.h>
+#include <linux/devfreq-cooling.h>
+
+/*
+ * Cooling state <-> devfreq frequency
+ *
+ * Cooling states are translated to frequencies throughout this driver and this
+ * is the relation between them.
+ *
+ * Highest cooling state corresponds to lowest possible frequency.
+ *
+ * i.e.
+ * level 0 --> 1st Max Freq
+ * level 1 --> 2nd Max Freq
+ * ...
+ */
+
+/**
+ * struct devfreq_cooling_device - data for cooling device with devfreq
+ * @cool_dev: thermal_cooling_device pointer to keep track of the
+ * registered cooling device.
+ * @devfreq: the devfreq instance.
+ * @cur_state: integer value representing the current state of devfreq
+ * cooling devices.
+ * @max_state: interger value representing the maximum state of devfreq
+ * cooling devices.
+ *
+ * This structure is required for keeping information of each registered
+ * devfreq_cooling_device.
+ */
+struct devfreq_cooling_device {
+ struct thermal_cooling_device *cool_dev;
+ struct devfreq *devfreq;
+
+ unsigned int cur_state;
+ unsigned int max_state;
+
+ unsigned int *freq_table; /* In descending order */
+};
+
+/* devfreq cooling device callback functions are defined below */
+
+/**
+ * devfreq_get_max_state - callback function to get the max cooling state.
+ * @cdev: thermal cooling device pointer.
+ * @state: fill this variable with the max cooling state.
+ *
+ * Callback for the thermal cooling device to return the devfreq
+ * max cooling state.
+ *
+ * Return: 0 on success, an error code otherwise.
+ */
+static int devfreq_get_max_state(struct thermal_cooling_device *cdev,
+ unsigned long *state)
+{
+ struct devfreq_cooling_device *devfreq_device = cdev->devdata;
+
+ *state = devfreq_device->max_state;
+
+ return 0;
+}
+
+/**
+ * devfreq_get_cur_state - callback function to get the current cooling state.
+ * @cdev: thermal cooling device pointer.
+ * @state: fill this variable with the current cooling state.
+ *
+ * Callback for the thermal cooling device to return the devfreq
+ * current cooling state.
+ *
+ * Return: 0 on success, an error code otherwise.
+ */
+static int devfreq_get_cur_state(struct thermal_cooling_device *cdev,
+ unsigned long *state)
+{
+ struct devfreq_cooling_device *devfreq_device = cdev->devdata;
+
+ *state = devfreq_device->cur_state;
+
+ return 0;
+}
+
+/**
+ * devfreq_set_cur_state - callback function to set the current cooling state.
+ * @cdev: thermal cooling device pointer.
+ * @state: set this variable to the current cooling state.
+ *
+ * Callback for the thermal cooling device to change the devfreq
+ * current cooling state.
+ *
+ * Return: 0 on success, an error code otherwise.
+ */
+static int devfreq_set_cur_state(struct thermal_cooling_device *cdev,
+ unsigned long state)
+{
+ struct devfreq_cooling_device *devfreq_dev = cdev->devdata;
+ unsigned int limited_freq;
+
+ /* Request state should be less than max_level */
+ if (WARN_ON(state > devfreq_dev->max_state))
+ return -EINVAL;
+
+ /* Check if the old cooling action is same as new cooling action */
+ if (devfreq_dev->cur_state == state)
+ return 0;
+
+ limited_freq = devfreq_dev->freq_table[state];
+
+ devfreq_dev->cur_state = state;
+
+ /* Set the limited frequency to maximum frequency of devfreq */
+ devfreq_dev->devfreq->max_freq = limited_freq;
+
+ return 0;
+}
+
+/* Bind devfreq callbacks to thermal cooling device ops */
+static struct thermal_cooling_device_ops const devfreq_cooling_ops = {
+ .get_max_state = devfreq_get_max_state,
+ .get_cur_state = devfreq_get_cur_state,
+ .set_cur_state = devfreq_set_cur_state,
+};
+
+/**
+ * __devfreq_cooling_register - helper function to create devfreq cooling device
+ * @np: a valid struct device_node to the cooling device tree node
+ * @devfreq: the devfreq instance.
+ *
+ * This interface function registers the devfreq cooling device with the name
+ * "thermal-devfreq-%x". This api can support multiple instances of devfreq
+ * cooling devices. It also gives the opportunity to link the cooling device
+ * with a device tree node, in order to bind it via the thermal DT code.
+ *
+ * Return: a valid struct thermal_cooling_device pointer on success,
+ * on failure, it returns a corresponding ERR_PTR().
+ */
+static struct thermal_cooling_device *
+__devfreq_cooling_register(struct device_node *np, struct devfreq *devfreq)
+{
+ struct thermal_cooling_device *cool_dev;
+ struct devfreq_cooling_device *devfreq_dev;
+ struct devfreq_dev_profile *devfreq_profile = devfreq->profile;
+ struct dev_pm_opp *opp;
+ static atomic_t devfreq_cooling_no = ATOMIC_INIT(-1);
+ char dev_name[THERMAL_NAME_LENGTH];
+ unsigned long freq;
+ int i;
+
+ devfreq_dev = kzalloc(sizeof(*devfreq_dev), GFP_KERNEL);
+ if (!devfreq_dev)
+ return ERR_PTR(-ENOMEM);
+
+ rcu_read_lock();
+ devfreq_dev->max_state = dev_pm_opp_get_opp_count(devfreq->dev.parent);
+ if (devfreq_dev->max_state <= 0) {
+ rcu_read_unlock();
+ cool_dev = ERR_PTR(-EINVAL);
+ goto free_cdev;
+ }
+ rcu_read_unlock();
+
+ /*
+ * Use the freq_table of devfreq_dev_profile structure
+ * if the devfreq_dev_profile includes already filled frequency table.
+ */
+ if (devfreq_profile->freq_table) {
+ devfreq_dev->freq_table = devfreq_profile->freq_table;
+ goto register_cooling_dev;
+ }
+
+ /* Allocate the frequency table and fill it */
+ rcu_read_lock();
+ devfreq_dev->freq_table = kzalloc(sizeof(*devfreq_dev->freq_table) *
+ devfreq_dev->max_state, GFP_KERNEL);
+ if (!devfreq_dev->freq_table) {
+ rcu_read_unlock();
+ cool_dev = ERR_PTR(-ENOMEM);
+ goto free_cdev;
+ }
+ devfreq_dev->max_state -= 1;
+
+ freq = ULONG_MAX;
+ for (i = 0; i <= devfreq_dev->max_state; i++, freq--) {
+ opp = dev_pm_opp_find_freq_floor(devfreq->dev.parent,
+ &freq);
+ if (IS_ERR(opp)) {
+ rcu_read_unlock();
+ cool_dev = ERR_PTR(-EINVAL);
+ goto free_table;
+ }
+ devfreq_dev->freq_table[i] = freq;
+ }
+ rcu_read_unlock();
+
+register_cooling_dev:
+ /* Register cooling device with devfreq device */
+ snprintf(dev_name, sizeof(dev_name), "thermal-devfreq-%d",
+ atomic_inc_return(&devfreq_cooling_no));
+
+ cool_dev = thermal_of_cooling_device_register(np, dev_name, devfreq_dev,
+ &devfreq_cooling_ops);
+ if (IS_ERR(cool_dev))
+ goto free_table;
+
+ devfreq_dev->devfreq = devfreq;
+ devfreq_dev->cool_dev = cool_dev;
+
+ return cool_dev;
+
+free_table:
+ kfree(devfreq_dev->freq_table);
+free_cdev:
+ kfree(devfreq_dev);
+
+ return cool_dev;
+}
+
+/**
+ * of_devfreq_cooling_register - function to create devfreq cooling device.
+ * @np: a valid struct device_node to the cooling device tree node
+ * @devfreq: the devfreq instance.
+ *
+ * This interface function registers the devfreq cooling device with the name
+ * "thermal-devfreq-%x". This api can support multiple instances of devfreq
+ * cooling devices. Using this API, the devfreq cooling device will be
+ * linked to the device tree node provided.
+ *
+ * Return: a valid struct thermal_cooling_device pointer on success,
+ * on failure, it returns a corresponding ERR_PTR().
+ */
+struct thermal_cooling_device *
+of_devfreq_cooling_register(struct device_node *np, struct devfreq *devfreq)
+{
+ if (!np || !devfreq)
+ return ERR_PTR(-EINVAL);
+
+ return __devfreq_cooling_register(np, devfreq);
+}
+EXPORT_SYMBOL_GPL(of_devfreq_cooling_register);
+
+/**
+ * devfreq_cooling_register - function to create devfreq cooling device.
+ * @devfreq: the devfreq instance.
+ *
+ * This interface function registers the devfreq cooling device with the name
+ * "thermal-devfreq-%x". This api can support multiple instances of devfreq
+ * cooling devices.
+ *
+ * Return: a valid struct thermal_cooling_device pointer on success,
+ * on failure, it returns a corresponding ERR_PTR().
+ */
+struct thermal_cooling_device *
+devfreq_cooling_register(struct devfreq *devfreq)
+{
+ if (!devfreq)
+ return ERR_PTR(-EINVAL);
+
+ return __devfreq_cooling_register(NULL, devfreq);
+}
+EXPORT_SYMBOL_GPL(devfreq_cooling_register);
+
+/**
+ * devfreq_cooling_unregister - function to remove devfreq cooling device.
+ * @cdev: thermal cooling device pointer.
+ *
+ * This interface function unregisters the "thermal-devfreq-%x" cooling device.
+ */
+void devfreq_cooling_unregister(struct thermal_cooling_device *cdev)
+{
+ struct devfreq_cooling_device *devfreq_dev;
+
+ if (!cdev)
+ return;
+
+ devfreq_dev = cdev->devdata;
+
+ thermal_cooling_device_unregister(devfreq_dev->cool_dev);
+ kfree(devfreq_dev->freq_table);
+ kfree(devfreq_dev);
+}
+EXPORT_SYMBOL_GPL(devfreq_cooling_unregister);
diff --git a/include/linux/devfreq-cooling.h b/include/linux/devfreq-cooling.h
new file mode 100644
index 000000000000..eec9c7494e72
--- /dev/null
+++ b/include/linux/devfreq-cooling.h
@@ -0,0 +1,80 @@
+/*
+ * linux/include/linux/devfreq-cooling.h
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd
+ * Author: Chanwoo Choi <cw00.choi@samsung.com>
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#ifndef __DEVFREQ_COOLING_H__
+#define __DEVFREQ_COOLING_H__
+
+#include <linux/of.h>
+#include <linux/thermal.h>
+#include <linux/devfreq.h>
+
+#ifdef CONFIG_DEVFREQ_THERMAL
+/**
+ * devfreq_cooling_register - function to create devfreq cooling device.
+ * @devfreq: the devfreq instance.
+ */
+struct thermal_cooling_device *
+devfreq_cooling_register(struct devfreq *devfreq);
+
+/**
+ * of_devfreq_cooling_register - create devfreq cooling device based on DT.
+ * @np: a valid struct device_node to the cooling device tree node
+ * @devfreq: the devfreq instance.
+ */
+#ifdef CONFIG_THERMAL_OF
+struct thermal_cooling_device *
+of_devfreq_cooling_register(struct device_node *np, struct devfreq *devfreq);
+#else
+static inline struct thermal_cooling_device *
+of_devfreq_cooling_register(struct device_node *np, struct devfreq *devfreq)
+{
+ return ERR_PTR(-ENOSYS);
+}
+#endif
+
+/**
+ * devfreq_cooling_unregister - function to remove devfreq cooling device.
+ * @cdev: thermal cooling device pointer.
+ */
+void devfreq_cooling_unregister(struct thermal_cooling_device *cdev);
+
+#else /* !CONFIG_DEVFREQ_THERMAL */
+static inline struct thermal_cooling_device *
+devfreq_cooling_register(struct devfreq *devfreq)
+{
+ return ERR_PTR(-ENOSYS);
+}
+static inline struct thermal_cooling_device *
+of_devfreq_cooling_register(struct device_node *np, struct devfreq *devfreq)
+{
+ return ERR_PTR(-ENOSYS);
+}
+
+static inline
+void devfreq_cooling_unregister(struct thermal_cooling_device *cdev)
+{
+ return;
+}
+#endif /* CONFIG_DEVFREQ_THERMAL */
+
+#endif /* __DEVFREQ_COOLING_H__ */
--
1.8.5.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [RFC PATCH 0/2] thermal: Add generic devfreq cooling device
@ 2015-07-17 6:40 MyungJoo Ham
2015-07-17 7:16 ` Chanwoo Choi
0 siblings, 1 reply; 9+ messages in thread
From: MyungJoo Ham @ 2015-07-17 6:40 UTC (permalink / raw)
To: 최찬우, edubezval@gmail.com,
rui.zhang@intel.com, 박경민
Cc: ulf.hansson@linaro.org, khilman@linaro.org, robh+dt@kernel.org,
pawel.moll@arm.com, mark.rutland@arm.com,
ijc+devicetree@hellion.org.uk, 대인기,
Lukasz Majewski, 김국진,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
devicetree@vger.kernel.org
>
> This patchset introduce the generic devfreq cooling device for generic thermal
> framework. The devfreq devices are used ad cooling device to reduce the
> overheating temperature. This patch is based on drivers/thermal/cpu_cooling.c.
> The devfreq cooling device can change the ragne of the frequency table of
> devfreq device according to cooling level in device tree file.
Hi,
1. You've exported "update_devfreq()" in 1/2 and didn't use it anywhere.
2. If you've added "update_devfreq()" to notify devfreq driver when a new
max/min is defined, you'll need to add it at set_state, OR
You may do it with opp_enable()/opp_disable() function and let opp
notifiers do the homework for you. (no need to update_devfreq().
Cheers,
MyungJoo
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [RFC PATCH 0/2] thermal: Add generic devfreq cooling device
2015-07-17 6:40 MyungJoo Ham
@ 2015-07-17 7:16 ` Chanwoo Choi
0 siblings, 0 replies; 9+ messages in thread
From: Chanwoo Choi @ 2015-07-17 7:16 UTC (permalink / raw)
To: myungjoo.ham
Cc: edubezval@gmail.com, rui.zhang@intel.com,
박경민, ulf.hansson@linaro.org,
khilman@linaro.org, robh+dt@kernel.org, pawel.moll@arm.com,
mark.rutland@arm.com, ijc+devicetree@hellion.org.uk,
대인기, Lukasz Majewski,
김국진, linux-pm@vger.kernel.org,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org
Dear Myungjoo,
On 07/17/2015 03:40 PM, MyungJoo Ham wrote:
>>
>> This patchset introduce the generic devfreq cooling device for generic thermal
>> framework. The devfreq devices are used ad cooling device to reduce the
>> overheating temperature. This patch is based on drivers/thermal/cpu_cooling.c.
>> The devfreq cooling device can change the ragne of the frequency table of
>> devfreq device according to cooling level in device tree file.
>
> Hi,
>
>
> 1. You've exported "update_devfreq()" in 1/2 and didn't use it anywhere.
> 2. If you've added "update_devfreq()" to notify devfreq driver when a new
> max/min is defined, you'll need to add it at set_state, OR
> You may do it with opp_enable()/opp_disable() function and let opp
> notifiers do the homework for you. (no need to update_devfreq().
It is my mistake. The devfreq_set_cur_state() in patch2 use the update_devfreq()
to change the maximum frequency of devfreq device as following:
+ /* Set the limited frequency to maximum frequency of devfreq */
+ devfreq_dev->devfreq->max_freq = limited_freq;
+ update_devfreq(devfreq_dev->devfreq);
I'll resent v2 patch-set.
Thanks,
Chanwoo Choi
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [RFC PATCH 0/2] thermal: Add generic devfreq cooling device
2015-07-16 12:02 [RFC PATCH 0/2] thermal: Add generic devfreq cooling device Chanwoo Choi
2015-07-16 12:02 ` [RFC PATCH 1/2] PM: devfreq: Add the prototype of update_devfreq() to export Chanwoo Choi
2015-07-16 12:02 ` [RFC PATCH 2/2] thermal: devfreq_cooling: Add generic devfreq cooling device implementaion Chanwoo Choi
@ 2015-07-17 10:53 ` Punit Agrawal
2015-07-17 12:51 ` Chanwoo Choi
2 siblings, 1 reply; 9+ messages in thread
From: Punit Agrawal @ 2015-07-17 10:53 UTC (permalink / raw)
To: Chanwoo Choi
Cc: edubezval, rui.zhang, myungjoo.ham, kyungmin.park, ulf.hansson,
khilman, robh+dt, pawel.moll, mark.rutland, ijc+devicetree,
inki.dae, l.majewski, kgene.kim, linux-pm, linux-kernel,
devicetree
Hi Chanwoo,
Chanwoo Choi <cw00.choi@samsung.com> writes:
> This patchset introduce the generic devfreq cooling device for generic thermal
> framework. The devfreq devices are used ad cooling device to reduce the
> overheating temperature. This patch is based on drivers/thermal/cpu_cooling.c.
> The devfreq cooling device can change the ragne of the frequency table of
> devfreq device according to cooling level in device tree file.
>
Have you had a look at the devfreq cooling patches from Javi[0][1]? How
is the current patchset different?
At first glance, it seems that you are not implementing the extensions
that allow devfreq cooling devices to be used with power_allocator
thermal governor that got merged in v4.2-rc1.
Thanks,
Punit
[0] http://article.gmane.org/gmane.linux.power-management.general/61936
[1] http://article.gmane.org/gmane.linux.power-management.general/62417
> To verify the devfreq cooling device driver, I testd it with following platform:
>
> For example,
> - The Mali GPU of Exynos5433 SoC uses the devfreq framework to support the DVFS
> feature and Exynos5433 contains the G3D (GPU) thermal sensor. Following example
> explain the correlation between mali dt node and thermal sensor/zone.
> : thermal sensor : G3D sensor of Samsung Exynos5433 [1][2]
> : devfreq cooling device : Mali GPU [3]
>
> According to the temperature of g3d thermal sensor inclued in Exynos5433,
> devfreq cooling device can change the maximum frequency of Mali GPU.
>
> 1. In Exynos5433-based board dts file, Mali GPU dt node uses the devfreq
> framework to suppot the DVFS feature. Following dt node includes the
> both 'cooling-cells' and 'operating-points' which means the supported
> frequency entries:
>
> mali: mali@14AC0000 {
> compatible = "arm,mali-midgard";
> reg = <0x14AC0000 0x5000>;
> interrupts = <0 282 0>, <0 283 0>, <0 281 0>;
> interrupt-names = "JOB", "MMU", "GPU";
> clocks = <&cmu_g3d CLK_ACLK_G3D>;
> clock-names = "clk_mali";
> power-domains = <&pd_g3d>;
> status = "disabled";
>
> #cooling-cells = <2>;
>
> operating-points = <
> 700000 1150000
> 600000 1150000
> 550000 1125000
> 500000 1075000
> 420000 1025000
> 350000 1025000
> 266000 1000000
> 160000 1000000
> >;
> };
>
> 2. In exynos5433.dtsi, G3D thermal sensor measure the temperature of Mali GPU:
>
> tmu_g3d: tmu@10070000 {
> compatible = "samsung,exynos5433-tmu";
> reg = <0x10070000 0x200>;
> interrupts = <0 99 0>;
> clocks = <&cmu_peris CLK_PCLK_TMU1_APBIF>,
> <&cmu_peris CLK_SCLK_TMU1>;
> clock-names = "tmu_apbif", "tmu_sclk";
> #include "exynos5433-tmu-sensor-conf.dtsi"
> status = "disabled";
> };
>
> 3. In exynos5433-tmu.dtsi, thermal-zones includes both trip points and
> cooling-maps of g3d thermal sensor. Following cooling-maps show the match
> between each trip point and each cooling device (devfreq device of mali):
>
> thermal-zones {
> /* ...... */
> g3d_thermal: g3d-thermal {
> thermal-sensors = <&tmu_g3d>;
> polling-delay-passive = <0>;
> polling-delay = <0>;
> trips {
> g3d_alert_0: g3d-alert-0 {
> temperature = <30000>; /* millicelsius */
> hysteresis = <10000>; /* millicelsius */
> type = "active";
> };
> g3d_alert_1: g3d-alert-1 {
> temperature = <40000>; /* millicelsius */
> hysteresis = <10000>; /* millicelsius */
> type = "active";
> };
>
> /* ...... */
> };
>
> cooling-maps {
> map0 {
> /* Set maximum frequency as 550MHz */
> trip = <&g3d_alert_0>;
> cooling-device = <&mali 2 2>;
> };
> map1 {
> /* Set maximum frequency as 420MHz */
> trip = <&g3d_alert_1>;
> cooling-device = <&mali 4 4>;
> };
>
> /* ...... */
> };
> };
>
> ......
> };
>
> [1] https://git.kernel.org/cgit/linux/kernel/git/kgene/linux-samsung.git/commit/?h=v4.3-next/dt64-samsung&id=ac008f6b537703bb9a6fcc3882ca4af3331aa24f
> [2] https://git.kernel.org/cgit/linux/kernel/git/kgene/linux-samsung.git/commit/?h=v4.3-next/dt64-samsung&id=bcddc3a84e49ca1c646cf2081687a544a15f9218
> [3] malideveloper.arm.com/downloads/drivers/TX041/r5p0-06rel0/TX041-SW-99002-r5p0-06rel0.tgz
>
> Chanwoo Choi (2):
> PM: devfreq: Add the prototype of update_devfreq() to export
> thermal: devfreq_cooling: Add generic devfreq cooling device implementaion
>
> .../devicetree/bindings/thermal/thermal.txt | 8 +-
> drivers/devfreq/devfreq.c | 22 +-
> drivers/thermal/Kconfig | 11 +
> drivers/thermal/Makefile | 3 +
> drivers/thermal/devfreq-cooling.c | 309 +++++++++++++++++++++
> include/linux/devfreq-cooling.h | 80 ++++++
> include/linux/devfreq.h | 7 +
> 7 files changed, 425 insertions(+), 15 deletions(-)
> create mode 100644 drivers/thermal/devfreq-cooling.c
> create mode 100644 include/linux/devfreq-cooling.h
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [RFC PATCH 0/2] thermal: Add generic devfreq cooling device
2015-07-17 10:53 ` [RFC PATCH 0/2] thermal: Add generic devfreq cooling device Punit Agrawal
@ 2015-07-17 12:51 ` Chanwoo Choi
2015-07-20 14:43 ` Punit Agrawal
0 siblings, 1 reply; 9+ messages in thread
From: Chanwoo Choi @ 2015-07-17 12:51 UTC (permalink / raw)
To: Punit Agrawal
Cc: edubezval, rui.zhang, myungjoo.ham, kyungmin.park, ulf.hansson,
khilman, robh+dt, pawel.moll, mark.rutland, ijc+devicetree,
inki.dae, l.majewski, kgene.kim, linux-pm, linux-kernel,
devicetree
Hi Punit,
On 07/17/2015 07:53 PM, Punit Agrawal wrote:
> Hi Chanwoo,
>
> Chanwoo Choi <cw00.choi@samsung.com> writes:
>
>> This patchset introduce the generic devfreq cooling device for generic thermal
>> framework. The devfreq devices are used ad cooling device to reduce the
>> overheating temperature. This patch is based on drivers/thermal/cpu_cooling.c.
>> The devfreq cooling device can change the ragne of the frequency table of
>> devfreq device according to cooling level in device tree file.
>>
>
> Have you had a look at the devfreq cooling patches from Javi[0][1]? How
> is the current patchset different?
I didn't see Javi's patchset before. Thanks for your information.
I reviewed ths Javi's patchset. Both Javi's patchset and my patchset
has same concept except for applying the power allocator thermal governor
as you below comment.
But, there are some difference.
First,
I don't add new devfreq API (devfreq_set_max() / devfreq_set_min()).
The my patchset used existing update_devfreq() to update the
maximum frequency of devfreq device.
Second,
In my patchset, the devfreq cooling device will be operated
as existing cpu cooling device. If sensor measure the overheating
temperature, devfreq cooling device will limit the maximum frequency
of devfreq device. As below example, the devicetree file includes
the overheating temperature information of each trip-point.
- Javi's patchset used the static power value calculated by
devfreq_cooling_gen_power_table() instead of temperature.
Third,
Javi's patchset used the same string of type when calling
the thermal_of_cooling_device_register()
- Javi's patchset used always the same "devfreq" string.
- My patchset used the different "thermal-devfreq-%d" string
according to each devfreq cooling device.
In my patchset, devfreq cooling device uses the same method
to determine the throttling situation as existing cpu cooling
device. It is just my opinion.
>
> At first glance, it seems that you are not implementing the extensions
> that allow devfreq cooling devices to be used with power_allocator
> thermal governor that got merged in v4.2-rc1.
>
> Thanks,
> Punit
>
> [0] http://article.gmane.org/gmane.linux.power-management.general/61936
> [1] http://article.gmane.org/gmane.linux.power-management.general/62417
Thanks,
Chanwoo Choi
>
>
>> To verify the devfreq cooling device driver, I testd it with following platform:
>>
>> For example,
>> - The Mali GPU of Exynos5433 SoC uses the devfreq framework to support the DVFS
>> feature and Exynos5433 contains the G3D (GPU) thermal sensor. Following example
>> explain the correlation between mali dt node and thermal sensor/zone.
>> : thermal sensor : G3D sensor of Samsung Exynos5433 [1][2]
>> : devfreq cooling device : Mali GPU [3]
>>
>> According to the temperature of g3d thermal sensor inclued in Exynos5433,
>> devfreq cooling device can change the maximum frequency of Mali GPU.
>>
>> 1. In Exynos5433-based board dts file, Mali GPU dt node uses the devfreq
>> framework to suppot the DVFS feature. Following dt node includes the
>> both 'cooling-cells' and 'operating-points' which means the supported
>> frequency entries:
>>
>> mali: mali@14AC0000 {
>> compatible = "arm,mali-midgard";
>> reg = <0x14AC0000 0x5000>;
>> interrupts = <0 282 0>, <0 283 0>, <0 281 0>;
>> interrupt-names = "JOB", "MMU", "GPU";
>> clocks = <&cmu_g3d CLK_ACLK_G3D>;
>> clock-names = "clk_mali";
>> power-domains = <&pd_g3d>;
>> status = "disabled";
>>
>> #cooling-cells = <2>;
>>
>> operating-points = <
>> 700000 1150000
>> 600000 1150000
>> 550000 1125000
>> 500000 1075000
>> 420000 1025000
>> 350000 1025000
>> 266000 1000000
>> 160000 1000000
>> >;
>> };
>>
>> 2. In exynos5433.dtsi, G3D thermal sensor measure the temperature of Mali GPU:
>>
>> tmu_g3d: tmu@10070000 {
>> compatible = "samsung,exynos5433-tmu";
>> reg = <0x10070000 0x200>;
>> interrupts = <0 99 0>;
>> clocks = <&cmu_peris CLK_PCLK_TMU1_APBIF>,
>> <&cmu_peris CLK_SCLK_TMU1>;
>> clock-names = "tmu_apbif", "tmu_sclk";
>> #include "exynos5433-tmu-sensor-conf.dtsi"
>> status = "disabled";
>> };
>>
>> 3. In exynos5433-tmu.dtsi, thermal-zones includes both trip points and
>> cooling-maps of g3d thermal sensor. Following cooling-maps show the match
>> between each trip point and each cooling device (devfreq device of mali):
>>
>> thermal-zones {
>> /* ...... */
>> g3d_thermal: g3d-thermal {
>> thermal-sensors = <&tmu_g3d>;
>> polling-delay-passive = <0>;
>> polling-delay = <0>;
>> trips {
>> g3d_alert_0: g3d-alert-0 {
>> temperature = <30000>; /* millicelsius */
>> hysteresis = <10000>; /* millicelsius */
>> type = "active";
>> };
>> g3d_alert_1: g3d-alert-1 {
>> temperature = <40000>; /* millicelsius */
>> hysteresis = <10000>; /* millicelsius */
>> type = "active";
>> };
>>
>> /* ...... */
>> };
>>
>> cooling-maps {
>> map0 {
>> /* Set maximum frequency as 550MHz */
>> trip = <&g3d_alert_0>;
>> cooling-device = <&mali 2 2>;
>> };
>> map1 {
>> /* Set maximum frequency as 420MHz */
>> trip = <&g3d_alert_1>;
>> cooling-device = <&mali 4 4>;
>> };
>>
>> /* ...... */
>> };
>> };
>>
>> ......
>> };
>>
>> [1] https://git.kernel.org/cgit/linux/kernel/git/kgene/linux-samsung.git/commit/?h=v4.3-next/dt64-samsung&id=ac008f6b537703bb9a6fcc3882ca4af3331aa24f
>> [2] https://git.kernel.org/cgit/linux/kernel/git/kgene/linux-samsung.git/commit/?h=v4.3-next/dt64-samsung&id=bcddc3a84e49ca1c646cf2081687a544a15f9218
>> [3] malideveloper.arm.com/downloads/drivers/TX041/r5p0-06rel0/TX041-SW-99002-r5p0-06rel0.tgz
>>
>> Chanwoo Choi (2):
>> PM: devfreq: Add the prototype of update_devfreq() to export
>> thermal: devfreq_cooling: Add generic devfreq cooling device implementaion
>>
>> .../devicetree/bindings/thermal/thermal.txt | 8 +-
>> drivers/devfreq/devfreq.c | 22 +-
>> drivers/thermal/Kconfig | 11 +
>> drivers/thermal/Makefile | 3 +
>> drivers/thermal/devfreq-cooling.c | 309 +++++++++++++++++++++
>> include/linux/devfreq-cooling.h | 80 ++++++
>> include/linux/devfreq.h | 7 +
>> 7 files changed, 425 insertions(+), 15 deletions(-)
>> create mode 100644 drivers/thermal/devfreq-cooling.c
>> create mode 100644 include/linux/devfreq-cooling.h
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [RFC PATCH 0/2] thermal: Add generic devfreq cooling device
2015-07-17 12:51 ` Chanwoo Choi
@ 2015-07-20 14:43 ` Punit Agrawal
2015-07-23 1:02 ` Chanwoo Choi
0 siblings, 1 reply; 9+ messages in thread
From: Punit Agrawal @ 2015-07-20 14:43 UTC (permalink / raw)
To: Chanwoo Choi
Cc: edubezval, rui.zhang, myungjoo.ham, kyungmin.park, ulf.hansson,
khilman, robh+dt, pawel.moll, mark.rutland, ijc+devicetree,
inki.dae, l.majewski, kgene.kim, linux-pm, linux-kernel,
devicetree
Hi Chanwoo,
Chanwoo Choi <cw00.choi@samsung.com> writes:
> Hi Punit,
>
> On 07/17/2015 07:53 PM, Punit Agrawal wrote:
>> Hi Chanwoo,
>>
>> Chanwoo Choi <cw00.choi@samsung.com> writes:
>>
>>> This patchset introduce the generic devfreq cooling device for generic thermal
>>> framework. The devfreq devices are used ad cooling device to reduce the
>>> overheating temperature. This patch is based on drivers/thermal/cpu_cooling.c.
>>> The devfreq cooling device can change the ragne of the frequency table of
>>> devfreq device according to cooling level in device tree file.
>>>
>>
>> Have you had a look at the devfreq cooling patches from Javi[0][1]? How
>> is the current patchset different?
>
> I didn't see Javi's patchset before. Thanks for your information.
>
> I reviewed ths Javi's patchset. Both Javi's patchset and my patchset
> has same concept except for applying the power allocator thermal governor
> as you below comment.
>
> But, there are some difference.
>
> First,
> I don't add new devfreq API (devfreq_set_max() / devfreq_set_min()).
> The my patchset used existing update_devfreq() to update the
> maximum frequency of devfreq device.
>
Ok.
> Second,
> In my patchset, the devfreq cooling device will be operated
> as existing cpu cooling device. If sensor measure the overheating
> temperature, devfreq cooling device will limit the maximum frequency
> of devfreq device.
Javi's patchset behaves exactly as you describe here.
> As below example, the devicetree file includes
> the overheating temperature information of each trip-point.
> - Javi's patchset used the static power value calculated by
> devfreq_cooling_gen_power_table() instead of temperature.
>
You've got this wrong.
The power table is used to model device power consumption which allows
the device to be used with the power_allocator governor. Refer to the
power_allocator documentation[2] to understand how it is used.
This doesn't change the behaviour when used with other governors.
[2] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/thermal/power_allocator.txt?id=refs/tags/v4.2-rc3
> Third,
> Javi's patchset used the same string of type when calling
> the thermal_of_cooling_device_register()
> - Javi's patchset used always the same "devfreq" string.
> - My patchset used the different "thermal-devfreq-%d" string
> according to each devfreq cooling device.
>
Except for this difference (which needs to be fixed), the current
patchset is a subset of the functionality proposed in [1].
With the merging of the power_allocator governor in v4.2, it makes sense
for the devfreq cooling device to also include support for it -
especially when the functionality is already under discussion on the
list.
As such, it would be great if you could provide feedback on that thread.
Thanks,
Punit
> In my patchset, devfreq cooling device uses the same method
> to determine the throttling situation as existing cpu cooling
> device. It is just my opinion.
>
>>
>> At first glance, it seems that you are not implementing the extensions
>> that allow devfreq cooling devices to be used with power_allocator
>> thermal governor that got merged in v4.2-rc1.
>>
>> Thanks,
>> Punit
>>
>> [0] http://article.gmane.org/gmane.linux.power-management.general/61936
>> [1] http://article.gmane.org/gmane.linux.power-management.general/62417
>
> Thanks,
> Chanwoo Choi
>
>>
>>
>>> To verify the devfreq cooling device driver, I testd it with following platform:
>>>
>>> For example,
>>> - The Mali GPU of Exynos5433 SoC uses the devfreq framework to support the DVFS
>>> feature and Exynos5433 contains the G3D (GPU) thermal sensor. Following example
>>> explain the correlation between mali dt node and thermal sensor/zone.
>>> : thermal sensor : G3D sensor of Samsung Exynos5433 [1][2]
>>> : devfreq cooling device : Mali GPU [3]
>>>
>>> According to the temperature of g3d thermal sensor inclued in Exynos5433,
>>> devfreq cooling device can change the maximum frequency of Mali GPU.
>>>
>>> 1. In Exynos5433-based board dts file, Mali GPU dt node uses the devfreq
>>> framework to suppot the DVFS feature. Following dt node includes the
>>> both 'cooling-cells' and 'operating-points' which means the supported
>>> frequency entries:
>>>
>>> mali: mali@14AC0000 {
>>> compatible = "arm,mali-midgard";
>>> reg = <0x14AC0000 0x5000>;
>>> interrupts = <0 282 0>, <0 283 0>, <0 281 0>;
>>> interrupt-names = "JOB", "MMU", "GPU";
>>> clocks = <&cmu_g3d CLK_ACLK_G3D>;
>>> clock-names = "clk_mali";
>>> power-domains = <&pd_g3d>;
>>> status = "disabled";
>>>
>>> #cooling-cells = <2>;
>>>
>>> operating-points = <
>>> 700000 1150000
>>> 600000 1150000
>>> 550000 1125000
>>> 500000 1075000
>>> 420000 1025000
>>> 350000 1025000
>>> 266000 1000000
>>> 160000 1000000
>>> >;
>>> };
>>>
>>> 2. In exynos5433.dtsi, G3D thermal sensor measure the temperature of Mali GPU:
>>>
>>> tmu_g3d: tmu@10070000 {
>>> compatible = "samsung,exynos5433-tmu";
>>> reg = <0x10070000 0x200>;
>>> interrupts = <0 99 0>;
>>> clocks = <&cmu_peris CLK_PCLK_TMU1_APBIF>,
>>> <&cmu_peris CLK_SCLK_TMU1>;
>>> clock-names = "tmu_apbif", "tmu_sclk";
>>> #include "exynos5433-tmu-sensor-conf.dtsi"
>>> status = "disabled";
>>> };
>>>
>>> 3. In exynos5433-tmu.dtsi, thermal-zones includes both trip points and
>>> cooling-maps of g3d thermal sensor. Following cooling-maps show the match
>>> between each trip point and each cooling device (devfreq device of mali):
>>>
>>> thermal-zones {
>>> /* ...... */
>>> g3d_thermal: g3d-thermal {
>>> thermal-sensors = <&tmu_g3d>;
>>> polling-delay-passive = <0>;
>>> polling-delay = <0>;
>>> trips {
>>> g3d_alert_0: g3d-alert-0 {
>>> temperature = <30000>; /* millicelsius */
>>> hysteresis = <10000>; /* millicelsius */
>>> type = "active";
>>> };
>>> g3d_alert_1: g3d-alert-1 {
>>> temperature = <40000>; /* millicelsius */
>>> hysteresis = <10000>; /* millicelsius */
>>> type = "active";
>>> };
>>>
>>> /* ...... */
>>> };
>>>
>>> cooling-maps {
>>> map0 {
>>> /* Set maximum frequency as 550MHz */
>>> trip = <&g3d_alert_0>;
>>> cooling-device = <&mali 2 2>;
>>> };
>>> map1 {
>>> /* Set maximum frequency as 420MHz */
>>> trip = <&g3d_alert_1>;
>>> cooling-device = <&mali 4 4>;
>>> };
>>>
>>> /* ...... */
>>> };
>>> };
>>>
>>> ......
>>> };
>>>
>>> [1] https://git.kernel.org/cgit/linux/kernel/git/kgene/linux-samsung.git/commit/?h=v4.3-next/dt64-samsung&id=ac008f6b537703bb9a6fcc3882ca4af3331aa24f
>>> [2] https://git.kernel.org/cgit/linux/kernel/git/kgene/linux-samsung.git/commit/?h=v4.3-next/dt64-samsung&id=bcddc3a84e49ca1c646cf2081687a544a15f9218
>>> [3] malideveloper.arm.com/downloads/drivers/TX041/r5p0-06rel0/TX041-SW-99002-r5p0-06rel0.tgz
>>>
>>> Chanwoo Choi (2):
>>> PM: devfreq: Add the prototype of update_devfreq() to export
>>> thermal: devfreq_cooling: Add generic devfreq cooling device implementaion
>>>
>>> .../devicetree/bindings/thermal/thermal.txt | 8 +-
>>> drivers/devfreq/devfreq.c | 22 +-
>>> drivers/thermal/Kconfig | 11 +
>>> drivers/thermal/Makefile | 3 +
>>> drivers/thermal/devfreq-cooling.c | 309 +++++++++++++++++++++
>>> include/linux/devfreq-cooling.h | 80 ++++++
>>> include/linux/devfreq.h | 7 +
>>> 7 files changed, 425 insertions(+), 15 deletions(-)
>>> create mode 100644 drivers/thermal/devfreq-cooling.c
>>> create mode 100644 include/linux/devfreq-cooling.h
>>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [RFC PATCH 0/2] thermal: Add generic devfreq cooling device
2015-07-20 14:43 ` Punit Agrawal
@ 2015-07-23 1:02 ` Chanwoo Choi
0 siblings, 0 replies; 9+ messages in thread
From: Chanwoo Choi @ 2015-07-23 1:02 UTC (permalink / raw)
To: Punit Agrawal
Cc: edubezval, rui.zhang, myungjoo.ham, kyungmin.park, ulf.hansson,
khilman, robh+dt, pawel.moll, mark.rutland, ijc+devicetree,
inki.dae, l.majewski, kgene.kim, linux-pm, linux-kernel,
devicetree
Hi Punit,
On 07/20/2015 11:43 PM, Punit Agrawal wrote:
> Hi Chanwoo,
>
> Chanwoo Choi <cw00.choi@samsung.com> writes:
>
>> Hi Punit,
>>
>> On 07/17/2015 07:53 PM, Punit Agrawal wrote:
>>> Hi Chanwoo,
>>>
>>> Chanwoo Choi <cw00.choi@samsung.com> writes:
>>>
>>>> This patchset introduce the generic devfreq cooling device for generic thermal
>>>> framework. The devfreq devices are used ad cooling device to reduce the
>>>> overheating temperature. This patch is based on drivers/thermal/cpu_cooling.c.
>>>> The devfreq cooling device can change the ragne of the frequency table of
>>>> devfreq device according to cooling level in device tree file.
>>>>
>>>
>>> Have you had a look at the devfreq cooling patches from Javi[0][1]? How
>>> is the current patchset different?
>>
>> I didn't see Javi's patchset before. Thanks for your information.
>>
>> I reviewed ths Javi's patchset. Both Javi's patchset and my patchset
>> has same concept except for applying the power allocator thermal governor
>> as you below comment.
>>
>> But, there are some difference.
>>
>> First,
>> I don't add new devfreq API (devfreq_set_max() / devfreq_set_min()).
>> The my patchset used existing update_devfreq() to update the
>> maximum frequency of devfreq device.
>>
>
> Ok.
>
>> Second,
>> In my patchset, the devfreq cooling device will be operated
>> as existing cpu cooling device. If sensor measure the overheating
>> temperature, devfreq cooling device will limit the maximum frequency
>> of devfreq device.
>
> Javi's patchset behaves exactly as you describe here.
>
>> As below example, the devicetree file includes
>> the overheating temperature information of each trip-point.
>> - Javi's patchset used the static power value calculated by
>> devfreq_cooling_gen_power_table() instead of temperature.
>>
>
> You've got this wrong.
>
> The power table is used to model device power consumption which allows
> the device to be used with the power_allocator governor. Refer to the
> power_allocator documentation[2] to understand how it is used.
>
> This doesn't change the behaviour when used with other governors.
>
> [2] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/thermal/power_allocator.txt?id=refs/tags/v4.2-rc3
OK. I'll check it.
>
>> Third,
>> Javi's patchset used the same string of type when calling
>> the thermal_of_cooling_device_register()
>> - Javi's patchset used always the same "devfreq" string.
>> - My patchset used the different "thermal-devfreq-%d" string
>> according to each devfreq cooling device.
>>
>
> Except for this difference (which needs to be fixed), the current
> patchset is a subset of the functionality proposed in [1].
>
> With the merging of the power_allocator governor in v4.2, it makes sense
> for the devfreq cooling device to also include support for it -
> especially when the functionality is already under discussion on the
> list.
>
> As such, it would be great if you could provide feedback on that thread.
First of all, I'm not opposite to apply power_allocator
to cooling device (CPU, Devfreq). I think that thermal framework
may need the basic patch-set for devfreq cooling device
as cpu cooling device without power allocator.
And then the additional patch-set(e.g., to apply power_allocator)
will be implemented on basic patchset. The your proposed
patch-set[1] include the two features with power_allocator.
Lastly, I want to simplify the devfreq cooling device driver
without unneed/additional functions as I explained on previous reply.
Thanks,
Chanwoo Choi
>
> Thanks,
> Punit
>
>> In my patchset, devfreq cooling device uses the same method
>> to determine the throttling situation as existing cpu cooling
>> device. It is just my opinion.
>>
>>>
>>> At first glance, it seems that you are not implementing the extensions
>>> that allow devfreq cooling devices to be used with power_allocator
>>> thermal governor that got merged in v4.2-rc1.
>>>
>>> Thanks,
>>> Punit
>>>
>>> [0] http://article.gmane.org/gmane.linux.power-management.general/61936
>>> [1] http://article.gmane.org/gmane.linux.power-management.general/62417
>>
>> Thanks,
>> Chanwoo Choi
>>
>>>
>>>
>>>> To verify the devfreq cooling device driver, I testd it with following platform:
>>>>
>>>> For example,
>>>> - The Mali GPU of Exynos5433 SoC uses the devfreq framework to support the DVFS
>>>> feature and Exynos5433 contains the G3D (GPU) thermal sensor. Following example
>>>> explain the correlation between mali dt node and thermal sensor/zone.
>>>> : thermal sensor : G3D sensor of Samsung Exynos5433 [1][2]
>>>> : devfreq cooling device : Mali GPU [3]
>>>>
>>>> According to the temperature of g3d thermal sensor inclued in Exynos5433,
>>>> devfreq cooling device can change the maximum frequency of Mali GPU.
>>>>
>>>> 1. In Exynos5433-based board dts file, Mali GPU dt node uses the devfreq
>>>> framework to suppot the DVFS feature. Following dt node includes the
>>>> both 'cooling-cells' and 'operating-points' which means the supported
>>>> frequency entries:
>>>>
>>>> mali: mali@14AC0000 {
>>>> compatible = "arm,mali-midgard";
>>>> reg = <0x14AC0000 0x5000>;
>>>> interrupts = <0 282 0>, <0 283 0>, <0 281 0>;
>>>> interrupt-names = "JOB", "MMU", "GPU";
>>>> clocks = <&cmu_g3d CLK_ACLK_G3D>;
>>>> clock-names = "clk_mali";
>>>> power-domains = <&pd_g3d>;
>>>> status = "disabled";
>>>>
>>>> #cooling-cells = <2>;
>>>>
>>>> operating-points = <
>>>> 700000 1150000
>>>> 600000 1150000
>>>> 550000 1125000
>>>> 500000 1075000
>>>> 420000 1025000
>>>> 350000 1025000
>>>> 266000 1000000
>>>> 160000 1000000
>>>> >;
>>>> };
>>>>
>>>> 2. In exynos5433.dtsi, G3D thermal sensor measure the temperature of Mali GPU:
>>>>
>>>> tmu_g3d: tmu@10070000 {
>>>> compatible = "samsung,exynos5433-tmu";
>>>> reg = <0x10070000 0x200>;
>>>> interrupts = <0 99 0>;
>>>> clocks = <&cmu_peris CLK_PCLK_TMU1_APBIF>,
>>>> <&cmu_peris CLK_SCLK_TMU1>;
>>>> clock-names = "tmu_apbif", "tmu_sclk";
>>>> #include "exynos5433-tmu-sensor-conf.dtsi"
>>>> status = "disabled";
>>>> };
>>>>
>>>> 3. In exynos5433-tmu.dtsi, thermal-zones includes both trip points and
>>>> cooling-maps of g3d thermal sensor. Following cooling-maps show the match
>>>> between each trip point and each cooling device (devfreq device of mali):
>>>>
>>>> thermal-zones {
>>>> /* ...... */
>>>> g3d_thermal: g3d-thermal {
>>>> thermal-sensors = <&tmu_g3d>;
>>>> polling-delay-passive = <0>;
>>>> polling-delay = <0>;
>>>> trips {
>>>> g3d_alert_0: g3d-alert-0 {
>>>> temperature = <30000>; /* millicelsius */
>>>> hysteresis = <10000>; /* millicelsius */
>>>> type = "active";
>>>> };
>>>> g3d_alert_1: g3d-alert-1 {
>>>> temperature = <40000>; /* millicelsius */
>>>> hysteresis = <10000>; /* millicelsius */
>>>> type = "active";
>>>> };
>>>>
>>>> /* ...... */
>>>> };
>>>>
>>>> cooling-maps {
>>>> map0 {
>>>> /* Set maximum frequency as 550MHz */
>>>> trip = <&g3d_alert_0>;
>>>> cooling-device = <&mali 2 2>;
>>>> };
>>>> map1 {
>>>> /* Set maximum frequency as 420MHz */
>>>> trip = <&g3d_alert_1>;
>>>> cooling-device = <&mali 4 4>;
>>>> };
>>>>
>>>> /* ...... */
>>>> };
>>>> };
>>>>
>>>> ......
>>>> };
>>>>
>>>> [1] https://git.kernel.org/cgit/linux/kernel/git/kgene/linux-samsung.git/commit/?h=v4.3-next/dt64-samsung&id=ac008f6b537703bb9a6fcc3882ca4af3331aa24f
>>>> [2] https://git.kernel.org/cgit/linux/kernel/git/kgene/linux-samsung.git/commit/?h=v4.3-next/dt64-samsung&id=bcddc3a84e49ca1c646cf2081687a544a15f9218
>>>> [3] malideveloper.arm.com/downloads/drivers/TX041/r5p0-06rel0/TX041-SW-99002-r5p0-06rel0.tgz
>>>>
>>>> Chanwoo Choi (2):
>>>> PM: devfreq: Add the prototype of update_devfreq() to export
>>>> thermal: devfreq_cooling: Add generic devfreq cooling device implementaion
>>>>
>>>> .../devicetree/bindings/thermal/thermal.txt | 8 +-
>>>> drivers/devfreq/devfreq.c | 22 +-
>>>> drivers/thermal/Kconfig | 11 +
>>>> drivers/thermal/Makefile | 3 +
>>>> drivers/thermal/devfreq-cooling.c | 309 +++++++++++++++++++++
>>>> include/linux/devfreq-cooling.h | 80 ++++++
>>>> include/linux/devfreq.h | 7 +
>>>> 7 files changed, 425 insertions(+), 15 deletions(-)
>>>> create mode 100644 drivers/thermal/devfreq-cooling.c
>>>> create mode 100644 include/linux/devfreq-cooling.h
>>>
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-pm" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2015-07-23 1:02 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-16 12:02 [RFC PATCH 0/2] thermal: Add generic devfreq cooling device Chanwoo Choi
2015-07-16 12:02 ` [RFC PATCH 1/2] PM: devfreq: Add the prototype of update_devfreq() to export Chanwoo Choi
2015-07-16 12:02 ` [RFC PATCH 2/2] thermal: devfreq_cooling: Add generic devfreq cooling device implementaion Chanwoo Choi
2015-07-17 10:53 ` [RFC PATCH 0/2] thermal: Add generic devfreq cooling device Punit Agrawal
2015-07-17 12:51 ` Chanwoo Choi
2015-07-20 14:43 ` Punit Agrawal
2015-07-23 1:02 ` Chanwoo Choi
-- strict thread matches above, loose matches on Subject: below --
2015-07-17 6:40 MyungJoo Ham
2015-07-17 7:16 ` Chanwoo Choi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).