Skip to content

Commit 61d8843

Browse files
committed
iwlwifi: mvm: Populate trip table before registering thermal zone
The trip table in iwl_mvm_thermal_zone_register() is populated after passing it to thermal_zone_device_register_with_trips(), so it may be accessed (for instance, via sysfs) before it is ready. To prevent that from happening, modify the function to populate the trip table before calling thermal_zone_device_register_with_trips(). Also make the code use THERMAL_TEMP_INVALID as the "invalid temperature" value which is also meaningful for the core. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Miri Korenblit <Miriam.rachel.korenblit@intel.com>
1 parent 2e171a5 commit 61d8843

File tree

1 file changed

+9
-10
lines changed
  • drivers/net/wireless/intel/iwlwifi/mvm

1 file changed

+9
-10
lines changed

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ int iwl_mvm_send_temp_report_ths_cmd(struct iwl_mvm *mvm)
575575

576576
/* compress trips to cmd array, remove uninitialized values*/
577577
for (i = 0; i < IWL_MAX_DTS_TRIPS; i++) {
578-
if (mvm->tz_device.trips[i].temperature != INT_MIN) {
578+
if (mvm->tz_device.trips[i].temperature != THERMAL_TEMP_INVALID) {
579579
cmd.thresholds[idx++] =
580580
cpu_to_le16((s16)(mvm->tz_device.trips[i].temperature / 1000));
581581
}
@@ -675,6 +675,14 @@ static void iwl_mvm_thermal_zone_register(struct iwl_mvm *mvm)
675675
BUILD_BUG_ON(ARRAY_SIZE(name) >= THERMAL_NAME_LENGTH);
676676

677677
sprintf(name, "iwlwifi_%u", atomic_inc_return(&counter) & 0xFF);
678+
/*
679+
* 0 is a valid temperature,
680+
* so initialize the array with S16_MIN which invalid temperature
681+
*/
682+
for (i = 0 ; i < IWL_MAX_DTS_TRIPS; i++) {
683+
mvm->tz_device.trips[i].temperature = THERMAL_TEMP_INVALID;
684+
mvm->tz_device.trips[i].type = THERMAL_TRIP_PASSIVE;
685+
}
678686
mvm->tz_device.tzone = thermal_zone_device_register_with_trips(name,
679687
mvm->tz_device.trips,
680688
IWL_MAX_DTS_TRIPS,
@@ -693,15 +701,6 @@ static void iwl_mvm_thermal_zone_register(struct iwl_mvm *mvm)
693701
if (ret) {
694702
IWL_DEBUG_TEMP(mvm, "Failed to enable thermal zone\n");
695703
thermal_zone_device_unregister(mvm->tz_device.tzone);
696-
return;
697-
}
698-
699-
/* 0 is a valid temperature,
700-
* so initialize the array with S16_MIN which invalid temperature
701-
*/
702-
for (i = 0 ; i < IWL_MAX_DTS_TRIPS; i++) {
703-
mvm->tz_device.trips[i].temperature = INT_MIN;
704-
mvm->tz_device.trips[i].type = THERMAL_TRIP_PASSIVE;
705704
}
706705
}
707706

0 commit comments

Comments
 (0)