summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2024-02-07 20:10:24 +0100
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2024-02-08 14:54:55 +0100
commit61d88437546f5f40b6411aac17c55d0298c7a19d (patch)
treed6a441c61333e65dc7a6e9ac8d5db35c3c6223ff
parent2e171a57c312cb732d633c5ccc51551588b7a855 (diff)
downloadlinux-stable-61d88437546f5f40b6411aac17c55d0298c7a19d.tar.gz
linux-stable-61d88437546f5f40b6411aac17c55d0298c7a19d.tar.bz2
linux-stable-61d88437546f5f40b6411aac17c55d0298c7a19d.zip
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>
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/tt.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
index a2f921a1f5bd..4fcbf02b415e 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
@@ -575,7 +575,7 @@ int iwl_mvm_send_temp_report_ths_cmd(struct iwl_mvm *mvm)
/* compress trips to cmd array, remove uninitialized values*/
for (i = 0; i < IWL_MAX_DTS_TRIPS; i++) {
- if (mvm->tz_device.trips[i].temperature != INT_MIN) {
+ if (mvm->tz_device.trips[i].temperature != THERMAL_TEMP_INVALID) {
cmd.thresholds[idx++] =
cpu_to_le16((s16)(mvm->tz_device.trips[i].temperature / 1000));
}
@@ -675,6 +675,14 @@ static void iwl_mvm_thermal_zone_register(struct iwl_mvm *mvm)
BUILD_BUG_ON(ARRAY_SIZE(name) >= THERMAL_NAME_LENGTH);
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.trips,
IWL_MAX_DTS_TRIPS,
@@ -693,15 +701,6 @@ static void iwl_mvm_thermal_zone_register(struct iwl_mvm *mvm)
if (ret) {
IWL_DEBUG_TEMP(mvm, "Failed to enable thermal zone\n");
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;
}
}