Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1302484

[PATCH v3 1/4] thermal: power_allocator: rework proportional parameter

From Leo Yan <leo.yan@linaro.org>
Newsgroups linux.kernel
Subject [PATCH v3 1/4] thermal: power_allocator: rework proportional parameter
Date 2016-01-06 10:00 +0100
Message-ID <qNS6L-7dw-19@gated-at.bofh.it> (permalink)
References <qNS6J-7dw-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


k_po/k_pu are two proportional term constants and essentially they have
fixed ratio compared with sustainable power. In current implementation,
k_po and k_pu are absolute value after calculation and cannot represent
the ratio relationship with sustainable power; as a result, when change
sustainable power we cannot smoothly change proportional term constant.

So this patch introduces variants k_po_ratio and k_pu_ratio, which
represent the ratio value compared against sustainable power, so smaller
ratio will result in thermal slower ramp. The formulas finally are as
below:

k_pu = k_pu_ratio * sustainable_power /
		(desired_temperature - switch_on_temp)

k_po = k_po_ratio * sustainable_power /
		(desired_temperature - switch_on_temp)

Signed-off-by: Leo Yan <leo.yan@linaro.org>
---
 drivers/thermal/power_allocator.c | 18 ++++++++++++------
 include/linux/thermal.h           |  4 ++--
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/drivers/thermal/power_allocator.c b/drivers/thermal/power_allocator.c
index 1246aa6..76d2b47 100644
--- a/drivers/thermal/power_allocator.c
+++ b/drivers/thermal/power_allocator.c
@@ -155,13 +155,11 @@ static void estimate_pid_constants(struct thermal_zone_device *tz,
 	if (!temperature_threshold)
 		return;
 
-	if (!tz->tzp->k_po || force)
-		tz->tzp->k_po = int_to_frac(sustainable_power) /
-			temperature_threshold;
+	if (!tz->tzp->k_po_ratio || force)
+		tz->tzp->k_po_ratio = 1;
 
-	if (!tz->tzp->k_pu || force)
-		tz->tzp->k_pu = int_to_frac(2 * sustainable_power) /
-			temperature_threshold;
+	if (!tz->tzp->k_pu_ratio || force)
+		tz->tzp->k_pu_ratio = 2;
 
 	if (!tz->tzp->k_i || force)
 		tz->tzp->k_i = int_to_frac(10) / 1000;
@@ -169,6 +167,11 @@ static void estimate_pid_constants(struct thermal_zone_device *tz,
 	 * The default for k_d and integral_cutoff is 0, so we can
 	 * leave them as they are.
 	 */
+
+	tz->tzp->k_po = int_to_frac(tz->tzp->k_po_ratio * sustainable_power) /
+				temperature_threshold;
+	tz->tzp->k_pu = int_to_frac(tz->tzp->k_pu_ratio * sustainable_power) /
+				temperature_threshold;
 }
 
 /**
@@ -202,6 +205,9 @@ static u32 pid_controller(struct thermal_zone_device *tz,
 
 	if (tz->tzp->sustainable_power) {
 		sustainable_power = tz->tzp->sustainable_power;
+		estimate_pid_constants(tz, sustainable_power,
+				       params->trip_switch_on, control_temp,
+				       false);
 	} else {
 		sustainable_power = estimate_sustainable_power(tz);
 		estimate_pid_constants(tz, sustainable_power,
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 613c29b..2638f0b 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -284,13 +284,13 @@ struct thermal_zone_params {
 	 * Proportional parameter of the PID controller when
 	 * overshooting (i.e., when temperature is below the target)
 	 */
-	s32 k_po;
+	s32 k_po, k_po_ratio;
 
 	/*
 	 * Proportional parameter of the PID controller when
 	 * undershooting
 	 */
-	s32 k_pu;
+	s32 k_pu, k_pu_ratio;
 
 	/* Integral parameter of the PID controller */
 	s32 k_i;
-- 
1.9.1

--
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/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v3 0/4] thermal: re-calculate k_po/k_pu when update sustainable power Leo Yan <leo.yan@linaro.org> - 2016-01-06 10:00 +0100
  [PATCH v3 2/4] thermal: power_allocator: change k_pu_ratio/k_po_ratio as percentage Leo Yan <leo.yan@linaro.org> - 2016-01-06 10:00 +0100
  [PATCH v3 4/4] thermal: power_allocator: document k_pu_ratio/k_po_ratio Leo Yan <leo.yan@linaro.org> - 2016-01-06 10:00 +0100
  [PATCH v3 1/4] thermal: power_allocator: rework proportional parameter Leo Yan <leo.yan@linaro.org> - 2016-01-06 10:00 +0100
  [PATCH v3 3/4] thermal: add sys node for k_pu_ratio/k_po_ratio Leo Yan <leo.yan@linaro.org> - 2016-01-06 10:00 +0100
  Re: [PATCH v3 0/4] thermal: re-calculate k_po/k_pu when update  sustainable power Javi Merino <javi.merino@arm.com> - 2016-01-06 11:10 +0100
    Re: [PATCH v3 0/4] thermal: re-calculate k_po/k_pu when update  sustainable power Leo Yan <leo.yan@linaro.org> - 2016-01-06 12:20 +0100
    Re: [PATCH v3 0/4] thermal: re-calculate k_po/k_pu when update  sustainable power Daniel Thompson <daniel.thompson@linaro.org> - 2016-01-06 12:30 +0100
      Re: [PATCH v3 0/4] thermal: re-calculate k_po/k_pu when update  sustainable power Javi Merino <javi.merino@arm.com> - 2016-01-06 16:10 +0100

csiph-web