From: Amit Daniel Kachhap <amit.daniel@samsung.com>
To: linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org
Cc: Zhang Rui <rui.zhang@intel.com>,
linux-kernel@vger.kernel.org, amit.kachhap@gmail.com,
edubezval@gmail.com, rjw@rjwysocki.net,
linux-arm-kernel@lists.infradead.org, lenb@kernel.org
Subject: [PATCH v1 4/6] thermal: cpu_cooling: Add support to find up/low frequency levels.
Date: Thu, 29 May 2014 13:45:32 +0530 [thread overview]
Message-ID: <1401351334-11210-5-git-send-email-amit.daniel@samsung.com> (raw)
In-Reply-To: <1401351334-11210-1-git-send-email-amit.daniel@samsung.com>
This patch adds support to get P state ceil/floor level for nearest frequency.
This will be used for consolidating ACPI cpufreq cooling via the generic cpu
cooling framework.
Signed-off-by: Amit Daniel Kachhap <amit.daniel@samsung.com>
---
Documentation/thermal/cpu-cooling-api.txt | 15 +++++++++
drivers/thermal/cpu_cooling.c | 39 +++++++++++++++++------
drivers/thermal/samsung/exynos_thermal_common.c | 3 +-
include/linux/cpu_cooling.h | 13 ++++++-
4 files changed, 57 insertions(+), 13 deletions(-)
diff --git a/Documentation/thermal/cpu-cooling-api.txt b/Documentation/thermal/cpu-cooling-api.txt
index aaa07c6..a1f93b8 100644
--- a/Documentation/thermal/cpu-cooling-api.txt
+++ b/Documentation/thermal/cpu-cooling-api.txt
@@ -31,3 +31,18 @@ the user. The registration APIs returns the cooling device pointer.
This interface function unregisters the "thermal-cpufreq-%x" cooling device.
cdev: Cooling device pointer which has to be unregistered.
+
+1.1.3 unsigned long cpufreq_cooling_get_level(unsigned int cpu,
+ unsigned int freq, enum cpufreq_cooling_property)
+
+ This interface gets the frequency level for the absolute frequency by
+ matching in grequency table.
+
+ cpu: cpu for which the frequency level is expected.
+ freq: absolute input frequency as found in cpu freq table.
+ cpufreq_cooling_property:
+ .GET_LEVEL_CEIL: returns the ceil of the frequency level.
+ .GET_LEVEL_FLOOR: returns the floor of the frequency level.
+ .GET_LEVEL_EXACT: returns the exact frequency level if found.
+ .GET_MAXL: returns the max frequency level.
+
diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
index 6d145d5..4ce8803 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -120,11 +120,7 @@ cpufreq_cooling_get_info(struct thermal_cooling_device *cdev)
return cpufreq_dev;
}
-enum cpufreq_cooling_property {
- GET_LEVEL,
- GET_FREQ,
- GET_MAXL,
-};
+#define GET_FREQ (sizeof(enum cpufreq_cooling_property) + 1)
/**
* get_property - fetch a property of interest for a give cpu.
@@ -207,15 +203,37 @@ static int get_property(unsigned int cpu, unsigned long input,
/* now we have a valid frequency entry */
freq = table[i].frequency;
- if (property == GET_LEVEL && (unsigned int)input == freq) {
+ if (property == GET_LEVEL_EXACT &&
+ (unsigned int)input == freq) {
/* get level by frequency */
*output = descend ? j : (max_level - j);
return 0;
- }
- if (property == GET_FREQ && level == j) {
+ } else if (property == GET_FREQ && level == j) {
/* get frequency by level */
*output = freq;
return 0;
+ } else if (property == GET_LEVEL_FLOOR) {
+ /* get minimum possible level by frequency */
+ if (descend && freq <= input) {
+ *output = j;
+ return 0;
+ } else if (!descend) {
+ if (freq <= input)
+ *output = (max_level - j);
+ else
+ return 0;
+ }
+ } else if (property == GET_LEVEL_CEIL) {
+ /* get maximum possible level by frequency */
+ if (!descend && freq >= input) {
+ *output = (max_level - j);
+ return 0;
+ } else if (descend) {
+ if (freq >= input)
+ *output = j;
+ else
+ return 0;
+ }
}
j++;
}
@@ -234,11 +252,12 @@ static int get_property(unsigned int cpu, unsigned long input,
* Return: The matched cooling level on success or THERMAL_CSTATE_INVALID
* otherwise.
*/
-unsigned long cpufreq_cooling_get_level(unsigned int cpu, unsigned int freq)
+unsigned long cpufreq_cooling_get_level(unsigned int cpu, unsigned int freq,
+ enum cpufreq_cooling_property property)
{
unsigned int val;
- if (get_property(cpu, (unsigned long)freq, &val, GET_LEVEL))
+ if (get_property(cpu, (unsigned long)freq, &val, property))
return THERMAL_CSTATE_INVALID;
return (unsigned long)val;
diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c
index a7306fa..aa4696b 100644
--- a/drivers/thermal/samsung/exynos_thermal_common.c
+++ b/drivers/thermal/samsung/exynos_thermal_common.c
@@ -156,7 +156,8 @@ static int exynos_bind(struct thermal_zone_device *thermal,
/* Bind the thermal zone to the cpufreq cooling device */
for (i = 0; i < tab_size; i++) {
clip_data = (struct freq_clip_table *)&(tab_ptr[i]);
- level = cpufreq_cooling_get_level(0, clip_data->freq_clip_max);
+ level = cpufreq_cooling_get_level(0, clip_data->freq_clip_max,
+ GET_LEVEL_EXACT);
if (level == THERMAL_CSTATE_INVALID)
return 0;
switch (GET_ZONE(i)) {
diff --git a/include/linux/cpu_cooling.h b/include/linux/cpu_cooling.h
index aaef7d8..dba52c9 100644
--- a/include/linux/cpu_cooling.h
+++ b/include/linux/cpu_cooling.h
@@ -28,6 +28,13 @@
#include <linux/thermal.h>
#include <linux/cpumask.h>
+enum cpufreq_cooling_property {
+ GET_LEVEL_CEIL,
+ GET_LEVEL_FLOOR,
+ GET_LEVEL_EXACT,
+ GET_MAXL,
+};
+
#ifdef CONFIG_CPU_THERMAL
/**
* cpufreq_cooling_register - function to create cpufreq cooling device.
@@ -61,7 +68,8 @@ of_cpufreq_cooling_register(struct device_node *np,
*/
void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev);
-unsigned long cpufreq_cooling_get_level(unsigned int cpu, unsigned int freq);
+unsigned long cpufreq_cooling_get_level(unsigned int cpu, unsigned int freq,
+ enum cpufreq_cooling_property);
#else /* !CONFIG_CPU_THERMAL */
static inline struct thermal_cooling_device *
cpufreq_cooling_register(const struct cpumask *clip_cpus, void *devdata)
@@ -80,7 +88,8 @@ void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev)
return;
}
static inline
-unsigned long cpufreq_cooling_get_level(unsigned int cpu, unsigned int freq)
+unsigned long cpufreq_cooling_get_level(unsigned int cpu, unsigned int freq,
+ enum cpufreq_cooling_property property)
{
return THERMAL_CSTATE_INVALID;
}
--
1.7.1
next prev parent reply other threads:[~2014-05-29 8:17 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-29 8:15 [PATCH v1 0/6] ACPI: thermal: Migrate cpufreq cooling to generic cpu_cooling layer Amit Daniel Kachhap
2014-05-29 8:15 ` [PATCH v1 1/6] thermal: cpu_cooling: Fix the notification mechanism by using per cpu structure Amit Daniel Kachhap
2014-05-29 8:15 ` [PATCH v1 2/6] thermal: cpu_cooling: Support passing driver private data Amit Daniel Kachhap
2014-05-29 12:06 ` Javi Merino
2014-06-02 9:24 ` Amit Kachhap
2014-06-02 18:57 ` Eduardo Valentin
2014-05-29 8:15 ` [PATCH v1 3/6] thermal: thermal-core: Add notifications support for the cooling states Amit Daniel Kachhap
2014-05-29 12:24 ` Javi Merino
2014-06-02 9:31 ` Amit Kachhap
2014-06-02 10:14 ` Javi Merino
2014-05-29 8:15 ` Amit Daniel Kachhap [this message]
2014-05-29 8:15 ` [PATCH v1 5/6] thermal: thermal_core: Remove the max cooling limit check in registration Amit Daniel Kachhap
2014-05-29 8:15 ` [PATCH v1 6/6] ACPI: thermal: processor: Use the generic cpufreq infrastructure Amit Daniel Kachhap
2014-05-29 12:42 ` Javi Merino
2014-06-02 9:21 ` Amit Kachhap
2014-06-02 10:20 ` Javi Merino
2014-06-02 17:36 ` Eduardo Valentin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1401351334-11210-5-git-send-email-amit.daniel@samsung.com \
--to=amit.daniel@samsung.com \
--cc=amit.kachhap@gmail.com \
--cc=edubezval@gmail.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rjw@rjwysocki.net \
--cc=rui.zhang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®