[COMMON] thermal: power_alloctor: reset err_integral to integral_max
authorEunseok Choi <es10.choi@samsung.com>
Wed, 30 Aug 2017 13:58:37 +0000 (22:58 +0900)
committerChungwoo Park <cww.park@samsung.com>
Mon, 21 May 2018 08:22:04 +0000 (17:22 +0900)
This patch set err_integral value to integral_max as a reset value.

Change-Id: I79ce81fd91bcbc565d484ead2adbf313d4430c45
Signed-off-by: Eunseok Choi <es10.choi@samsung.com>
drivers/thermal/power_allocator.c

index 8082bbf2b71989f277c05ebdded5c2fa67aabec7..e8728b52d942ba34cb8098f2d5b4e93349d46e27 100644 (file)
@@ -530,10 +530,13 @@ static void get_governor_trips(struct thermal_zone_device *tz,
        }
 }
 
-static void reset_pid_controller(struct power_allocator_params *params)
+static void reset_pid_controller(struct power_allocator_params *params, struct thermal_zone_device *tz)
 {
-       params->err_integral = 0;
+       s64 i = int_to_frac(tz->tzp->integral_max);
+
+       params->err_integral = div_frac(i, tz->tzp->k_i);
        params->prev_err = 0;
+
 }
 
 static void allow_maximum_power(struct thermal_zone_device *tz)
@@ -598,7 +601,7 @@ static int power_allocator_bind(struct thermal_zone_device *tz)
                                               control_temp, false);
        }
 
-       reset_pid_controller(params);
+       reset_pid_controller(params, tz);
 
        tz->governor_data = params;
 
@@ -642,7 +645,7 @@ static int power_allocator_throttle(struct thermal_zone_device *tz, int trip)
                                     &switch_on_temp);
        if (!ret && (tz->temperature < switch_on_temp)) {
                tz->passive = 0;
-               reset_pid_controller(params);
+               reset_pid_controller(params, tz);
                allow_maximum_power(tz);
                return 0;
        }