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()
141 * @tz: thermal zone for which to estimate the constants
149 static void estimate_pid_constants(struct thermal_zone_device *tz, in estimate_pid_constants() argument
171 tz->tzp->k_po = int_to_frac(sustainable_power) / in estimate_pid_constants()
174 tz->tzp->k_pu = int_to_frac(2 * sustainable_power) / in estimate_pid_constants()
177 k_i = tz->tzp->k_pu / 10; in estimate_pid_constants()
178 tz->tzp->k_i = k_i > 0 ? k_i : 1; in estimate_pid_constants()
188 * @tz: thermal zone for which to estimate the constants
197 static u32 get_sustainable_power(struct thermal_zone_device *tz, in get_sustainable_power() argument
203 if (!tz->tzp->sustainable_power) in get_sustainable_power()
204 sustainable_power = estimate_sustainable_power(tz); in get_sustainable_power()
206 sustainable_power = tz->tzp->sustainable_power; in get_sustainable_power()
210 estimate_pid_constants(tz, sustainable_power, in get_sustainable_power()
214 tz->tzp->sustainable_power = sustainable_power; in get_sustainable_power()
223 * @tz: thermal zone we are operating in
239 static u32 pid_controller(struct thermal_zone_device *tz, in pid_controller() argument
243 struct power_allocator_params *params = tz->governor_data; in pid_controller()
250 sustainable_power = get_sustainable_power(tz, params, control_temp); in pid_controller()
252 err = control_temp - tz->temperature; in pid_controller()
256 p = mul_frac(err < 0 ? tz->tzp->k_po : tz->tzp->k_pu, err); in pid_controller()
264 i = mul_frac(tz->tzp->k_i, params->err_integral); in pid_controller()
266 if (err < int_to_frac(tz->tzp->integral_cutoff)) { in pid_controller()
267 s64 i_next = i + mul_frac(tz->tzp->k_i, err); in pid_controller()
282 d = mul_frac(tz->tzp->k_d, err - params->prev_err); in pid_controller()
283 d = div_frac(d, jiffies_to_msecs(tz->passive_delay_jiffies)); in pid_controller()
293 trace_thermal_power_allocator_pid(tz, frac_to_int(err), in pid_controller()
406 static void allocate_power(struct thermal_zone_device *tz, int control_temp) in allocate_power() argument
408 struct power_allocator_params *params = tz->governor_data; in allocate_power()
458 power_range = pid_controller(tz, control_temp, max_allocatable_power); in allocate_power()
474 trace_thermal_power_actor(tz, i, pa->req_power, in allocate_power()
479 trace_thermal_power_allocator(tz, total_req_power, total_granted_power, in allocate_power()
481 max_allocatable_power, tz->temperature, in allocate_power()
482 control_temp - tz->temperature); in allocate_power()
487 * @tz: thermal zone to operate on
500 static void get_governor_trips(struct thermal_zone_device *tz, in get_governor_trips() argument
508 for_each_trip_desc(tz, td) { in get_governor_trips()
545 static void allow_maximum_power(struct thermal_zone_device *tz) in allow_maximum_power() argument
547 struct power_allocator_params *params = tz->governor_data; in allow_maximum_power()
577 * @tz: thermal zone to operate on
580 * Check all cooling devices in the @tz and warn every time they are missing
584 * If all of the cooling devices currently attached to @tz implement the power
588 static int check_power_actors(struct thermal_zone_device *tz, in check_power_actors() argument
602 dev_warn(&tz->device, "power_allocator: %s is not a power actor\n", in check_power_actors()
660 static void power_allocator_update_tz(struct thermal_zone_device *tz, in power_allocator_update_tz() argument
663 struct power_allocator_params *params = tz->governor_data; in power_allocator_update_tz()
689 * @tz: thermal zone to bind it to
695 * when there are unsupported cooling devices in the @tz.
697 static int power_allocator_bind(struct thermal_zone_device *tz) in power_allocator_bind() argument
706 get_governor_trips(tz, params); in power_allocator_bind()
708 ret = check_power_actors(tz, params); in power_allocator_bind()
710 dev_warn(&tz->device, "power_allocator: binding failed\n"); in power_allocator_bind()
717 dev_warn(&tz->device, "power_allocator: allocation failed\n"); in power_allocator_bind()
722 if (!tz->tzp) { in power_allocator_bind()
723 tz->tzp = kzalloc(sizeof(*tz->tzp), GFP_KERNEL); in power_allocator_bind()
724 if (!tz->tzp) { in power_allocator_bind()
732 if (!tz->tzp->sustainable_power) in power_allocator_bind()
733 dev_warn(&tz->device, "power_allocator: sustainable_power will be estimated\n"); in power_allocator_bind()
735 params->sustainable_power = tz->tzp->sustainable_power; in power_allocator_bind()
738 estimate_pid_constants(tz, tz->tzp->sustainable_power, in power_allocator_bind()
744 tz->governor_data = params; in power_allocator_bind()
757 static void power_allocator_unbind(struct thermal_zone_device *tz) in power_allocator_unbind() argument
759 struct power_allocator_params *params = tz->governor_data; in power_allocator_unbind()
761 dev_dbg(&tz->device, "Unbinding from thermal zone %d\n", tz->id); in power_allocator_unbind()
764 kfree(tz->tzp); in power_allocator_unbind()
765 tz->tzp = NULL; in power_allocator_unbind()
769 kfree(tz->governor_data); in power_allocator_unbind()
770 tz->governor_data = NULL; in power_allocator_unbind()
773 static void power_allocator_manage(struct thermal_zone_device *tz) in power_allocator_manage() argument
775 struct power_allocator_params *params = tz->governor_data; in power_allocator_manage()
778 lockdep_assert_held(&tz->lock); in power_allocator_manage()
780 if (trip && tz->temperature < trip->temperature) { in power_allocator_manage()
782 allow_maximum_power(tz); in power_allocator_manage()
790 allocate_power(tz, params->trip_max->temperature); in power_allocator_manage()