Commit 9396b2a6 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

Merge branch 'thermal-core'

This includes a major rework of thermal governors and part of the
thermal core interacting with them as well as some fixes and cleanups
of the thermal debug code:

 - Redesign the thermal governor interface to allow the governors to
   work in a more straightforward way.

 - Make thermal governors take the current trip point thresholds into
   account in their computations which allows trip hysteresis to be
   observed more accurately.

 - Clean up thermal governors.

 - Make the thermal core manage passive polling for thermal zones and
   remove passive polling management from thermal governors.

 - Improve the handling of cooling device states and thermal mitigation
   episodes in progress in the thermal debug code.

 - Avoid excessive updates of trip point statistics and clean up the
   printing of thermal mitigation episode information.

* thermal-core: (27 commits)
  thermal: core: Move passive polling management to the core
  thermal: core: Do not call handle_thermal_trip() if zone temperature is invalid
  thermal: trip: Add missing empty code line
  thermal/debugfs: Avoid printing zero duration for mitigation events in progress
  thermal/debugfs: Pass cooling device state to thermal_debug_cdev_add()
  thermal/debugfs: Create records for cdev states as they get used
  thermal: core: Introduce thermal_governor_trip_crossed()
  thermal/debugfs: Make tze_seq_show() skip invalid trips and trips with no stats
  thermal/debugfs: Rename thermal_debug_update_temp() to thermal_debug_update_trip_stats()
  thermal/debugfs: Clean up thermal_debug_update_temp()
  thermal/debugfs: Avoid excessive updates of trip point statistics
  thermal: core: Relocate critical and hot trip handling
  thermal: core: Drop the .throttle() governor callback
  thermal: gov_user_space: Use .trip_crossed() instead of .throttle()
  thermal: gov_fair_share: Eliminate unnecessary integer divisions
  thermal: gov_fair_share: Use trip thresholds instead of trip temperatures
  thermal: gov_fair_share: Use .manage() callback instead of .throttle()
  thermal: gov_step_wise: Clean up thermal_zone_trip_update()
  thermal: gov_step_wise: Use trip thresholds instead of trip temperatures
  thermal: gov_step_wise: Use .manage() callback instead of .throttle()
  ...
parents 00211025 042a3d80
...@@ -13,60 +13,11 @@ ...@@ -13,60 +13,11 @@
#include "thermal_core.h" #include "thermal_core.h"
static int thermal_zone_trip_update(struct thermal_zone_device *tz,
const struct thermal_trip *trip)
{
int trip_index = thermal_zone_trip_id(tz, trip);
struct thermal_instance *instance;
if (!trip->hysteresis)
dev_info_once(&tz->device,
"Zero hysteresis value for thermal zone %s\n", tz->type);
dev_dbg(&tz->device, "Trip%d[temp=%d]:temp=%d:hyst=%d\n",
trip_index, trip->temperature, tz->temperature,
trip->hysteresis);
list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
if (instance->trip != trip)
continue;
/* in case fan is in initial state, switch the fan off */
if (instance->target == THERMAL_NO_TARGET)
instance->target = 0;
/* in case fan is neither on nor off set the fan to active */
if (instance->target != 0 && instance->target != 1) {
pr_warn("Thermal instance %s controlled by bang-bang has unexpected state: %ld\n",
instance->name, instance->target);
instance->target = 1;
}
/*
* enable fan when temperature exceeds trip_temp and disable
* the fan in case it falls below trip_temp minus hysteresis
*/
if (instance->target == 0 && tz->temperature >= trip->temperature)
instance->target = 1;
else if (instance->target == 1 &&
tz->temperature < trip->temperature - trip->hysteresis)
instance->target = 0;
dev_dbg(&instance->cdev->device, "target=%d\n",
(int)instance->target);
mutex_lock(&instance->cdev->lock);
instance->cdev->updated = false; /* cdev needs update */
mutex_unlock(&instance->cdev->lock);
}
return 0;
}
/** /**
* bang_bang_control - controls devices associated with the given zone * bang_bang_control - controls devices associated with the given zone
* @tz: thermal_zone_device * @tz: thermal_zone_device
* @trip: the trip point * @trip: the trip point
* @crossed_up: whether or not the trip has been crossed on the way up
* *
* Regulation Logic: a two point regulation, deliver cooling state depending * Regulation Logic: a two point regulation, deliver cooling state depending
* on the previous state shown in this diagram: * on the previous state shown in this diagram:
...@@ -90,26 +41,54 @@ static int thermal_zone_trip_update(struct thermal_zone_device *tz, ...@@ -90,26 +41,54 @@ static int thermal_zone_trip_update(struct thermal_zone_device *tz,
* (trip_temp - hyst) so that the fan gets turned off again. * (trip_temp - hyst) so that the fan gets turned off again.
* *
*/ */
static int bang_bang_control(struct thermal_zone_device *tz, static void bang_bang_control(struct thermal_zone_device *tz,
const struct thermal_trip *trip) const struct thermal_trip *trip,
bool crossed_up)
{ {
struct thermal_instance *instance; struct thermal_instance *instance;
int ret;
lockdep_assert_held(&tz->lock); lockdep_assert_held(&tz->lock);
ret = thermal_zone_trip_update(tz, trip); dev_dbg(&tz->device, "Trip%d[temp=%d]:temp=%d:hyst=%d\n",
if (ret) thermal_zone_trip_id(tz, trip), trip->temperature,
return ret; tz->temperature, trip->hysteresis);
list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
if (instance->trip != trip)
continue;
if (instance->target == THERMAL_NO_TARGET)
instance->target = 0;
if (instance->target != 0 && instance->target != 1) {
pr_debug("Unexpected state %ld of thermal instance %s in bang-bang\n",
instance->target, instance->name);
instance->target = 1;
}
/*
* Enable the fan when the trip is crossed on the way up and
* disable it when the trip is crossed on the way down.
*/
if (instance->target == 0 && crossed_up)
instance->target = 1;
else if (instance->target == 1 && !crossed_up)
instance->target = 0;
dev_dbg(&instance->cdev->device, "target=%ld\n", instance->target);
mutex_lock(&instance->cdev->lock);
instance->cdev->updated = false; /* cdev needs update */
mutex_unlock(&instance->cdev->lock);
}
list_for_each_entry(instance, &tz->thermal_instances, tz_node) list_for_each_entry(instance, &tz->thermal_instances, tz_node)
thermal_cdev_update(instance->cdev); thermal_cdev_update(instance->cdev);
return 0;
} }
static struct thermal_governor thermal_gov_bang_bang = { static struct thermal_governor thermal_gov_bang_bang = {
.name = "bang_bang", .name = "bang_bang",
.throttle = bang_bang_control, .trip_crossed = bang_bang_control,
}; };
THERMAL_GOVERNOR_DECLARE(thermal_gov_bang_bang); THERMAL_GOVERNOR_DECLARE(thermal_gov_bang_bang);
...@@ -17,100 +17,111 @@ ...@@ -17,100 +17,111 @@
static int get_trip_level(struct thermal_zone_device *tz) static int get_trip_level(struct thermal_zone_device *tz)
{ {
const struct thermal_trip *level_trip = NULL; const struct thermal_trip_desc *level_td = NULL;
const struct thermal_trip_desc *td; const struct thermal_trip_desc *td;
int trip_level = -1; int trip_level = -1;
for_each_trip_desc(tz, td) { for_each_trip_desc(tz, td) {
const struct thermal_trip *trip = &td->trip; if (td->threshold > tz->temperature)
if (trip->temperature >= tz->temperature)
continue; continue;
trip_level++; trip_level++;
if (!level_trip || trip->temperature > level_trip->temperature) if (!level_td || td->threshold > level_td->threshold)
level_trip = trip; level_td = td;
} }
/* Bail out if the temperature is not greater than any trips. */ /* Bail out if the temperature is not greater than any trips. */
if (trip_level < 0) if (trip_level < 0)
return 0; return 0;
trace_thermal_zone_trip(tz, thermal_zone_trip_id(tz, level_trip), trace_thermal_zone_trip(tz, thermal_zone_trip_id(tz, &level_td->trip),
level_trip->type); level_td->trip.type);
return trip_level; return trip_level;
} }
static long get_target_state(struct thermal_zone_device *tz,
struct thermal_cooling_device *cdev, int percentage, int level)
{
return (long)(percentage * level * cdev->max_state) / (100 * tz->num_trips);
}
/** /**
* fair_share_throttle - throttles devices associated with the given zone * fair_share_throttle - throttles devices associated with the given zone
* @tz: thermal_zone_device * @tz: thermal_zone_device
* @trip: trip point * @trip: trip point
* @trip_level: number of trips crossed by the zone temperature
* *
* Throttling Logic: This uses three parameters to calculate the new * Throttling Logic: This uses three parameters to calculate the new
* throttle state of the cooling devices associated with the given zone. * throttle state of the cooling devices associated with the given zone.
* *
* Parameters used for Throttling: * Parameters used for Throttling:
* P1. max_state: Maximum throttle state exposed by the cooling device. * P1. max_state: Maximum throttle state exposed by the cooling device.
* P2. percentage[i]/100: * P2. weight[i]/total_weight:
* How 'effective' the 'i'th device is, in cooling the given zone. * How 'effective' the 'i'th device is, in cooling the given zone.
* P3. cur_trip_level/max_no_of_trips: * P3. trip_level/max_no_of_trips:
* This describes the extent to which the devices should be throttled. * This describes the extent to which the devices should be throttled.
* We do not want to throttle too much when we trip a lower temperature, * We do not want to throttle too much when we trip a lower temperature,
* whereas the throttling is at full swing if we trip critical levels. * whereas the throttling is at full swing if we trip critical levels.
* (Heavily assumes the trip points are in ascending order)
* new_state of cooling device = P3 * P2 * P1 * new_state of cooling device = P3 * P2 * P1
*/ */
static int fair_share_throttle(struct thermal_zone_device *tz, static void fair_share_throttle(struct thermal_zone_device *tz,
const struct thermal_trip *trip) const struct thermal_trip *trip,
int trip_level)
{ {
struct thermal_instance *instance; struct thermal_instance *instance;
int total_weight = 0; int total_weight = 0;
int total_instance = 0; int nr_instances = 0;
int cur_trip_level = get_trip_level(tz);
lockdep_assert_held(&tz->lock);
list_for_each_entry(instance, &tz->thermal_instances, tz_node) { list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
if (instance->trip != trip) if (instance->trip != trip)
continue; continue;
total_weight += instance->weight; total_weight += instance->weight;
total_instance++; nr_instances++;
} }
list_for_each_entry(instance, &tz->thermal_instances, tz_node) { list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
int percentage;
struct thermal_cooling_device *cdev = instance->cdev; struct thermal_cooling_device *cdev = instance->cdev;
u64 dividend;
u32 divisor;
if (instance->trip != trip) if (instance->trip != trip)
continue; continue;
if (!total_weight) dividend = trip_level;
percentage = 100 / total_instance; dividend *= cdev->max_state;
else divisor = tz->num_trips;
percentage = (instance->weight * 100) / total_weight; if (total_weight) {
dividend *= instance->weight;
instance->target = get_target_state(tz, cdev, percentage, divisor *= total_weight;
cur_trip_level); } else {
divisor *= nr_instances;
}
instance->target = div_u64(dividend, divisor);
mutex_lock(&cdev->lock); mutex_lock(&cdev->lock);
__thermal_cdev_update(cdev); __thermal_cdev_update(cdev);
mutex_unlock(&cdev->lock); mutex_unlock(&cdev->lock);
} }
}
static void fair_share_manage(struct thermal_zone_device *tz)
{
int trip_level = get_trip_level(tz);
const struct thermal_trip_desc *td;
lockdep_assert_held(&tz->lock);
for_each_trip_desc(tz, td) {
const struct thermal_trip *trip = &td->trip;
return 0; if (trip->temperature == THERMAL_TEMP_INVALID ||
trip->type == THERMAL_TRIP_CRITICAL ||
trip->type == THERMAL_TRIP_HOT)
continue;
fair_share_throttle(tz, trip, trip_level);
}
} }
static struct thermal_governor thermal_gov_fair_share = { static struct thermal_governor thermal_gov_fair_share = {
.name = "fair_share", .name = "fair_share",
.throttle = fair_share_throttle, .manage = fair_share_manage,
}; };
THERMAL_GOVERNOR_DECLARE(thermal_gov_fair_share); THERMAL_GOVERNOR_DECLARE(thermal_gov_fair_share);
...@@ -66,6 +66,7 @@ struct power_actor { ...@@ -66,6 +66,7 @@ struct power_actor {
* struct power_allocator_params - parameters for the power allocator governor * struct power_allocator_params - parameters for the power allocator governor
* @allocated_tzp: whether we have allocated tzp for this thermal zone and * @allocated_tzp: whether we have allocated tzp for this thermal zone and
* it needs to be freed on unbind * it needs to be freed on unbind
* @update_cdevs: whether or not update cdevs on the next run
* @err_integral: accumulated error in the PID controller. * @err_integral: accumulated error in the PID controller.
* @prev_err: error in the previous iteration of the PID controller. * @prev_err: error in the previous iteration of the PID controller.
* Used to calculate the derivative term. * Used to calculate the derivative term.
...@@ -84,6 +85,7 @@ struct power_actor { ...@@ -84,6 +85,7 @@ struct power_actor {
*/ */
struct power_allocator_params { struct power_allocator_params {
bool allocated_tzp; bool allocated_tzp;
bool update_cdevs;
s64 err_integral; s64 err_integral;
s32 prev_err; s32 prev_err;
u32 sustainable_power; u32 sustainable_power;
...@@ -395,7 +397,7 @@ static void divvy_up_power(struct power_actor *power, int num_actors, ...@@ -395,7 +397,7 @@ static void divvy_up_power(struct power_actor *power, int num_actors,
} }
} }
static int allocate_power(struct thermal_zone_device *tz, int control_temp) static void allocate_power(struct thermal_zone_device *tz, int control_temp)
{ {
struct power_allocator_params *params = tz->governor_data; struct power_allocator_params *params = tz->governor_data;
unsigned int num_actors = params->num_actors; unsigned int num_actors = params->num_actors;
...@@ -410,7 +412,7 @@ static int allocate_power(struct thermal_zone_device *tz, int control_temp) ...@@ -410,7 +412,7 @@ static int allocate_power(struct thermal_zone_device *tz, int control_temp)
int i = 0, ret; int i = 0, ret;
if (!num_actors) if (!num_actors)
return -ENODEV; return;
/* Clean all buffers for new power estimations */ /* Clean all buffers for new power estimations */
memset(power, 0, params->buffer_size); memset(power, 0, params->buffer_size);
...@@ -471,8 +473,6 @@ static int allocate_power(struct thermal_zone_device *tz, int control_temp) ...@@ -471,8 +473,6 @@ static int allocate_power(struct thermal_zone_device *tz, int control_temp)
num_actors, power_range, num_actors, power_range,
max_allocatable_power, tz->temperature, max_allocatable_power, tz->temperature,
control_temp - tz->temperature); control_temp - tz->temperature);
return 0;
} }
/** /**
...@@ -535,7 +535,7 @@ static void reset_pid_controller(struct power_allocator_params *params) ...@@ -535,7 +535,7 @@ static void reset_pid_controller(struct power_allocator_params *params)
params->prev_err = 0; params->prev_err = 0;
} }
static void allow_maximum_power(struct thermal_zone_device *tz, bool update) static void allow_maximum_power(struct thermal_zone_device *tz)
{ {
struct power_allocator_params *params = tz->governor_data; struct power_allocator_params *params = tz->governor_data;
struct thermal_cooling_device *cdev; struct thermal_cooling_device *cdev;
...@@ -557,7 +557,7 @@ static void allow_maximum_power(struct thermal_zone_device *tz, bool update) ...@@ -557,7 +557,7 @@ static void allow_maximum_power(struct thermal_zone_device *tz, bool update)
*/ */
cdev->ops->get_requested_power(cdev, &req_power); cdev->ops->get_requested_power(cdev, &req_power);
if (update) if (params->update_cdevs)
__thermal_cdev_update(cdev); __thermal_cdev_update(cdev);
mutex_unlock(&cdev->lock); mutex_unlock(&cdev->lock);
...@@ -745,40 +745,29 @@ static void power_allocator_unbind(struct thermal_zone_device *tz) ...@@ -745,40 +745,29 @@ static void power_allocator_unbind(struct thermal_zone_device *tz)
tz->governor_data = NULL; tz->governor_data = NULL;
} }
static int power_allocator_throttle(struct thermal_zone_device *tz, static void power_allocator_manage(struct thermal_zone_device *tz)
const struct thermal_trip *trip)
{ {
struct power_allocator_params *params = tz->governor_data; struct power_allocator_params *params = tz->governor_data;
bool update; const struct thermal_trip *trip = params->trip_switch_on;
lockdep_assert_held(&tz->lock); lockdep_assert_held(&tz->lock);
/*
* We get called for every trip point but we only need to do
* our calculations once
*/
if (trip != params->trip_max)
return 0;
trip = params->trip_switch_on;
if (trip && tz->temperature < trip->temperature) { if (trip && tz->temperature < trip->temperature) {
update = tz->passive;
tz->passive = 0;
reset_pid_controller(params); reset_pid_controller(params);
allow_maximum_power(tz, update); allow_maximum_power(tz);
return 0; params->update_cdevs = false;
return;
} }
tz->passive = 1; allocate_power(tz, params->trip_max->temperature);
params->update_cdevs = true;
return allocate_power(tz, params->trip_max->temperature);
} }
static struct thermal_governor thermal_gov_power_allocator = { static struct thermal_governor thermal_gov_power_allocator = {
.name = "power_allocator", .name = "power_allocator",
.bind_to_tz = power_allocator_bind, .bind_to_tz = power_allocator_bind,
.unbind_from_tz = power_allocator_unbind, .unbind_from_tz = power_allocator_unbind,
.throttle = power_allocator_throttle, .manage = power_allocator_manage,
.update_tz = power_allocator_update_tz, .update_tz = power_allocator_update_tz,
}; };
THERMAL_GOVERNOR_DECLARE(thermal_gov_power_allocator); THERMAL_GOVERNOR_DECLARE(thermal_gov_power_allocator);
...@@ -62,81 +62,76 @@ static unsigned long get_target_state(struct thermal_instance *instance, ...@@ -62,81 +62,76 @@ static unsigned long get_target_state(struct thermal_instance *instance,
} }
static void thermal_zone_trip_update(struct thermal_zone_device *tz, static void thermal_zone_trip_update(struct thermal_zone_device *tz,
const struct thermal_trip *trip) const struct thermal_trip *trip,
int trip_threshold)
{ {
enum thermal_trend trend = get_tz_trend(tz, trip);
int trip_id = thermal_zone_trip_id(tz, trip); int trip_id = thermal_zone_trip_id(tz, trip);
enum thermal_trend trend;
struct thermal_instance *instance; struct thermal_instance *instance;
bool throttle = false; bool throttle = false;
int old_target;
trend = get_tz_trend(tz, trip); if (tz->temperature >= trip_threshold) {
if (tz->temperature >= trip->temperature) {
throttle = true; throttle = true;
trace_thermal_zone_trip(tz, trip_id, trip->type); trace_thermal_zone_trip(tz, trip_id, trip->type);
} }
dev_dbg(&tz->device, "Trip%d[type=%d,temp=%d]:trend=%d,throttle=%d\n", dev_dbg(&tz->device, "Trip%d[type=%d,temp=%d]:trend=%d,throttle=%d\n",
trip_id, trip->type, trip->temperature, trend, throttle); trip_id, trip->type, trip_threshold, trend, throttle);
list_for_each_entry(instance, &tz->thermal_instances, tz_node) { list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
int old_target;
if (instance->trip != trip) if (instance->trip != trip)
continue; continue;
old_target = instance->target; old_target = instance->target;
instance->target = get_target_state(instance, trend, throttle); instance->target = get_target_state(instance, trend, throttle);
dev_dbg(&instance->cdev->device, "old_target=%d, target=%d\n",
old_target, (int)instance->target); dev_dbg(&instance->cdev->device, "old_target=%d, target=%ld\n",
old_target, instance->target);
if (instance->initialized && old_target == instance->target) if (instance->initialized && old_target == instance->target)
continue; continue;
if (trip->type == THERMAL_TRIP_PASSIVE) {
/* If needed, update the status of passive polling. */
if (old_target == THERMAL_NO_TARGET &&
instance->target != THERMAL_NO_TARGET)
tz->passive++;
else if (old_target != THERMAL_NO_TARGET &&
instance->target == THERMAL_NO_TARGET)
tz->passive--;
}
instance->initialized = true; instance->initialized = true;
mutex_lock(&instance->cdev->lock); mutex_lock(&instance->cdev->lock);
instance->cdev->updated = false; /* cdev needs update */ instance->cdev->updated = false; /* cdev needs update */
mutex_unlock(&instance->cdev->lock); mutex_unlock(&instance->cdev->lock);
} }
} }
/** static void step_wise_manage(struct thermal_zone_device *tz)
* step_wise_throttle - throttles devices associated with the given zone
* @tz: thermal_zone_device
* @trip: trip point
*
* 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 and its particular trip point, by one
* step. If the zone is 'cooling down' it brings back the performance of
* the devices by one step.
*/
static int step_wise_throttle(struct thermal_zone_device *tz,
const struct thermal_trip *trip)
{ {
const struct thermal_trip_desc *td;
struct thermal_instance *instance; struct thermal_instance *instance;
lockdep_assert_held(&tz->lock); lockdep_assert_held(&tz->lock);
thermal_zone_trip_update(tz, trip); /*
* Throttling Logic: Use the trend of the thermal zone to throttle.
* If the thermal zone is 'heating up', throttle all of the cooling
* devices associated with each trip point by one step. If the zone
* is 'cooling down', it brings back the performance of the devices
* by one step.
*/
for_each_trip_desc(tz, td) {
const struct thermal_trip *trip = &td->trip;
if (trip->temperature == THERMAL_TEMP_INVALID ||
trip->type == THERMAL_TRIP_CRITICAL ||
trip->type == THERMAL_TRIP_HOT)
continue;
thermal_zone_trip_update(tz, trip, td->threshold);
}
list_for_each_entry(instance, &tz->thermal_instances, tz_node) list_for_each_entry(instance, &tz->thermal_instances, tz_node)
thermal_cdev_update(instance->cdev); thermal_cdev_update(instance->cdev);
return 0;
} }
static struct thermal_governor thermal_gov_step_wise = { static struct thermal_governor thermal_gov_step_wise = {
.name = "step_wise", .name = "step_wise",
.throttle = step_wise_throttle, .manage = step_wise_manage,
}; };
THERMAL_GOVERNOR_DECLARE(thermal_gov_step_wise); THERMAL_GOVERNOR_DECLARE(thermal_gov_step_wise);
...@@ -26,11 +26,13 @@ static int user_space_bind(struct thermal_zone_device *tz) ...@@ -26,11 +26,13 @@ static int user_space_bind(struct thermal_zone_device *tz)
* notify_user_space - Notifies user space about thermal events * notify_user_space - Notifies user space about thermal events
* @tz: thermal_zone_device * @tz: thermal_zone_device
* @trip: trip point * @trip: trip point
* @crossed_up: whether or not the trip has been crossed on the way up
* *
* This function notifies the user space through UEvents. * This function notifies the user space through UEvents.
*/ */
static int notify_user_space(struct thermal_zone_device *tz, static void notify_user_space(struct thermal_zone_device *tz,
const struct thermal_trip *trip) const struct thermal_trip *trip,
bool crossed_up)
{ {
char *thermal_prop[5]; char *thermal_prop[5];
int i; int i;
...@@ -46,13 +48,11 @@ static int notify_user_space(struct thermal_zone_device *tz, ...@@ -46,13 +48,11 @@ static int notify_user_space(struct thermal_zone_device *tz,
kobject_uevent_env(&tz->device.kobj, KOBJ_CHANGE, thermal_prop); kobject_uevent_env(&tz->device.kobj, KOBJ_CHANGE, thermal_prop);
for (i = 0; i < 4; ++i) for (i = 0; i < 4; ++i)
kfree(thermal_prop[i]); kfree(thermal_prop[i]);
return 0;
} }
static struct thermal_governor thermal_gov_user_space = { static struct thermal_governor thermal_gov_user_space = {
.name = "user_space", .name = "user_space",
.throttle = notify_user_space, .trip_crossed = notify_user_space,
.bind_to_tz = user_space_bind, .bind_to_tz = user_space_bind,
}; };
THERMAL_GOVERNOR_DECLARE(thermal_gov_user_space); THERMAL_GOVERNOR_DECLARE(thermal_gov_user_space);
...@@ -296,17 +296,18 @@ static void monitor_thermal_zone(struct thermal_zone_device *tz) ...@@ -296,17 +296,18 @@ static void monitor_thermal_zone(struct thermal_zone_device *tz)
{ {
if (tz->mode != THERMAL_DEVICE_ENABLED) if (tz->mode != THERMAL_DEVICE_ENABLED)
thermal_zone_device_set_polling(tz, 0); thermal_zone_device_set_polling(tz, 0);
else if (tz->passive) else if (tz->passive > 0)
thermal_zone_device_set_polling(tz, tz->passive_delay_jiffies); thermal_zone_device_set_polling(tz, tz->passive_delay_jiffies);
else if (tz->polling_delay_jiffies) else if (tz->polling_delay_jiffies)
thermal_zone_device_set_polling(tz, tz->polling_delay_jiffies); thermal_zone_device_set_polling(tz, tz->polling_delay_jiffies);
} }
static void handle_non_critical_trips(struct thermal_zone_device *tz, static struct thermal_governor *thermal_get_tz_governor(struct thermal_zone_device *tz)
const struct thermal_trip *trip)
{ {
tz->governor ? tz->governor->throttle(tz, trip) : if (tz->governor)
def_governor->throttle(tz, trip); return tz->governor;
return def_governor;
} }
void thermal_governor_update_tz(struct thermal_zone_device *tz, void thermal_governor_update_tz(struct thermal_zone_device *tz,
...@@ -349,10 +350,6 @@ void thermal_zone_device_critical_reboot(struct thermal_zone_device *tz) ...@@ -349,10 +350,6 @@ void thermal_zone_device_critical_reboot(struct thermal_zone_device *tz)
static void handle_critical_trips(struct thermal_zone_device *tz, static void handle_critical_trips(struct thermal_zone_device *tz,
const struct thermal_trip *trip) const struct thermal_trip *trip)
{ {
/* If we have not crossed the trip_temp, we do not care. */
if (trip->temperature <= 0 || tz->temperature < trip->temperature)
return;
trace_thermal_zone_trip(tz, thermal_zone_trip_id(tz, trip), trip->type); trace_thermal_zone_trip(tz, thermal_zone_trip_id(tz, trip), trip->type);
if (trip->type == THERMAL_TRIP_CRITICAL) if (trip->type == THERMAL_TRIP_CRITICAL)
...@@ -392,6 +389,11 @@ static void handle_thermal_trip(struct thermal_zone_device *tz, ...@@ -392,6 +389,11 @@ static void handle_thermal_trip(struct thermal_zone_device *tz,
if (tz->temperature < trip->temperature - trip->hysteresis) { if (tz->temperature < trip->temperature - trip->hysteresis) {
list_add(&td->notify_list_node, way_down_list); list_add(&td->notify_list_node, way_down_list);
td->notify_temp = trip->temperature - trip->hysteresis; td->notify_temp = trip->temperature - trip->hysteresis;
if (trip->type == THERMAL_TRIP_PASSIVE) {
tz->passive--;
WARN_ON(tz->passive < 0);
}
} else { } else {
td->threshold -= trip->hysteresis; td->threshold -= trip->hysteresis;
} }
...@@ -404,12 +406,13 @@ static void handle_thermal_trip(struct thermal_zone_device *tz, ...@@ -404,12 +406,13 @@ static void handle_thermal_trip(struct thermal_zone_device *tz,
list_add_tail(&td->notify_list_node, way_up_list); list_add_tail(&td->notify_list_node, way_up_list);
td->notify_temp = trip->temperature; td->notify_temp = trip->temperature;
td->threshold -= trip->hysteresis; td->threshold -= trip->hysteresis;
}
if (trip->type == THERMAL_TRIP_CRITICAL || trip->type == THERMAL_TRIP_HOT) if (trip->type == THERMAL_TRIP_PASSIVE)
handle_critical_trips(tz, trip); tz->passive++;
else else if (trip->type == THERMAL_TRIP_CRITICAL ||
handle_non_critical_trips(tz, trip); trip->type == THERMAL_TRIP_HOT)
handle_critical_trips(tz, trip);
}
} }
static void update_temperature(struct thermal_zone_device *tz) static void update_temperature(struct thermal_zone_device *tz)
...@@ -431,7 +434,6 @@ static void update_temperature(struct thermal_zone_device *tz) ...@@ -431,7 +434,6 @@ static void update_temperature(struct thermal_zone_device *tz)
trace_thermal_temperature(tz); trace_thermal_temperature(tz);
thermal_genl_sampling_temp(tz->id, temp); thermal_genl_sampling_temp(tz->id, temp);
thermal_debug_update_temp(tz);
} }
static void thermal_zone_device_check(struct work_struct *work) static void thermal_zone_device_check(struct work_struct *work)
...@@ -449,12 +451,22 @@ static void thermal_zone_device_init(struct thermal_zone_device *tz) ...@@ -449,12 +451,22 @@ static void thermal_zone_device_init(struct thermal_zone_device *tz)
INIT_DELAYED_WORK(&tz->poll_queue, thermal_zone_device_check); INIT_DELAYED_WORK(&tz->poll_queue, thermal_zone_device_check);
tz->temperature = THERMAL_TEMP_INVALID; tz->temperature = THERMAL_TEMP_INVALID;
tz->passive = 0;
tz->prev_low_trip = -INT_MAX; tz->prev_low_trip = -INT_MAX;
tz->prev_high_trip = INT_MAX; tz->prev_high_trip = INT_MAX;
list_for_each_entry(pos, &tz->thermal_instances, tz_node) list_for_each_entry(pos, &tz->thermal_instances, tz_node)
pos->initialized = false; pos->initialized = false;
} }
static void thermal_governor_trip_crossed(struct thermal_governor *governor,
struct thermal_zone_device *tz,
const struct thermal_trip *trip,
bool crossed_up)
{
if (governor->trip_crossed)
governor->trip_crossed(tz, trip, crossed_up);
}
static int thermal_trip_notify_cmp(void *ascending, const struct list_head *a, static int thermal_trip_notify_cmp(void *ascending, const struct list_head *a,
const struct list_head *b) const struct list_head *b)
{ {
...@@ -470,6 +482,7 @@ static int thermal_trip_notify_cmp(void *ascending, const struct list_head *a, ...@@ -470,6 +482,7 @@ static int thermal_trip_notify_cmp(void *ascending, const struct list_head *a,
void __thermal_zone_device_update(struct thermal_zone_device *tz, void __thermal_zone_device_update(struct thermal_zone_device *tz,
enum thermal_notify_event event) enum thermal_notify_event event)
{ {
struct thermal_governor *governor = thermal_get_tz_governor(tz);
struct thermal_trip_desc *td; struct thermal_trip_desc *td;
LIST_HEAD(way_down_list); LIST_HEAD(way_down_list);
LIST_HEAD(way_up_list); LIST_HEAD(way_up_list);
...@@ -482,6 +495,9 @@ void __thermal_zone_device_update(struct thermal_zone_device *tz, ...@@ -482,6 +495,9 @@ void __thermal_zone_device_update(struct thermal_zone_device *tz,
update_temperature(tz); update_temperature(tz);
if (tz->temperature == THERMAL_TEMP_INVALID)
return;
__thermal_zone_set_trips(tz); __thermal_zone_set_trips(tz);
tz->notify_event = event; tz->notify_event = event;
...@@ -493,14 +509,21 @@ void __thermal_zone_device_update(struct thermal_zone_device *tz, ...@@ -493,14 +509,21 @@ void __thermal_zone_device_update(struct thermal_zone_device *tz,
list_for_each_entry(td, &way_up_list, notify_list_node) { list_for_each_entry(td, &way_up_list, notify_list_node) {
thermal_notify_tz_trip_up(tz, &td->trip); thermal_notify_tz_trip_up(tz, &td->trip);
thermal_debug_tz_trip_up(tz, &td->trip); thermal_debug_tz_trip_up(tz, &td->trip);
thermal_governor_trip_crossed(governor, tz, &td->trip, true);
} }
list_sort(NULL, &way_down_list, thermal_trip_notify_cmp); list_sort(NULL, &way_down_list, thermal_trip_notify_cmp);
list_for_each_entry(td, &way_down_list, notify_list_node) { list_for_each_entry(td, &way_down_list, notify_list_node) {
thermal_notify_tz_trip_down(tz, &td->trip); thermal_notify_tz_trip_down(tz, &td->trip);
thermal_debug_tz_trip_down(tz, &td->trip); thermal_debug_tz_trip_down(tz, &td->trip);
thermal_governor_trip_crossed(governor, tz, &td->trip, false);
} }
if (governor->manage)
governor->manage(tz);
thermal_debug_update_trip_stats(tz);
monitor_thermal_zone(tz); monitor_thermal_zone(tz);
} }
...@@ -923,6 +946,7 @@ __thermal_cooling_device_register(struct device_node *np, ...@@ -923,6 +946,7 @@ __thermal_cooling_device_register(struct device_node *np,
{ {
struct thermal_cooling_device *cdev; struct thermal_cooling_device *cdev;
struct thermal_zone_device *pos = NULL; struct thermal_zone_device *pos = NULL;
unsigned long current_state;
int id, ret; int id, ret;
if (!ops || !ops->get_max_state || !ops->get_cur_state || if (!ops || !ops->get_max_state || !ops->get_cur_state ||
...@@ -960,6 +984,10 @@ __thermal_cooling_device_register(struct device_node *np, ...@@ -960,6 +984,10 @@ __thermal_cooling_device_register(struct device_node *np,
if (ret) if (ret)
goto out_cdev_type; goto out_cdev_type;
ret = cdev->ops->get_cur_state(cdev, &current_state);
if (ret)
goto out_cdev_type;
thermal_cooling_device_setup_sysfs(cdev); thermal_cooling_device_setup_sysfs(cdev);
ret = dev_set_name(&cdev->device, "cooling_device%d", cdev->id); ret = dev_set_name(&cdev->device, "cooling_device%d", cdev->id);
...@@ -973,6 +1001,8 @@ __thermal_cooling_device_register(struct device_node *np, ...@@ -973,6 +1001,8 @@ __thermal_cooling_device_register(struct device_node *np,
return ERR_PTR(ret); return ERR_PTR(ret);
} }
thermal_debug_cdev_add(cdev, current_state);
/* Add 'this' new cdev to the global cdev list */ /* Add 'this' new cdev to the global cdev list */
mutex_lock(&thermal_list_lock); mutex_lock(&thermal_list_lock);
...@@ -988,8 +1018,6 @@ __thermal_cooling_device_register(struct device_node *np, ...@@ -988,8 +1018,6 @@ __thermal_cooling_device_register(struct device_node *np,
mutex_unlock(&thermal_list_lock); mutex_unlock(&thermal_list_lock);
thermal_debug_cdev_add(cdev);
return cdev; return cdev;
out_cooling_dev: out_cooling_dev:
......
...@@ -30,8 +30,8 @@ struct thermal_trip_desc { ...@@ -30,8 +30,8 @@ struct thermal_trip_desc {
* otherwise it fails. * otherwise it fails.
* @unbind_from_tz: callback called when a governor is unbound from a * @unbind_from_tz: callback called when a governor is unbound from a
* thermal zone. * thermal zone.
* @throttle: callback called for every trip point even if temperature is * @trip_crossed: called for trip points that have just been crossed
* below the trip point temperature * @manage: called on thermal zone temperature updates
* @update_tz: callback called when thermal zone internals have changed, e.g. * @update_tz: callback called when thermal zone internals have changed, e.g.
* thermal cooling instance was added/removed * thermal cooling instance was added/removed
* @governor_list: node in thermal_governor_list (in thermal_core.c) * @governor_list: node in thermal_governor_list (in thermal_core.c)
...@@ -40,8 +40,10 @@ struct thermal_governor { ...@@ -40,8 +40,10 @@ struct thermal_governor {
const char *name; const char *name;
int (*bind_to_tz)(struct thermal_zone_device *tz); int (*bind_to_tz)(struct thermal_zone_device *tz);
void (*unbind_from_tz)(struct thermal_zone_device *tz); void (*unbind_from_tz)(struct thermal_zone_device *tz);
int (*throttle)(struct thermal_zone_device *tz, void (*trip_crossed)(struct thermal_zone_device *tz,
const struct thermal_trip *trip); const struct thermal_trip *trip,
bool crossed_up);
void (*manage)(struct thermal_zone_device *tz);
void (*update_tz)(struct thermal_zone_device *tz, void (*update_tz)(struct thermal_zone_device *tz,
enum thermal_notify_event reason); enum thermal_notify_event reason);
struct list_head governor_list; struct list_head governor_list;
......
...@@ -435,6 +435,14 @@ void thermal_debug_cdev_state_update(const struct thermal_cooling_device *cdev, ...@@ -435,6 +435,14 @@ void thermal_debug_cdev_state_update(const struct thermal_cooling_device *cdev,
} }
cdev_dbg->current_state = new_state; cdev_dbg->current_state = new_state;
/*
* Create a record for the new state if it is not there, so its
* duration will be printed by cdev_dt_seq_show() as expected if it
* runs before the next state transition.
*/
thermal_debugfs_cdev_record_get(thermal_dbg, cdev_dbg->durations, new_state);
transition = (old_state << 16) | new_state; transition = (old_state << 16) | new_state;
/* /*
...@@ -460,8 +468,9 @@ void thermal_debug_cdev_state_update(const struct thermal_cooling_device *cdev, ...@@ -460,8 +468,9 @@ void thermal_debug_cdev_state_update(const struct thermal_cooling_device *cdev,
* Allocates a cooling device object for debug, initializes the * Allocates a cooling device object for debug, initializes the
* statistics and create the entries in sysfs. * statistics and create the entries in sysfs.
* @cdev: a pointer to a cooling device * @cdev: a pointer to a cooling device
* @state: current state of the cooling device
*/ */
void thermal_debug_cdev_add(struct thermal_cooling_device *cdev) void thermal_debug_cdev_add(struct thermal_cooling_device *cdev, int state)
{ {
struct thermal_debugfs *thermal_dbg; struct thermal_debugfs *thermal_dbg;
struct cdev_debugfs *cdev_dbg; struct cdev_debugfs *cdev_dbg;
...@@ -478,9 +487,16 @@ void thermal_debug_cdev_add(struct thermal_cooling_device *cdev) ...@@ -478,9 +487,16 @@ void thermal_debug_cdev_add(struct thermal_cooling_device *cdev)
INIT_LIST_HEAD(&cdev_dbg->durations[i]); INIT_LIST_HEAD(&cdev_dbg->durations[i]);
} }
cdev_dbg->current_state = 0; cdev_dbg->current_state = state;
cdev_dbg->timestamp = ktime_get(); cdev_dbg->timestamp = ktime_get();
/*
* Create a record for the initial cooling device state, so its
* duration will be printed by cdev_dt_seq_show() as expected if it
* runs before the first state transition.
*/
thermal_debugfs_cdev_record_get(thermal_dbg, cdev_dbg->durations, state);
debugfs_create_file("trans_table", 0400, thermal_dbg->d_top, debugfs_create_file("trans_table", 0400, thermal_dbg->d_top,
thermal_dbg, &tt_fops); thermal_dbg, &tt_fops);
...@@ -540,6 +556,7 @@ static struct tz_episode *thermal_debugfs_tz_event_alloc(struct thermal_zone_dev ...@@ -540,6 +556,7 @@ static struct tz_episode *thermal_debugfs_tz_event_alloc(struct thermal_zone_dev
INIT_LIST_HEAD(&tze->node); INIT_LIST_HEAD(&tze->node);
tze->timestamp = now; tze->timestamp = now;
tze->duration = KTIME_MIN;
for (i = 0; i < tz->num_trips; i++) { for (i = 0; i < tz->num_trips; i++) {
tze->trip_stats[i].min = INT_MAX; tze->trip_stats[i].min = INT_MAX;
...@@ -555,7 +572,6 @@ void thermal_debug_tz_trip_up(struct thermal_zone_device *tz, ...@@ -555,7 +572,6 @@ void thermal_debug_tz_trip_up(struct thermal_zone_device *tz,
struct tz_episode *tze; struct tz_episode *tze;
struct tz_debugfs *tz_dbg; struct tz_debugfs *tz_dbg;
struct thermal_debugfs *thermal_dbg = tz->debugfs; struct thermal_debugfs *thermal_dbg = tz->debugfs;
int temperature = tz->temperature;
int trip_id = thermal_zone_trip_id(tz, trip); int trip_id = thermal_zone_trip_id(tz, trip);
ktime_t now = ktime_get(); ktime_t now = ktime_get();
...@@ -624,12 +640,6 @@ void thermal_debug_tz_trip_up(struct thermal_zone_device *tz, ...@@ -624,12 +640,6 @@ void thermal_debug_tz_trip_up(struct thermal_zone_device *tz,
tze = list_first_entry(&tz_dbg->tz_episodes, struct tz_episode, node); tze = list_first_entry(&tz_dbg->tz_episodes, struct tz_episode, node);
tze->trip_stats[trip_id].timestamp = now; tze->trip_stats[trip_id].timestamp = now;
tze->trip_stats[trip_id].max = max(tze->trip_stats[trip_id].max, temperature);
tze->trip_stats[trip_id].min = min(tze->trip_stats[trip_id].min, temperature);
tze->trip_stats[trip_id].count++;
tze->trip_stats[trip_id].avg = tze->trip_stats[trip_id].avg +
(temperature - tze->trip_stats[trip_id].avg) /
tze->trip_stats[trip_id].count;
unlock: unlock:
mutex_unlock(&thermal_dbg->lock); mutex_unlock(&thermal_dbg->lock);
...@@ -682,6 +692,9 @@ void thermal_debug_tz_trip_down(struct thermal_zone_device *tz, ...@@ -682,6 +692,9 @@ void thermal_debug_tz_trip_down(struct thermal_zone_device *tz,
tze->trip_stats[trip_id].duration = tze->trip_stats[trip_id].duration =
ktime_add(delta, tze->trip_stats[trip_id].duration); ktime_add(delta, tze->trip_stats[trip_id].duration);
/* Mark the end of mitigation for this trip point. */
tze->trip_stats[trip_id].timestamp = KTIME_MAX;
/* /*
* This event closes the mitigation as we are crossing the * This event closes the mitigation as we are crossing the
* last trip point the way down. * last trip point the way down.
...@@ -693,12 +706,12 @@ void thermal_debug_tz_trip_down(struct thermal_zone_device *tz, ...@@ -693,12 +706,12 @@ void thermal_debug_tz_trip_down(struct thermal_zone_device *tz,
mutex_unlock(&thermal_dbg->lock); mutex_unlock(&thermal_dbg->lock);
} }
void thermal_debug_update_temp(struct thermal_zone_device *tz) void thermal_debug_update_trip_stats(struct thermal_zone_device *tz)
{ {
struct thermal_debugfs *thermal_dbg = tz->debugfs; struct thermal_debugfs *thermal_dbg = tz->debugfs;
struct tz_episode *tze;
struct tz_debugfs *tz_dbg; struct tz_debugfs *tz_dbg;
int trip_id, i; struct tz_episode *tze;
int i;
if (!thermal_dbg) if (!thermal_dbg)
return; return;
...@@ -710,15 +723,16 @@ void thermal_debug_update_temp(struct thermal_zone_device *tz) ...@@ -710,15 +723,16 @@ void thermal_debug_update_temp(struct thermal_zone_device *tz)
if (!tz_dbg->nr_trips) if (!tz_dbg->nr_trips)
goto out; goto out;
tze = list_first_entry(&tz_dbg->tz_episodes, struct tz_episode, node);
for (i = 0; i < tz_dbg->nr_trips; i++) { for (i = 0; i < tz_dbg->nr_trips; i++) {
trip_id = tz_dbg->trips_crossed[i]; int trip_id = tz_dbg->trips_crossed[i];
tze = list_first_entry(&tz_dbg->tz_episodes, struct tz_episode, node); struct trip_stats *trip_stats = &tze->trip_stats[trip_id];
tze->trip_stats[trip_id].count++;
tze->trip_stats[trip_id].max = max(tze->trip_stats[trip_id].max, tz->temperature); trip_stats->max = max(trip_stats->max, tz->temperature);
tze->trip_stats[trip_id].min = min(tze->trip_stats[trip_id].min, tz->temperature); trip_stats->min = min(trip_stats->min, tz->temperature);
tze->trip_stats[trip_id].avg = tze->trip_stats[trip_id].avg + trip_stats->avg += (tz->temperature - trip_stats->avg) /
(tz->temperature - tze->trip_stats[trip_id].avg) / ++trip_stats->count;
tze->trip_stats[trip_id].count;
} }
out: out:
mutex_unlock(&thermal_dbg->lock); mutex_unlock(&thermal_dbg->lock);
...@@ -756,18 +770,33 @@ static int tze_seq_show(struct seq_file *s, void *v) ...@@ -756,18 +770,33 @@ static int tze_seq_show(struct seq_file *s, void *v)
struct thermal_trip_desc *td; struct thermal_trip_desc *td;
struct tz_episode *tze; struct tz_episode *tze;
const char *type; const char *type;
u64 duration_ms;
int trip_id; int trip_id;
char c;
tze = list_entry((struct list_head *)v, struct tz_episode, node); tze = list_entry((struct list_head *)v, struct tz_episode, node);
seq_printf(s, ",-Mitigation at %lluus, duration=%llums\n", if (tze->duration == KTIME_MIN) {
ktime_to_us(tze->timestamp), /* Mitigation in progress. */
ktime_to_ms(tze->duration)); duration_ms = ktime_to_ms(ktime_sub(ktime_get(), tze->timestamp));
c = '>';
} else {
duration_ms = ktime_to_ms(tze->duration);
c = '=';
}
seq_printf(s, ",-Mitigation at %lluus, duration%c%llums\n",
ktime_to_us(tze->timestamp), c, duration_ms);
seq_printf(s, "| trip | type | temp(°mC) | hyst(°mC) | duration | avg(°mC) | min(°mC) | max(°mC) |\n"); seq_printf(s, "| trip | type | temp(°mC) | hyst(°mC) | duration | avg(°mC) | min(°mC) | max(°mC) |\n");
for_each_trip_desc(tz, td) { for_each_trip_desc(tz, td) {
const struct thermal_trip *trip = &td->trip; const struct thermal_trip *trip = &td->trip;
struct trip_stats *trip_stats;
/* Skip invalid trips. */
if (trip->temperature == THERMAL_TEMP_INVALID)
continue;
/* /*
* There is no possible mitigation happening at the * There is no possible mitigation happening at the
...@@ -777,6 +806,13 @@ static int tze_seq_show(struct seq_file *s, void *v) ...@@ -777,6 +806,13 @@ static int tze_seq_show(struct seq_file *s, void *v)
if (trip->type == THERMAL_TRIP_CRITICAL) if (trip->type == THERMAL_TRIP_CRITICAL)
continue; continue;
trip_id = thermal_zone_trip_id(tz, trip);
trip_stats = &tze->trip_stats[trip_id];
/* Skip trips without any stats. */
if (trip_stats->min > trip_stats->max)
continue;
if (trip->type == THERMAL_TRIP_PASSIVE) if (trip->type == THERMAL_TRIP_PASSIVE)
type = "passive"; type = "passive";
else if (trip->type == THERMAL_TRIP_ACTIVE) else if (trip->type == THERMAL_TRIP_ACTIVE)
...@@ -784,17 +820,28 @@ static int tze_seq_show(struct seq_file *s, void *v) ...@@ -784,17 +820,28 @@ static int tze_seq_show(struct seq_file *s, void *v)
else else
type = "hot"; type = "hot";
trip_id = thermal_zone_trip_id(tz, trip); if (trip_stats->timestamp != KTIME_MAX) {
/* Mitigation in progress. */
ktime_t delta = ktime_sub(ktime_get(),
trip_stats->timestamp);
delta = ktime_add(delta, trip_stats->duration);
duration_ms = ktime_to_ms(delta);
c = '>';
} else {
duration_ms = ktime_to_ms(trip_stats->duration);
c = ' ';
}
seq_printf(s, "| %*d | %*s | %*d | %*d | %*lld | %*d | %*d | %*d |\n", seq_printf(s, "| %*d | %*s | %*d | %*d | %c%*lld | %*d | %*d | %*d |\n",
4 , trip_id, 4 , trip_id,
8, type, 8, type,
9, trip->temperature, 9, trip->temperature,
9, trip->hysteresis, 9, trip->hysteresis,
10, ktime_to_ms(tze->trip_stats[trip_id].duration), c, 10, duration_ms,
9, tze->trip_stats[trip_id].avg, 9, trip_stats->avg,
9, tze->trip_stats[trip_id].min, 9, trip_stats->min,
9, tze->trip_stats[trip_id].max); 9, trip_stats->max);
} }
return 0; return 0;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#ifdef CONFIG_THERMAL_DEBUGFS #ifdef CONFIG_THERMAL_DEBUGFS
void thermal_debug_init(void); void thermal_debug_init(void);
void thermal_debug_cdev_add(struct thermal_cooling_device *cdev); void thermal_debug_cdev_add(struct thermal_cooling_device *cdev, int state);
void thermal_debug_cdev_remove(struct thermal_cooling_device *cdev); void thermal_debug_cdev_remove(struct thermal_cooling_device *cdev);
void thermal_debug_cdev_state_update(const struct thermal_cooling_device *cdev, int state); void thermal_debug_cdev_state_update(const struct thermal_cooling_device *cdev, int state);
void thermal_debug_tz_add(struct thermal_zone_device *tz); void thermal_debug_tz_add(struct thermal_zone_device *tz);
...@@ -11,10 +11,10 @@ void thermal_debug_tz_trip_up(struct thermal_zone_device *tz, ...@@ -11,10 +11,10 @@ void thermal_debug_tz_trip_up(struct thermal_zone_device *tz,
const struct thermal_trip *trip); const struct thermal_trip *trip);
void thermal_debug_tz_trip_down(struct thermal_zone_device *tz, void thermal_debug_tz_trip_down(struct thermal_zone_device *tz,
const struct thermal_trip *trip); const struct thermal_trip *trip);
void thermal_debug_update_temp(struct thermal_zone_device *tz); void thermal_debug_update_trip_stats(struct thermal_zone_device *tz);
#else #else
static inline void thermal_debug_init(void) {} static inline void thermal_debug_init(void) {}
static inline void thermal_debug_cdev_add(struct thermal_cooling_device *cdev) {} static inline void thermal_debug_cdev_add(struct thermal_cooling_device *cdev, int state) {}
static inline void thermal_debug_cdev_remove(struct thermal_cooling_device *cdev) {} static inline void thermal_debug_cdev_remove(struct thermal_cooling_device *cdev) {}
static inline void thermal_debug_cdev_state_update(const struct thermal_cooling_device *cdev, static inline void thermal_debug_cdev_state_update(const struct thermal_cooling_device *cdev,
int state) {} int state) {}
...@@ -24,5 +24,5 @@ static inline void thermal_debug_tz_trip_up(struct thermal_zone_device *tz, ...@@ -24,5 +24,5 @@ static inline void thermal_debug_tz_trip_up(struct thermal_zone_device *tz,
const struct thermal_trip *trip) {}; const struct thermal_trip *trip) {};
static inline void thermal_debug_tz_trip_down(struct thermal_zone_device *tz, static inline void thermal_debug_tz_trip_down(struct thermal_zone_device *tz,
const struct thermal_trip *trip) {} const struct thermal_trip *trip) {}
static inline void thermal_debug_update_temp(struct thermal_zone_device *tz) {} static inline void thermal_debug_update_trip_stats(struct thermal_zone_device *tz) {}
#endif /* CONFIG_THERMAL_DEBUGFS */ #endif /* CONFIG_THERMAL_DEBUGFS */
...@@ -138,6 +138,7 @@ int thermal_zone_trip_id(const struct thermal_zone_device *tz, ...@@ -138,6 +138,7 @@ int thermal_zone_trip_id(const struct thermal_zone_device *tz,
*/ */
return trip_to_trip_desc(trip) - tz->trips; return trip_to_trip_desc(trip) - tz->trips;
} }
void thermal_zone_trip_updated(struct thermal_zone_device *tz, void thermal_zone_trip_updated(struct thermal_zone_device *tz,
const struct thermal_trip *trip) const struct thermal_trip *trip)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment