Lines Matching refs:mvm

13 void iwl_mvm_enter_ctkill(struct iwl_mvm *mvm)  in iwl_mvm_enter_ctkill()  argument
15 struct iwl_mvm_tt_mgmt *tt = &mvm->thermal_throttle; in iwl_mvm_enter_ctkill()
18 if (test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status)) in iwl_mvm_enter_ctkill()
21 IWL_ERR(mvm, "Enter CT Kill\n"); in iwl_mvm_enter_ctkill()
22 iwl_mvm_set_hw_ctkill_state(mvm, true); in iwl_mvm_enter_ctkill()
24 if (!iwl_mvm_is_tt_in_fw(mvm)) { in iwl_mvm_enter_ctkill()
33 if (!mvm->temperature_test) in iwl_mvm_enter_ctkill()
38 static void iwl_mvm_exit_ctkill(struct iwl_mvm *mvm) in iwl_mvm_exit_ctkill() argument
40 if (!test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status)) in iwl_mvm_exit_ctkill()
43 IWL_ERR(mvm, "Exit CT Kill\n"); in iwl_mvm_exit_ctkill()
44 iwl_mvm_set_hw_ctkill_state(mvm, false); in iwl_mvm_exit_ctkill()
47 static void iwl_mvm_tt_temp_changed(struct iwl_mvm *mvm, u32 temp) in iwl_mvm_tt_temp_changed() argument
50 if (mvm->temperature_test) in iwl_mvm_tt_temp_changed()
53 if (mvm->temperature == temp) in iwl_mvm_tt_temp_changed()
56 mvm->temperature = temp; in iwl_mvm_tt_temp_changed()
57 iwl_mvm_tt_handler(mvm); in iwl_mvm_tt_temp_changed()
60 static int iwl_mvm_temp_notif_parse(struct iwl_mvm *mvm, in iwl_mvm_temp_notif_parse() argument
71 IWL_ERR(mvm, "Invalid DTS_MEASUREMENT_NOTIFICATION\n"); in iwl_mvm_temp_notif_parse()
83 IWL_DEBUG_TEMP(mvm, "DTS_MEASUREMENT_NOTIFICATION - %d\n", temp); in iwl_mvm_temp_notif_parse()
91 struct iwl_mvm *mvm = in iwl_mvm_temp_notif_wait() local
96 ret = iwl_mvm_temp_notif_parse(mvm, pkt); in iwl_mvm_temp_notif_wait()
105 void iwl_mvm_temp_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb) in iwl_mvm_temp_notif() argument
114 if (test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status)) in iwl_mvm_temp_notif()
117 temp = iwl_mvm_temp_notif_parse(mvm, pkt); in iwl_mvm_temp_notif()
119 if (!iwl_mvm_is_tt_in_fw(mvm)) { in iwl_mvm_temp_notif()
121 iwl_mvm_tt_temp_changed(mvm, temp); in iwl_mvm_temp_notif()
126 IWL_ERR(mvm, "Invalid DTS_MEASUREMENT_NOTIFICATION\n"); in iwl_mvm_temp_notif()
139 IWL_DEBUG_TEMP(mvm, "Temp = %d Threshold crossed = %d\n", in iwl_mvm_temp_notif()
146 if (mvm->tz_device.tzone) { in iwl_mvm_temp_notif()
147 struct iwl_mvm_thermal_device *tz_dev = &mvm->tz_device; in iwl_mvm_temp_notif()
155 void iwl_mvm_ct_kill_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb) in iwl_mvm_ct_kill_notif() argument
161 IWL_DEBUG_TEMP(mvm, "CT Kill notification temperature = %d\n", in iwl_mvm_ct_kill_notif()
163 if (iwl_fw_lookup_notif_ver(mvm->fw, PHY_OPS_GROUP, in iwl_mvm_ct_kill_notif()
165 IWL_DEBUG_TEMP(mvm, in iwl_mvm_ct_kill_notif()
169 iwl_mvm_enter_ctkill(mvm); in iwl_mvm_ct_kill_notif()
176 static int iwl_mvm_send_temp_cmd(struct iwl_mvm *mvm, bool response, s32 *temp) in iwl_mvm_send_temp_cmd() argument
192 if (fw_has_capa(&mvm->fw->ucode_capa, in iwl_mvm_send_temp_cmd()
211 IWL_DEBUG_TEMP(mvm, in iwl_mvm_send_temp_cmd()
214 ret = iwl_mvm_send_cmd(mvm, &cmd); in iwl_mvm_send_temp_cmd()
217 IWL_ERR(mvm, in iwl_mvm_send_temp_cmd()
226 IWL_DEBUG_TEMP(mvm, in iwl_mvm_send_temp_cmd()
235 int iwl_mvm_get_temp(struct iwl_mvm *mvm, s32 *temp) in iwl_mvm_get_temp() argument
248 cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw, in iwl_mvm_get_temp()
252 return iwl_mvm_send_temp_cmd(mvm, true, temp); in iwl_mvm_get_temp()
254 lockdep_assert_held(&mvm->mutex); in iwl_mvm_get_temp()
256 iwl_init_notification_wait(&mvm->notif_wait, &wait_temp_notif, in iwl_mvm_get_temp()
260 ret = iwl_mvm_send_temp_cmd(mvm, false, temp); in iwl_mvm_get_temp()
262 iwl_remove_notification(&mvm->notif_wait, &wait_temp_notif); in iwl_mvm_get_temp()
266 ret = iwl_wait_notification(&mvm->notif_wait, &wait_temp_notif, in iwl_mvm_get_temp()
269 IWL_WARN(mvm, "Getting the temperature timed out\n"); in iwl_mvm_get_temp()
277 struct iwl_mvm *mvm; in check_exit_ctkill() local
283 mvm = container_of(tt, struct iwl_mvm, thermal_throttle); in check_exit_ctkill()
285 if (iwl_mvm_is_tt_in_fw(mvm)) { in check_exit_ctkill()
286 iwl_mvm_exit_ctkill(mvm); in check_exit_ctkill()
293 flush_work(&mvm->roc_done_wk); in check_exit_ctkill()
295 mutex_lock(&mvm->mutex); in check_exit_ctkill()
297 if (__iwl_mvm_mac_start(mvm)) in check_exit_ctkill()
300 ret = iwl_mvm_get_temp(mvm, &temp); in check_exit_ctkill()
302 __iwl_mvm_mac_stop(mvm); in check_exit_ctkill()
307 IWL_DEBUG_TEMP(mvm, "NIC temperature: %d\n", temp); in check_exit_ctkill()
310 mutex_unlock(&mvm->mutex); in check_exit_ctkill()
311 iwl_mvm_exit_ctkill(mvm); in check_exit_ctkill()
316 mutex_unlock(&mvm->mutex); in check_exit_ctkill()
317 schedule_delayed_work(&mvm->thermal_throttle.ct_kill_exit, in check_exit_ctkill()
324 struct iwl_mvm *mvm = _data; in iwl_mvm_tt_smps_iterator() local
327 lockdep_assert_held(&mvm->mutex); in iwl_mvm_tt_smps_iterator()
329 if (mvm->thermal_throttle.dynamic_smps) in iwl_mvm_tt_smps_iterator()
337 iwl_mvm_update_smps(mvm, vif, IWL_MVM_SMPS_REQ_TT, smps_mode); in iwl_mvm_tt_smps_iterator()
340 static void iwl_mvm_tt_tx_protection(struct iwl_mvm *mvm, bool enable) in iwl_mvm_tt_tx_protection() argument
345 for (i = 0; i < mvm->fw->ucode_capa.num_stations; i++) { in iwl_mvm_tt_tx_protection()
346 mvmsta = iwl_mvm_sta_from_staid_protected(mvm, i); in iwl_mvm_tt_tx_protection()
352 err = iwl_mvm_tx_protection(mvm, mvmsta, enable); in iwl_mvm_tt_tx_protection()
354 IWL_ERR(mvm, "Failed to %s Tx protection\n", in iwl_mvm_tt_tx_protection()
357 IWL_DEBUG_TEMP(mvm, "%s Tx protection\n", in iwl_mvm_tt_tx_protection()
364 void iwl_mvm_tt_tx_backoff(struct iwl_mvm *mvm, u32 backoff) in iwl_mvm_tt_tx_backoff() argument
372 backoff = max(backoff, mvm->thermal_throttle.min_backoff); in iwl_mvm_tt_tx_backoff()
374 if (iwl_mvm_send_cmd(mvm, &cmd) == 0) { in iwl_mvm_tt_tx_backoff()
375 IWL_DEBUG_TEMP(mvm, "Set Thermal Tx backoff to: %u\n", in iwl_mvm_tt_tx_backoff()
377 mvm->thermal_throttle.tx_backoff = backoff; in iwl_mvm_tt_tx_backoff()
379 IWL_ERR(mvm, "Failed to change Thermal Tx backoff\n"); in iwl_mvm_tt_tx_backoff()
383 void iwl_mvm_tt_handler(struct iwl_mvm *mvm) in iwl_mvm_tt_handler() argument
385 struct iwl_tt_params *params = &mvm->thermal_throttle.params; in iwl_mvm_tt_handler()
386 struct iwl_mvm_tt_mgmt *tt = &mvm->thermal_throttle; in iwl_mvm_tt_handler()
387 s32 temperature = mvm->temperature; in iwl_mvm_tt_handler()
392 IWL_DEBUG_TEMP(mvm, "NIC temperature: %d\n", mvm->temperature); in iwl_mvm_tt_handler()
395 iwl_mvm_enter_ctkill(mvm); in iwl_mvm_tt_handler()
401 iwl_mvm_exit_ctkill(mvm); in iwl_mvm_tt_handler()
408 IWL_DEBUG_TEMP(mvm, "Enable dynamic SMPS\n"); in iwl_mvm_tt_handler()
411 mvm->hw, IEEE80211_IFACE_ITER_NORMAL, in iwl_mvm_tt_handler()
412 iwl_mvm_tt_smps_iterator, mvm); in iwl_mvm_tt_handler()
416 IWL_DEBUG_TEMP(mvm, "Disable dynamic SMPS\n"); in iwl_mvm_tt_handler()
419 mvm->hw, IEEE80211_IFACE_ITER_NORMAL, in iwl_mvm_tt_handler()
420 iwl_mvm_tt_smps_iterator, mvm); in iwl_mvm_tt_handler()
426 iwl_mvm_tt_tx_protection(mvm, true); in iwl_mvm_tt_handler()
429 iwl_mvm_tt_tx_protection(mvm, false); in iwl_mvm_tt_handler()
444 iwl_mvm_tt_tx_backoff(mvm, tx_backoff); in iwl_mvm_tt_handler()
448 IWL_WARN(mvm, in iwl_mvm_tt_handler()
454 IWL_WARN(mvm, in iwl_mvm_tt_handler()
507 int iwl_mvm_ctdp_command(struct iwl_mvm *mvm, u32 op, u32 state) in iwl_mvm_ctdp_command() argument
517 lockdep_assert_held(&mvm->mutex); in iwl_mvm_ctdp_command()
520 ret = iwl_mvm_send_cmd_pdu_status(mvm, WIDE_ID(PHY_OPS_GROUP, in iwl_mvm_ctdp_command()
525 IWL_ERR(mvm, "cTDP command failed (err=%d)\n", ret); in iwl_mvm_ctdp_command()
532 mvm->cooling_dev.cur_state = state; in iwl_mvm_ctdp_command()
536 IWL_DEBUG_TEMP(mvm, "cTDP avg energy in mWatt = %d\n", status); in iwl_mvm_ctdp_command()
545 IWL_DEBUG_TEMP(mvm, "cTDP stopped successfully\n"); in iwl_mvm_ctdp_command()
560 int iwl_mvm_send_temp_report_ths_cmd(struct iwl_mvm *mvm) in iwl_mvm_send_temp_report_ths_cmd() argument
567 lockdep_assert_held(&mvm->mutex); in iwl_mvm_send_temp_report_ths_cmd()
569 if (!mvm->tz_device.tzone) in iwl_mvm_send_temp_report_ths_cmd()
578 if (mvm->tz_device.temp_trips[i] != S16_MIN) { in iwl_mvm_send_temp_report_ths_cmd()
580 cpu_to_le16(mvm->tz_device.temp_trips[i]); in iwl_mvm_send_temp_report_ths_cmd()
597 mvm->tz_device.temp_trips[j]) in iwl_mvm_send_temp_report_ths_cmd()
598 mvm->tz_device.fw_trips_index[i] = j; in iwl_mvm_send_temp_report_ths_cmd()
604 ret = iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(PHY_OPS_GROUP, in iwl_mvm_send_temp_report_ths_cmd()
608 IWL_ERR(mvm, "TEMP_REPORT_THS_CMD command failed (err=%d)\n", in iwl_mvm_send_temp_report_ths_cmd()
618 struct iwl_mvm *mvm = (struct iwl_mvm *)device->devdata; in iwl_mvm_tzone_get_temp() local
622 mutex_lock(&mvm->mutex); in iwl_mvm_tzone_get_temp()
624 if (!iwl_mvm_firmware_running(mvm) || in iwl_mvm_tzone_get_temp()
625 mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) { in iwl_mvm_tzone_get_temp()
630 ret = iwl_mvm_get_temp(mvm, &temp); in iwl_mvm_tzone_get_temp()
637 mutex_unlock(&mvm->mutex); in iwl_mvm_tzone_get_temp()
644 struct iwl_mvm *mvm = (struct iwl_mvm *)device->devdata; in iwl_mvm_tzone_get_trip_temp() local
649 *temp = mvm->tz_device.temp_trips[trip] * 1000; in iwl_mvm_tzone_get_trip_temp()
668 struct iwl_mvm *mvm = (struct iwl_mvm *)device->devdata; in iwl_mvm_tzone_set_trip_temp() local
673 mutex_lock(&mvm->mutex); in iwl_mvm_tzone_set_trip_temp()
675 if (!iwl_mvm_firmware_running(mvm) || in iwl_mvm_tzone_set_trip_temp()
676 mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) { in iwl_mvm_tzone_set_trip_temp()
692 tzone = &mvm->tz_device; in iwl_mvm_tzone_set_trip_temp()
715 ret = iwl_mvm_send_temp_report_ths_cmd(mvm); in iwl_mvm_tzone_set_trip_temp()
717 mutex_unlock(&mvm->mutex); in iwl_mvm_tzone_set_trip_temp()
731 static void iwl_mvm_thermal_zone_register(struct iwl_mvm *mvm) in iwl_mvm_thermal_zone_register() argument
737 if (!iwl_mvm_is_tt_in_fw(mvm)) { in iwl_mvm_thermal_zone_register()
738 mvm->tz_device.tzone = NULL; in iwl_mvm_thermal_zone_register()
746 mvm->tz_device.tzone = thermal_zone_device_register(name, in iwl_mvm_thermal_zone_register()
749 mvm, &tzone_ops, in iwl_mvm_thermal_zone_register()
751 if (IS_ERR(mvm->tz_device.tzone)) { in iwl_mvm_thermal_zone_register()
752 IWL_DEBUG_TEMP(mvm, in iwl_mvm_thermal_zone_register()
754 PTR_ERR(mvm->tz_device.tzone)); in iwl_mvm_thermal_zone_register()
755 mvm->tz_device.tzone = NULL; in iwl_mvm_thermal_zone_register()
759 ret = thermal_zone_device_enable(mvm->tz_device.tzone); in iwl_mvm_thermal_zone_register()
761 IWL_DEBUG_TEMP(mvm, "Failed to enable thermal zone\n"); in iwl_mvm_thermal_zone_register()
762 thermal_zone_device_unregister(mvm->tz_device.tzone); in iwl_mvm_thermal_zone_register()
770 mvm->tz_device.temp_trips[i] = S16_MIN; in iwl_mvm_thermal_zone_register()
784 struct iwl_mvm *mvm = (struct iwl_mvm *)(cdev->devdata); in iwl_mvm_tcool_get_cur_state() local
786 *state = mvm->cooling_dev.cur_state; in iwl_mvm_tcool_get_cur_state()
794 struct iwl_mvm *mvm = (struct iwl_mvm *)(cdev->devdata); in iwl_mvm_tcool_set_cur_state() local
797 mutex_lock(&mvm->mutex); in iwl_mvm_tcool_set_cur_state()
799 if (!iwl_mvm_firmware_running(mvm) || in iwl_mvm_tcool_set_cur_state()
800 mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) { in iwl_mvm_tcool_set_cur_state()
810 ret = iwl_mvm_ctdp_command(mvm, CTDP_CMD_OPERATION_START, in iwl_mvm_tcool_set_cur_state()
814 mutex_unlock(&mvm->mutex); in iwl_mvm_tcool_set_cur_state()
824 static void iwl_mvm_cooling_device_register(struct iwl_mvm *mvm) in iwl_mvm_cooling_device_register() argument
828 if (!iwl_mvm_is_ctdp_supported(mvm)) in iwl_mvm_cooling_device_register()
833 mvm->cooling_dev.cdev = in iwl_mvm_cooling_device_register()
835 mvm, in iwl_mvm_cooling_device_register()
838 if (IS_ERR(mvm->cooling_dev.cdev)) { in iwl_mvm_cooling_device_register()
839 IWL_DEBUG_TEMP(mvm, in iwl_mvm_cooling_device_register()
841 PTR_ERR(mvm->cooling_dev.cdev)); in iwl_mvm_cooling_device_register()
842 mvm->cooling_dev.cdev = NULL; in iwl_mvm_cooling_device_register()
847 static void iwl_mvm_thermal_zone_unregister(struct iwl_mvm *mvm) in iwl_mvm_thermal_zone_unregister() argument
849 if (!iwl_mvm_is_tt_in_fw(mvm) || !mvm->tz_device.tzone) in iwl_mvm_thermal_zone_unregister()
852 IWL_DEBUG_TEMP(mvm, "Thermal zone device unregister\n"); in iwl_mvm_thermal_zone_unregister()
853 if (mvm->tz_device.tzone) { in iwl_mvm_thermal_zone_unregister()
854 thermal_zone_device_unregister(mvm->tz_device.tzone); in iwl_mvm_thermal_zone_unregister()
855 mvm->tz_device.tzone = NULL; in iwl_mvm_thermal_zone_unregister()
859 static void iwl_mvm_cooling_device_unregister(struct iwl_mvm *mvm) in iwl_mvm_cooling_device_unregister() argument
861 if (!iwl_mvm_is_ctdp_supported(mvm) || !mvm->cooling_dev.cdev) in iwl_mvm_cooling_device_unregister()
864 IWL_DEBUG_TEMP(mvm, "Cooling device unregister\n"); in iwl_mvm_cooling_device_unregister()
865 if (mvm->cooling_dev.cdev) { in iwl_mvm_cooling_device_unregister()
866 thermal_cooling_device_unregister(mvm->cooling_dev.cdev); in iwl_mvm_cooling_device_unregister()
867 mvm->cooling_dev.cdev = NULL; in iwl_mvm_cooling_device_unregister()
872 void iwl_mvm_thermal_initialize(struct iwl_mvm *mvm, u32 min_backoff) in iwl_mvm_thermal_initialize() argument
874 struct iwl_mvm_tt_mgmt *tt = &mvm->thermal_throttle; in iwl_mvm_thermal_initialize()
876 IWL_DEBUG_TEMP(mvm, "Initialize Thermal Throttling\n"); in iwl_mvm_thermal_initialize()
878 if (mvm->cfg->thermal_params) in iwl_mvm_thermal_initialize()
879 tt->params = *mvm->cfg->thermal_params; in iwl_mvm_thermal_initialize()
889 iwl_mvm_cooling_device_register(mvm); in iwl_mvm_thermal_initialize()
890 iwl_mvm_thermal_zone_register(mvm); in iwl_mvm_thermal_initialize()
892 mvm->init_status |= IWL_MVM_INIT_STATUS_THERMAL_INIT_COMPLETE; in iwl_mvm_thermal_initialize()
895 void iwl_mvm_thermal_exit(struct iwl_mvm *mvm) in iwl_mvm_thermal_exit() argument
897 if (!(mvm->init_status & IWL_MVM_INIT_STATUS_THERMAL_INIT_COMPLETE)) in iwl_mvm_thermal_exit()
900 cancel_delayed_work_sync(&mvm->thermal_throttle.ct_kill_exit); in iwl_mvm_thermal_exit()
901 IWL_DEBUG_TEMP(mvm, "Exit Thermal Throttling\n"); in iwl_mvm_thermal_exit()
904 iwl_mvm_cooling_device_unregister(mvm); in iwl_mvm_thermal_exit()
905 iwl_mvm_thermal_zone_unregister(mvm); in iwl_mvm_thermal_exit()
907 mvm->init_status &= ~IWL_MVM_INIT_STATUS_THERMAL_INIT_COMPLETE; in iwl_mvm_thermal_exit()