Commit 2c8459a5 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

Merge branch 'thermal-core'

Merge thermal core changes for 6.9:

 - Minor fixes for thermal governors (Rafael J. Wysocki, Di Shen).

 - Trip point handling fixes for the iwlwifi wireless driver (Rafael J.
   Wysocki).

 - Code cleanups (Rafael J. Wysocki, AngeloGioacchino Del Regno).

* thermal-tmp:
  thermal: gov_power_allocator: Avoid overwriting PID coefficients from setup time
  thermal: sysfs: Fix up white space in trip_point_temp_store()
  iwlwifi: mvm: Use for_each_thermal_trip() for walking trip points
  iwlwifi: mvm: Populate trip table before registering thermal zone
  iwlwifi: mvm: Drop unused fw_trips_index[] from iwl_mvm_thermal_device
  thermal: core: Change governor name to const char pointer
  thermal: gov_bang_bang: Fix possible cooling device state ping-pong
  thermal: gov_fair_share: Fix dependency on trip points ordering
parents 7251b9e8 0fac6893
...@@ -539,12 +539,10 @@ struct iwl_mvm_tt_mgmt { ...@@ -539,12 +539,10 @@ struct iwl_mvm_tt_mgmt {
/** /**
*struct iwl_mvm_thermal_device - thermal zone related data *struct iwl_mvm_thermal_device - thermal zone related data
* @temp_trips: temperature thresholds for report * @temp_trips: temperature thresholds for report
* @fw_trips_index: keep indexes to original array - temp_trips
* @tzone: thermal zone device data * @tzone: thermal zone device data
*/ */
struct iwl_mvm_thermal_device { struct iwl_mvm_thermal_device {
struct thermal_trip trips[IWL_MAX_DTS_TRIPS]; struct thermal_trip trips[IWL_MAX_DTS_TRIPS];
u8 fw_trips_index[IWL_MAX_DTS_TRIPS];
struct thermal_zone_device *tzone; struct thermal_zone_device *tzone;
}; };
......
...@@ -555,6 +555,22 @@ static int compare_temps(const void *a, const void *b) ...@@ -555,6 +555,22 @@ static int compare_temps(const void *a, const void *b)
return ((s16)le16_to_cpu(*(__le16 *)a) - return ((s16)le16_to_cpu(*(__le16 *)a) -
(s16)le16_to_cpu(*(__le16 *)b)); (s16)le16_to_cpu(*(__le16 *)b));
} }
struct iwl_trip_walk_data {
__le16 *thresholds;
int count;
};
static int iwl_trip_temp_cb(struct thermal_trip *trip, void *arg)
{
struct iwl_trip_walk_data *twd = arg;
if (trip->temperature == THERMAL_TEMP_INVALID)
return 0;
twd->thresholds[twd->count++] = cpu_to_le16((s16)(trip->temperature / 1000));
return 0;
}
#endif #endif
int iwl_mvm_send_temp_report_ths_cmd(struct iwl_mvm *mvm) int iwl_mvm_send_temp_report_ths_cmd(struct iwl_mvm *mvm)
...@@ -562,42 +578,25 @@ int iwl_mvm_send_temp_report_ths_cmd(struct iwl_mvm *mvm) ...@@ -562,42 +578,25 @@ int iwl_mvm_send_temp_report_ths_cmd(struct iwl_mvm *mvm)
struct temp_report_ths_cmd cmd = {0}; struct temp_report_ths_cmd cmd = {0};
int ret; int ret;
#ifdef CONFIG_THERMAL #ifdef CONFIG_THERMAL
int i, j, idx = 0; struct iwl_trip_walk_data twd = { .thresholds = cmd.thresholds, .count = 0 };
lockdep_assert_held(&mvm->mutex); lockdep_assert_held(&mvm->mutex);
if (!mvm->tz_device.tzone) if (!mvm->tz_device.tzone)
goto send; goto send;
/* The driver holds array of temperature trips that are unsorted /*
* and uncompressed, the FW should get it compressed and sorted * The thermal core holds an array of temperature trips that are
* unsorted and uncompressed, the FW should get it compressed and
* sorted.
*/ */
/* compress trips to cmd array, remove uninitialized values*/ /* compress trips to cmd array, remove uninitialized values*/
for (i = 0; i < IWL_MAX_DTS_TRIPS; i++) { for_each_thermal_trip(mvm->tz_device.tzone, iwl_trip_temp_cb, &twd);
if (mvm->tz_device.trips[i].temperature != INT_MIN) {
cmd.thresholds[idx++] =
cpu_to_le16((s16)(mvm->tz_device.trips[i].temperature / 1000));
}
}
cmd.num_temps = cpu_to_le32(idx);
if (!idx) cmd.num_temps = cpu_to_le32(twd.count);
goto send; if (twd.count)
sort(cmd.thresholds, twd.count, sizeof(s16), compare_temps, NULL);
/*sort cmd array*/
sort(cmd.thresholds, idx, sizeof(s16), compare_temps, NULL);
/* we should save the indexes of trips because we sort
* and compress the orginal array
*/
for (i = 0; i < idx; i++) {
for (j = 0; j < IWL_MAX_DTS_TRIPS; j++) {
if ((int)(le16_to_cpu(cmd.thresholds[i]) * 1000) ==
mvm->tz_device.trips[j].temperature)
mvm->tz_device.fw_trips_index[i] = j;
}
}
send: send:
#endif #endif
...@@ -686,6 +685,14 @@ static void iwl_mvm_thermal_zone_register(struct iwl_mvm *mvm) ...@@ -686,6 +685,14 @@ static void iwl_mvm_thermal_zone_register(struct iwl_mvm *mvm)
BUILD_BUG_ON(ARRAY_SIZE(name) >= THERMAL_NAME_LENGTH); BUILD_BUG_ON(ARRAY_SIZE(name) >= THERMAL_NAME_LENGTH);
sprintf(name, "iwlwifi_%u", atomic_inc_return(&counter) & 0xFF); sprintf(name, "iwlwifi_%u", atomic_inc_return(&counter) & 0xFF);
/*
* 0 is a valid temperature,
* so initialize the array with S16_MIN which invalid temperature
*/
for (i = 0 ; i < IWL_MAX_DTS_TRIPS; i++) {
mvm->tz_device.trips[i].temperature = THERMAL_TEMP_INVALID;
mvm->tz_device.trips[i].type = THERMAL_TRIP_PASSIVE;
}
mvm->tz_device.tzone = thermal_zone_device_register_with_trips(name, mvm->tz_device.tzone = thermal_zone_device_register_with_trips(name,
mvm->tz_device.trips, mvm->tz_device.trips,
IWL_MAX_DTS_TRIPS, IWL_MAX_DTS_TRIPS,
...@@ -704,15 +711,6 @@ static void iwl_mvm_thermal_zone_register(struct iwl_mvm *mvm) ...@@ -704,15 +711,6 @@ static void iwl_mvm_thermal_zone_register(struct iwl_mvm *mvm)
if (ret) { if (ret) {
IWL_DEBUG_TEMP(mvm, "Failed to enable thermal zone\n"); IWL_DEBUG_TEMP(mvm, "Failed to enable thermal zone\n");
thermal_zone_device_unregister(mvm->tz_device.tzone); thermal_zone_device_unregister(mvm->tz_device.tzone);
return;
}
/* 0 is a valid temperature,
* so initialize the array with S16_MIN which invalid temperature
*/
for (i = 0 ; i < IWL_MAX_DTS_TRIPS; i++) {
mvm->tz_device.trips[i].temperature = INT_MIN;
mvm->tz_device.trips[i].type = THERMAL_TRIP_PASSIVE;
} }
} }
......
...@@ -49,7 +49,7 @@ static int thermal_zone_trip_update(struct thermal_zone_device *tz, ...@@ -49,7 +49,7 @@ static int thermal_zone_trip_update(struct thermal_zone_device *tz,
if (instance->target == 0 && tz->temperature >= trip->temperature) if (instance->target == 0 && tz->temperature >= trip->temperature)
instance->target = 1; instance->target = 1;
else if (instance->target == 1 && else if (instance->target == 1 &&
tz->temperature <= trip->temperature - trip->hysteresis) tz->temperature < trip->temperature - trip->hysteresis)
instance->target = 0; instance->target = 0;
dev_dbg(&instance->cdev->device, "target=%d\n", dev_dbg(&instance->cdev->device, "target=%d\n",
......
...@@ -18,22 +18,24 @@ ...@@ -18,22 +18,24 @@
static int get_trip_level(struct thermal_zone_device *tz) static int get_trip_level(struct thermal_zone_device *tz)
{ {
const struct thermal_trip *trip, *level_trip = NULL; const struct thermal_trip *trip, *level_trip = NULL;
int trip_level; int trip_level = -1;
for_each_trip(tz, trip) { for_each_trip(tz, trip) {
if (trip->temperature >= tz->temperature) if (trip->temperature >= tz->temperature)
break; continue;
trip_level++;
if (!level_trip || trip->temperature > level_trip->temperature)
level_trip = trip; level_trip = trip;
} }
/* Bail out if the temperature is not greater than any trips. */ /* Bail out if the temperature is not greater than any trips. */
if (!level_trip) if (trip_level < 0)
return 0; return 0;
trip_level = thermal_zone_trip_id(tz, level_trip); trace_thermal_zone_trip(tz, thermal_zone_trip_id(tz, level_trip),
level_trip->type);
trace_thermal_zone_trip(tz, trip_level, level_trip->type);
return trip_level; return trip_level;
} }
......
...@@ -711,6 +711,8 @@ static int power_allocator_bind(struct thermal_zone_device *tz) ...@@ -711,6 +711,8 @@ static int power_allocator_bind(struct thermal_zone_device *tz)
if (!tz->tzp->sustainable_power) if (!tz->tzp->sustainable_power)
dev_warn(&tz->device, "power_allocator: sustainable_power will be estimated\n"); dev_warn(&tz->device, "power_allocator: sustainable_power will be estimated\n");
else
params->sustainable_power = tz->tzp->sustainable_power;
estimate_pid_constants(tz, tz->tzp->sustainable_power, estimate_pid_constants(tz, tz->tzp->sustainable_power,
params->trip_switch_on, params->trip_switch_on,
......
...@@ -214,7 +214,7 @@ struct thermal_zone_device { ...@@ -214,7 +214,7 @@ struct thermal_zone_device {
* @governor_list: node in thermal_governor_list (in thermal_core.c) * @governor_list: node in thermal_governor_list (in thermal_core.c)
*/ */
struct thermal_governor { struct thermal_governor {
char name[THERMAL_NAME_LENGTH]; 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, int (*throttle)(struct thermal_zone_device *tz,
...@@ -226,7 +226,7 @@ struct thermal_governor { ...@@ -226,7 +226,7 @@ struct thermal_governor {
/* Structure to define Thermal Zone parameters */ /* Structure to define Thermal Zone parameters */
struct thermal_zone_params { struct thermal_zone_params {
char governor_name[THERMAL_NAME_LENGTH]; const char *governor_name;
/* /*
* a boolean to indicate if the thermal to hwmon sysfs interface * a boolean to indicate if the thermal to hwmon sysfs interface
......
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