Lines Matching full:tz
107 * @tz: thermal zone we are operating in
116 static u32 estimate_sustainable_power(struct thermal_zone_device *tz) in estimate_sustainable_power() argument
118 struct power_allocator_params *params = tz->governor_data; in estimate_sustainable_power()
124 list_for_each_entry(instance, &tz->thermal_instances, tz_node) { in estimate_sustainable_power()
140 * @tz: thermal zone for which to estimate the constants
148 static void estimate_pid_constants(struct thermal_zone_device *tz, in estimate_pid_constants() argument
170 tz->tzp->k_po = int_to_frac(sustainable_power) / in estimate_pid_constants()
173 tz->tzp->k_pu = int_to_frac(2 * sustainable_power) / in estimate_pid_constants()
176 k_i = tz->tzp->k_pu / 10; in estimate_pid_constants()
177 tz->tzp->k_i = k_i > 0 ? k_i : 1; in estimate_pid_constants()
187 * @tz: thermal zone for which to estimate the constants
196 static u32 get_sustainable_power(struct thermal_zone_device *tz, in get_sustainable_power() argument
202 if (!tz->tzp->sustainable_power) in get_sustainable_power()
203 sustainable_power = estimate_sustainable_power(tz); in get_sustainable_power()
205 sustainable_power = tz->tzp->sustainable_power; in get_sustainable_power()
209 estimate_pid_constants(tz, sustainable_power, in get_sustainable_power()
213 tz->tzp->sustainable_power = sustainable_power; in get_sustainable_power()
222 * @tz: thermal zone we are operating in
238 static u32 pid_controller(struct thermal_zone_device *tz, in pid_controller() argument
242 struct power_allocator_params *params = tz->governor_data; in pid_controller()
249 sustainable_power = get_sustainable_power(tz, params, control_temp); in pid_controller()
251 err = control_temp - tz->temperature; in pid_controller()
255 p = mul_frac(err < 0 ? tz->tzp->k_po : tz->tzp->k_pu, err); in pid_controller()
263 i = mul_frac(tz->tzp->k_i, params->err_integral); in pid_controller()
265 if (err < int_to_frac(tz->tzp->integral_cutoff)) { in pid_controller()
266 s64 i_next = i + mul_frac(tz->tzp->k_i, err); in pid_controller()
281 d = mul_frac(tz->tzp->k_d, err - params->prev_err); in pid_controller()
282 d = div_frac(d, jiffies_to_msecs(tz->passive_delay_jiffies)); in pid_controller()
292 trace_thermal_power_allocator_pid(tz, frac_to_int(err), in pid_controller()
398 static int allocate_power(struct thermal_zone_device *tz, int control_temp) in allocate_power() argument
400 struct power_allocator_params *params = tz->governor_data; in allocate_power()
418 list_for_each_entry(instance, &tz->thermal_instances, tz_node) { in allocate_power()
449 power_range = pid_controller(tz, control_temp, max_allocatable_power); in allocate_power()
455 list_for_each_entry(instance, &tz->thermal_instances, tz_node) { in allocate_power()
465 trace_thermal_power_actor(tz, i, pa->req_power, in allocate_power()
470 trace_thermal_power_allocator(tz, total_req_power, total_granted_power, in allocate_power()
472 max_allocatable_power, tz->temperature, in allocate_power()
473 control_temp - tz->temperature); in allocate_power()
480 * @tz: thermal zone to operate on
493 static void get_governor_trips(struct thermal_zone_device *tz, in get_governor_trips() argument
501 for_each_trip(tz, trip) { in get_governor_trips()
536 static void allow_maximum_power(struct thermal_zone_device *tz, bool update) in allow_maximum_power() argument
538 struct power_allocator_params *params = tz->governor_data; in allow_maximum_power()
543 list_for_each_entry(instance, &tz->thermal_instances, tz_node) { in allow_maximum_power()
568 * @tz: thermal zone to operate on
571 * Check all cooling devices in the @tz and warn every time they are missing
575 * If all of the cooling devices currently attached to @tz implement the power
579 static int check_power_actors(struct thermal_zone_device *tz, in check_power_actors() argument
585 list_for_each_entry(instance, &tz->thermal_instances, tz_node) { in check_power_actors()
590 dev_warn(&tz->device, "power_allocator: %s is not a power actor\n", in check_power_actors()
632 static void power_allocator_update_tz(struct thermal_zone_device *tz, in power_allocator_update_tz() argument
635 struct power_allocator_params *params = tz->governor_data; in power_allocator_update_tz()
642 list_for_each_entry(instance, &tz->thermal_instances, tz_node) in power_allocator_update_tz()
653 list_for_each_entry(instance, &tz->thermal_instances, tz_node) in power_allocator_update_tz()
664 * @tz: thermal zone to bind it to
670 * when there are unsupported cooling devices in the @tz.
672 static int power_allocator_bind(struct thermal_zone_device *tz) in power_allocator_bind() argument
681 get_governor_trips(tz, params); in power_allocator_bind()
683 dev_warn(&tz->device, "power_allocator: missing trip_max\n"); in power_allocator_bind()
688 ret = check_power_actors(tz, params); in power_allocator_bind()
690 dev_warn(&tz->device, "power_allocator: binding failed\n"); in power_allocator_bind()
697 dev_warn(&tz->device, "power_allocator: allocation failed\n"); in power_allocator_bind()
702 if (!tz->tzp) { in power_allocator_bind()
703 tz->tzp = kzalloc(sizeof(*tz->tzp), GFP_KERNEL); in power_allocator_bind()
704 if (!tz->tzp) { in power_allocator_bind()
712 if (!tz->tzp->sustainable_power) in power_allocator_bind()
713 dev_warn(&tz->device, "power_allocator: sustainable_power will be estimated\n"); in power_allocator_bind()
715 estimate_pid_constants(tz, tz->tzp->sustainable_power, in power_allocator_bind()
721 tz->governor_data = params; in power_allocator_bind()
732 static void power_allocator_unbind(struct thermal_zone_device *tz) in power_allocator_unbind() argument
734 struct power_allocator_params *params = tz->governor_data; in power_allocator_unbind()
736 dev_dbg(&tz->device, "Unbinding from thermal zone %d\n", tz->id); in power_allocator_unbind()
739 kfree(tz->tzp); in power_allocator_unbind()
740 tz->tzp = NULL; in power_allocator_unbind()
744 kfree(tz->governor_data); in power_allocator_unbind()
745 tz->governor_data = NULL; in power_allocator_unbind()
748 static int power_allocator_throttle(struct thermal_zone_device *tz, in power_allocator_throttle() argument
751 struct power_allocator_params *params = tz->governor_data; in power_allocator_throttle()
754 lockdep_assert_held(&tz->lock); in power_allocator_throttle()
764 if (trip && tz->temperature < trip->temperature) { in power_allocator_throttle()
765 update = tz->passive; in power_allocator_throttle()
766 tz->passive = 0; in power_allocator_throttle()
768 allow_maximum_power(tz, update); in power_allocator_throttle()
772 tz->passive = 1; in power_allocator_throttle()
774 return allocate_power(tz, params->trip_max->temperature); in power_allocator_throttle()