linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eduardo Valentin <eduardo.valentin@ti.com>
To: Durgadoss R <durgadoss.r@intel.com>
Cc: lenb@kernel.org, rui.zhang@intel.com, linux-acpi@vger.kernel.org,
	eduardo.valentin@ti.com, amit.kachhap@linaro.org
Subject: Re: [PATCH 3/4] RFC Thermal: Introduce a step-wise thermal governor
Date: Tue, 12 Jun 2012 15:59:01 +0300	[thread overview]
Message-ID: <20120612125901.GD8724@besouro> (raw)
In-Reply-To: <1339436374-26881-4-git-send-email-durgadoss.r@intel.com>

Hello Rui,

On Mon, Jun 11, 2012 at 11:09:33PM +0530, Durgadoss R wrote:
> This patch adds a simple step-wise governor to the
> generic thermal layer. This algorithm throttles the
> cooling devices in a linear fashion. If the 'trend'
> is heating, it throttles by one step. And if the
> thermal trend is cooling it de-throttles by one step.
> 
> Signed-off-by: Durgadoss R <durgadoss.r@intel.com>
> ---
>  drivers/thermal/Kconfig     |    7 +++
>  drivers/thermal/Makefile    |    1 +
>  drivers/thermal/step_wise.c |   86 +++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 94 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/thermal/step_wise.c
> 
> diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
> index f5132f3..74992cd 100644
> --- a/drivers/thermal/Kconfig
> +++ b/drivers/thermal/Kconfig
> @@ -32,3 +32,10 @@ config FAIR_SHARE
>  	depends on THERMAL
>  	help
>  	  Enable this to manage platform thermals using fair-share governor.
> +
> +config STEP_WISE
> +	bool "step_wise thermal governor"
> +	depends on THERMAL
> +	help
> +	  Enable this to manage platform thermals using a simple linear
> +          throttling algorithm

Same as before, add some description of the governor-policy.

> diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
> index 4ffe1a8..c2c0ce0 100644
> --- a/drivers/thermal/Makefile
> +++ b/drivers/thermal/Makefile
> @@ -5,3 +5,4 @@
>  obj-$(CONFIG_THERMAL)		+= thermal_sys.o
>  obj-$(CONFIG_SPEAR_THERMAL)		+= spear_thermal.o
>  obj-$(CONFIG_FAIR_SHARE)		+= fair_share.o
> +obj-$(CONFIG_STEP_WISE)			+= step_wise.o
> diff --git a/drivers/thermal/step_wise.c b/drivers/thermal/step_wise.c
> new file mode 100644
> index 0000000..7ce923a
> --- /dev/null
> +++ b/drivers/thermal/step_wise.c
> @@ -0,0 +1,86 @@
> +/*
> + *  step_wise.c - A step-by-step Thermal throttling governor
> + *
> + *  Copyright (C) 2012 Intel Corp
> + *  Copyright (C) 2012 Durgadoss R <durgadoss.r@intel.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.
> + *
> + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> + */
> +
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> +#include <linux/module.h>
> +#include <linux/thermal.h>
> +
> +unsigned long get_new_state(unsigned long cur_state, enum thermal_trend trend)
> +{
> +	switch (trend) {
> +	case THERMAL_TREND_HEATING:
> +		return cur_state + 1;
> +	case THERMAL_TREND_COOLING:
> +		return cur_state - 1;
> +	default:
> +		return cur_state + 1;
> +	}
> +}
> +
> +/**
> + * step_wise_throttle - throttles devices asscciated with the given zone
> + * @tz - thermal_zone_device
> + *
> + * Throttling Logic: This uses the trend of the thermal zone to throttle.
> + * If the thermal zone is 'heating up' this throttles all the cooling
> + * devices associated with the zone by one step. If the zone is
> + * 'cooling down' it brings back the performance of the devices by one step.
> + */
> +int step_wise_throttle(struct thermal_zone_device *tz,
> +			int trip, enum thermal_trip_type trip_type)
> +{
> +	struct thermal_zone_params *tzp = tz->tzp;
> +	struct thermal_cooling_device *cdev;
> +	unsigned long max_state, cur_state, new_state;
> +	enum thermal_trend trend;
> +	int i;
> +
> +	if (!tz->ops->get_trend || tz->ops->get_trend(tz, trip, &trend))
> +		trend = THERMAL_TREND_DEFAULT;
> +
> +	for (i = 0; i < tzp->num_cdevs; i++) {
> +		if (!tzp->cdevs[i])
> +			continue;
> +
> +		cdev = tzp->cdevs[i];
> +		cdev->ops->get_cur_state(cdev, &cur_state);
> +		cdev->ops->get_max_state(cdev, &max_state);
> +
> +		new_state = get_new_state(cur_state, trend);
> +		if (new_state >= max_state)
> +			cdev->ops->set_cur_state(cdev, max_state);
> +		else if (new_state <= 0)

new_state can not be negative as it is declared as unsigned.

> +			cdev->ops->set_cur_state(cdev, 0);
> +		else
> +			cdev->ops->set_cur_state(cdev, new_state);
> +	}
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(step_wise_throttle);


Again, what was the difference between linear and step_wise?

Is it so that linear applies only to the passive trip points and
step wise applies to all cooling devices in the specific zone?

I guess we need some more clarity on the differences.

> +
> +MODULE_AUTHOR("Durgadoss R");
> +MODULE_DESCRIPTION("A step-by-step thermal throttling governor");
> +MODULE_LICENSE("GPL");
> -- 
> 1.7.0.4
> 

  reply	other threads:[~2012-06-12 12:59 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-11 17:39 [PATCH 0/4] Thermal Framework Enhancements Durgadoss R
2012-06-11 17:39 ` [PATCH 1/4] RFC Thermal: Enhance Generic Thermal layer with policies Durgadoss R
2012-06-12 12:46   ` Eduardo Valentin
2012-06-12 16:09     ` R, Durgadoss
2012-06-11 17:39 ` [PATCH 2/4] RFC Thermal: Introduce fair-share thermal governor Durgadoss R
2012-06-12 12:55   ` Eduardo Valentin
2012-06-12 14:49     ` R, Durgadoss
2012-06-11 17:39 ` [PATCH 3/4] RFC Thermal: Introduce a step-wise " Durgadoss R
2012-06-12 12:59   ` Eduardo Valentin [this message]
2012-06-12 14:46     ` R, Durgadoss
2012-06-11 17:39 ` [PATCH 4/4] RFC Thermal: Platform layer changes to provide thermal data Durgadoss R
2012-06-12 13:02   ` Eduardo Valentin
2012-06-12 14:40     ` R, Durgadoss
2012-06-12  7:44 ` [PATCH 0/4] Thermal Framework Enhancements Zhang Rui
2012-06-12  8:59   ` R, Durgadoss
2012-06-13  0:50     ` Zhang Rui
2012-06-12 13:12 ` Eduardo Valentin
2012-06-12 14:28   ` R, Durgadoss

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=20120612125901.GD8724@besouro \
    --to=eduardo.valentin@ti.com \
    --cc=amit.kachhap@linaro.org \
    --cc=durgadoss.r@intel.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).