From: edubezval@gmail.com (Eduardo Valentin)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 3/5] thermal: cpu_cooling: Add support to find nearby frequency levels.
Date: Thu, 15 May 2014 14:52:54 -0400 [thread overview]
Message-ID: <20140515185254.GC3138@developer> (raw)
In-Reply-To: <1399559880-20562-4-git-send-email-amit.daniel@samsung.com>
Hello Amit,
On Thu, May 08, 2014 at 08:07:58PM +0530, Amit Daniel Kachhap wrote:
> This patch adds suuport 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>
> ---
> drivers/thermal/cpu_cooling.c | 42 +++++++++++++++++------
> drivers/thermal/samsung/exynos_thermal_common.c | 3 +-
> include/linux/cpu_cooling.h | 23 ++++++++++++-
> 3 files changed, 55 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
> index e2aeb36..6f5430e 100644
> --- a/drivers/thermal/cpu_cooling.c
> +++ b/drivers/thermal/cpu_cooling.c
> @@ -120,12 +120,7 @@ static int is_cpufreq_valid(int cpu)
> return !cpufreq_get_policy(&policy, cpu);
> }
>
> -enum cpufreq_cooling_property {
> - GET_LEVEL,
> - GET_FREQ,
> - GET_MAXL,
> -};
> -
> +#define GET_FREQ (GET_MAXL + 1)
What happens if we add another level manipulating after GET_MAXL? say,
GET_MINL?
> /**
> * get_property - fetch a property of interest for a give cpu.
> * @cpu: cpu for which the property is required
> @@ -207,15 +202,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++;
> }
> @@ -227,6 +244,8 @@ static int get_property(unsigned int cpu, unsigned long input,
> * cpufreq_cooling_get_level - for a give cpu, return the cooling level.
> * @cpu: cpu for which the level is required
> * @freq: the frequency of interest
> + * @property: can be GET_LEVEL_CEIL, GET_LEVEL_FLOOR, GET_LEVEL_EXACT or
> + * GET_MAXL
> *
> * This function will match the cooling level corresponding to the
> * requested @freq and return it.
> @@ -234,11 +253,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 f786935..f4d2b0e 100644
> --- a/include/linux/cpu_cooling.h
> +++ b/include/linux/cpu_cooling.h
> @@ -44,6 +44,13 @@ struct cpufreq_cooling_status {
> void *devdata;
> };
>
> +enum cpufreq_cooling_property {
> + GET_LEVEL_CEIL,
> + GET_LEVEL_FLOOR,
> + GET_LEVEL_EXACT,
> + GET_MAXL,
> +};
Please document this enum.
> +
> #ifdef CONFIG_CPU_THERMAL
> /**
> * cpufreq_cooling_register - function to create cpufreq cooling device.
> @@ -77,7 +84,21 @@ 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);
> +/**
> + * cpufreq_cooling_get_level - for a give cpu, return the cooling level.
> + * @cpu: cpu for which the level is required
> + * @freq: the frequency of interest
> + * @property: can be GET_LEVEL_CEIL, GET_LEVEL_FLOOR, GET_LEVEL_EXACT or
> + * GET_MAXL
> + *
> + * This function will match the cooling level corresponding to the
> + * requested @freq and return it.
> + *
> + * Return: The matched cooling level on success or THERMAL_CSTATE_INVALID
> + * otherwise.
> + */
> +unsigned long cpufreq_cooling_get_level(unsigned int cpu, unsigned int freq,
> + enum cpufreq_cooling_property);
>
> /**
> * cpufreq_cooling_register_notifier - register a driver with cpufreq cooling.
> --
> 1.7.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
next prev parent reply other threads:[~2014-05-15 18:52 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-08 14:37 [RFC PATCH 0/5] ACPI: thermal: Migrate cpufreq cooling to generic cpu_cooling layer Amit Daniel Kachhap
2014-05-08 14:37 ` [RFC PATCH 1/5] thermal: cpu_cooling: Support passing driver private data Amit Daniel Kachhap
2014-05-15 18:33 ` Eduardo Valentin
2014-05-16 22:31 ` Rafael J. Wysocki
2014-05-19 8:56 ` amit daniel kachhap
2014-05-19 8:55 ` [linux-pm] " amit daniel kachhap
2014-05-08 14:37 ` [RFC PATCH 2/5] thermal: cpu_cooling: Add notifications support for the clients Amit Daniel Kachhap
2014-05-15 18:45 ` Eduardo Valentin
2014-05-19 8:59 ` [linux-pm] " amit daniel kachhap
2014-05-16 17:32 ` Javi Merino
2014-05-19 9:01 ` amit daniel kachhap
2014-05-08 14:37 ` [RFC PATCH 3/5] thermal: cpu_cooling: Add support to find nearby frequency levels Amit Daniel Kachhap
2014-05-15 18:52 ` Eduardo Valentin [this message]
2014-05-19 9:20 ` [linux-pm] " amit daniel kachhap
2014-05-08 14:37 ` [RFC PATCH 4/5] thermal: cpu_cooling: Release the upper cooling limit checks Amit Daniel Kachhap
2014-05-15 18:58 ` Eduardo Valentin
2014-05-19 9:15 ` [linux-pm] " amit daniel kachhap
2014-05-08 14:38 ` [RFC PATCH 5/5] ACPI: thermal: processor: Use the generic cpufreq infrastructure Amit Daniel Kachhap
2014-05-15 19:06 ` Eduardo Valentin
2014-05-19 9:09 ` [linux-pm] " amit daniel kachhap
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=20140515185254.GC3138@developer \
--to=edubezval@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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;
as well as URLs for NNTP newsgroup(s).