Skip to content

Commit 2c8459a

Browse files
committed
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
2 parents 7251b9e + 0fac689 commit 2c8459a

File tree

7 files changed

+48
-48
lines changed

7 files changed

+48
-48
lines changed

drivers/net/wireless/intel/iwlwifi/mvm/mvm.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,12 +539,10 @@ struct iwl_mvm_tt_mgmt {
539539
/**
540540
*struct iwl_mvm_thermal_device - thermal zone related data
541541
* @temp_trips: temperature thresholds for report
542-
* @fw_trips_index: keep indexes to original array - temp_trips
543542
* @tzone: thermal zone device data
544543
*/
545544
struct iwl_mvm_thermal_device {
546545
struct thermal_trip trips[IWL_MAX_DTS_TRIPS];
547-
u8 fw_trips_index[IWL_MAX_DTS_TRIPS];
548546
struct thermal_zone_device *tzone;
549547
};
550548

drivers/net/wireless/intel/iwlwifi/mvm/tt.c

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -555,49 +555,48 @@ static int compare_temps(const void *a, const void *b)
555555
return ((s16)le16_to_cpu(*(__le16 *)a) -
556556
(s16)le16_to_cpu(*(__le16 *)b));
557557
}
558+
559+
struct iwl_trip_walk_data {
560+
__le16 *thresholds;
561+
int count;
562+
};
563+
564+
static int iwl_trip_temp_cb(struct thermal_trip *trip, void *arg)
565+
{
566+
struct iwl_trip_walk_data *twd = arg;
567+
568+
if (trip->temperature == THERMAL_TEMP_INVALID)
569+
return 0;
570+
571+
twd->thresholds[twd->count++] = cpu_to_le16((s16)(trip->temperature / 1000));
572+
return 0;
573+
}
558574
#endif
559575

560576
int iwl_mvm_send_temp_report_ths_cmd(struct iwl_mvm *mvm)
561577
{
562578
struct temp_report_ths_cmd cmd = {0};
563579
int ret;
564580
#ifdef CONFIG_THERMAL
565-
int i, j, idx = 0;
581+
struct iwl_trip_walk_data twd = { .thresholds = cmd.thresholds, .count = 0 };
566582

567583
lockdep_assert_held(&mvm->mutex);
568584

569585
if (!mvm->tz_device.tzone)
570586
goto send;
571587

572-
/* The driver holds array of temperature trips that are unsorted
573-
* and uncompressed, the FW should get it compressed and sorted
588+
/*
589+
* The thermal core holds an array of temperature trips that are
590+
* unsorted and uncompressed, the FW should get it compressed and
591+
* sorted.
574592
*/
575593

576594
/* compress trips to cmd array, remove uninitialized values*/
577-
for (i = 0; i < IWL_MAX_DTS_TRIPS; i++) {
578-
if (mvm->tz_device.trips[i].temperature != INT_MIN) {
579-
cmd.thresholds[idx++] =
580-
cpu_to_le16((s16)(mvm->tz_device.trips[i].temperature / 1000));
581-
}
582-
}
583-
cmd.num_temps = cpu_to_le32(idx);
595+
for_each_thermal_trip(mvm->tz_device.tzone, iwl_trip_temp_cb, &twd);
584596

585-
if (!idx)
586-
goto send;
587-
588-
/*sort cmd array*/
589-
sort(cmd.thresholds, idx, sizeof(s16), compare_temps, NULL);
590-
591-
/* we should save the indexes of trips because we sort
592-
* and compress the orginal array
593-
*/
594-
for (i = 0; i < idx; i++) {
595-
for (j = 0; j < IWL_MAX_DTS_TRIPS; j++) {
596-
if ((int)(le16_to_cpu(cmd.thresholds[i]) * 1000) ==
597-
mvm->tz_device.trips[j].temperature)
598-
mvm->tz_device.fw_trips_index[i] = j;
599-
}
600-
}
597+
cmd.num_temps = cpu_to_le32(twd.count);
598+
if (twd.count)
599+
sort(cmd.thresholds, twd.count, sizeof(s16), compare_temps, NULL);
601600

602601
send:
603602
#endif
@@ -686,6 +685,14 @@ static void iwl_mvm_thermal_zone_register(struct iwl_mvm *mvm)
686685
BUILD_BUG_ON(ARRAY_SIZE(name) >= THERMAL_NAME_LENGTH);
687686

688687
sprintf(name, "iwlwifi_%u", atomic_inc_return(&counter) & 0xFF);
688+
/*
689+
* 0 is a valid temperature,
690+
* so initialize the array with S16_MIN which invalid temperature
691+
*/
692+
for (i = 0 ; i < IWL_MAX_DTS_TRIPS; i++) {
693+
mvm->tz_device.trips[i].temperature = THERMAL_TEMP_INVALID;
694+
mvm->tz_device.trips[i].type = THERMAL_TRIP_PASSIVE;
695+
}
689696
mvm->tz_device.tzone = thermal_zone_device_register_with_trips(name,
690697
mvm->tz_device.trips,
691698
IWL_MAX_DTS_TRIPS,
@@ -704,15 +711,6 @@ static void iwl_mvm_thermal_zone_register(struct iwl_mvm *mvm)
704711
if (ret) {
705712
IWL_DEBUG_TEMP(mvm, "Failed to enable thermal zone\n");
706713
thermal_zone_device_unregister(mvm->tz_device.tzone);
707-
return;
708-
}
709-
710-
/* 0 is a valid temperature,
711-
* so initialize the array with S16_MIN which invalid temperature
712-
*/
713-
for (i = 0 ; i < IWL_MAX_DTS_TRIPS; i++) {
714-
mvm->tz_device.trips[i].temperature = INT_MIN;
715-
mvm->tz_device.trips[i].type = THERMAL_TRIP_PASSIVE;
716714
}
717715
}
718716

drivers/thermal/gov_bang_bang.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static int thermal_zone_trip_update(struct thermal_zone_device *tz,
4949
if (instance->target == 0 && tz->temperature >= trip->temperature)
5050
instance->target = 1;
5151
else if (instance->target == 1 &&
52-
tz->temperature <= trip->temperature - trip->hysteresis)
52+
tz->temperature < trip->temperature - trip->hysteresis)
5353
instance->target = 0;
5454

5555
dev_dbg(&instance->cdev->device, "target=%d\n",

drivers/thermal/gov_fair_share.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,24 @@
1818
static int get_trip_level(struct thermal_zone_device *tz)
1919
{
2020
const struct thermal_trip *trip, *level_trip = NULL;
21-
int trip_level;
21+
int trip_level = -1;
2222

2323
for_each_trip(tz, trip) {
2424
if (trip->temperature >= tz->temperature)
25-
break;
25+
continue;
26+
27+
trip_level++;
2628

27-
level_trip = trip;
29+
if (!level_trip || trip->temperature > level_trip->temperature)
30+
level_trip = trip;
2831
}
2932

3033
/* Bail out if the temperature is not greater than any trips. */
31-
if (!level_trip)
34+
if (trip_level < 0)
3235
return 0;
3336

34-
trip_level = thermal_zone_trip_id(tz, level_trip);
35-
36-
trace_thermal_zone_trip(tz, trip_level, level_trip->type);
37+
trace_thermal_zone_trip(tz, thermal_zone_trip_id(tz, level_trip),
38+
level_trip->type);
3739

3840
return trip_level;
3941
}

drivers/thermal/gov_power_allocator.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,8 @@ static int power_allocator_bind(struct thermal_zone_device *tz)
711711

712712
if (!tz->tzp->sustainable_power)
713713
dev_warn(&tz->device, "power_allocator: sustainable_power will be estimated\n");
714+
else
715+
params->sustainable_power = tz->tzp->sustainable_power;
714716

715717
estimate_pid_constants(tz, tz->tzp->sustainable_power,
716718
params->trip_switch_on,

drivers/thermal/thermal_sysfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr,
136136

137137
unlock:
138138
mutex_unlock(&tz->lock);
139-
139+
140140
return ret ? ret : count;
141141
}
142142

include/linux/thermal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ struct thermal_zone_device {
214214
* @governor_list: node in thermal_governor_list (in thermal_core.c)
215215
*/
216216
struct thermal_governor {
217-
char name[THERMAL_NAME_LENGTH];
217+
const char *name;
218218
int (*bind_to_tz)(struct thermal_zone_device *tz);
219219
void (*unbind_from_tz)(struct thermal_zone_device *tz);
220220
int (*throttle)(struct thermal_zone_device *tz,
@@ -226,7 +226,7 @@ struct thermal_governor {
226226

227227
/* Structure to define Thermal Zone parameters */
228228
struct thermal_zone_params {
229-
char governor_name[THERMAL_NAME_LENGTH];
229+
const char *governor_name;
230230

231231
/*
232232
* a boolean to indicate if the thermal to hwmon sysfs interface

0 commit comments

Comments
 (0)