Lines Matching refs:mvm

69 void iwl_mvm_enter_ctkill(struct iwl_mvm *mvm)  in iwl_mvm_enter_ctkill()  argument
71 struct iwl_mvm_tt_mgmt *tt = &mvm->thermal_throttle; in iwl_mvm_enter_ctkill()
74 if (test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status)) in iwl_mvm_enter_ctkill()
77 IWL_ERR(mvm, "Enter CT Kill\n"); in iwl_mvm_enter_ctkill()
78 iwl_mvm_set_hw_ctkill_state(mvm, true); in iwl_mvm_enter_ctkill()
80 if (!iwl_mvm_is_tt_in_fw(mvm)) { in iwl_mvm_enter_ctkill()
89 if (!mvm->temperature_test) in iwl_mvm_enter_ctkill()
94 static void iwl_mvm_exit_ctkill(struct iwl_mvm *mvm) in iwl_mvm_exit_ctkill() argument
96 if (!test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status)) in iwl_mvm_exit_ctkill()
99 IWL_ERR(mvm, "Exit CT Kill\n"); in iwl_mvm_exit_ctkill()
100 iwl_mvm_set_hw_ctkill_state(mvm, false); in iwl_mvm_exit_ctkill()
103 void iwl_mvm_tt_temp_changed(struct iwl_mvm *mvm, u32 temp) in iwl_mvm_tt_temp_changed() argument
106 if (mvm->temperature_test) in iwl_mvm_tt_temp_changed()
109 if (mvm->temperature == temp) in iwl_mvm_tt_temp_changed()
112 mvm->temperature = temp; in iwl_mvm_tt_temp_changed()
113 iwl_mvm_tt_handler(mvm); in iwl_mvm_tt_temp_changed()
116 static int iwl_mvm_temp_notif_parse(struct iwl_mvm *mvm, in iwl_mvm_temp_notif_parse() argument
127 IWL_ERR(mvm, "Invalid DTS_MEASUREMENT_NOTIFICATION\n"); in iwl_mvm_temp_notif_parse()
139 IWL_DEBUG_TEMP(mvm, "DTS_MEASUREMENT_NOTIFICATION - %d\n", temp); in iwl_mvm_temp_notif_parse()
147 struct iwl_mvm *mvm = in iwl_mvm_temp_notif_wait() local
152 ret = iwl_mvm_temp_notif_parse(mvm, pkt); in iwl_mvm_temp_notif_wait()
161 void iwl_mvm_temp_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb) in iwl_mvm_temp_notif() argument
170 if (test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status)) in iwl_mvm_temp_notif()
173 temp = iwl_mvm_temp_notif_parse(mvm, pkt); in iwl_mvm_temp_notif()
175 if (!iwl_mvm_is_tt_in_fw(mvm)) { in iwl_mvm_temp_notif()
177 iwl_mvm_tt_temp_changed(mvm, temp); in iwl_mvm_temp_notif()
182 IWL_ERR(mvm, "Invalid DTS_MEASUREMENT_NOTIFICATION\n"); in iwl_mvm_temp_notif()
195 IWL_DEBUG_TEMP(mvm, "Temp = %d Threshold crossed = %d\n", in iwl_mvm_temp_notif()
202 if (mvm->tz_device.tzone) { in iwl_mvm_temp_notif()
203 struct iwl_mvm_thermal_device *tz_dev = &mvm->tz_device; in iwl_mvm_temp_notif()
211 void iwl_mvm_ct_kill_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb) in iwl_mvm_ct_kill_notif() argument
218 IWL_ERR(mvm, "Invalid CT_KILL_NOTIFICATION\n"); in iwl_mvm_ct_kill_notif()
223 IWL_DEBUG_TEMP(mvm, "CT Kill notification temperature = %d\n", in iwl_mvm_ct_kill_notif()
226 iwl_mvm_enter_ctkill(mvm); in iwl_mvm_ct_kill_notif()
229 static int iwl_mvm_get_temp_cmd(struct iwl_mvm *mvm) in iwl_mvm_get_temp_cmd() argument
242 if (!fw_has_capa(&mvm->fw->ucode_capa, in iwl_mvm_get_temp_cmd()
244 return iwl_mvm_send_cmd_pdu(mvm, cmdid, 0, sizeof(cmd), &cmd); in iwl_mvm_get_temp_cmd()
246 return iwl_mvm_send_cmd_pdu(mvm, cmdid, 0, sizeof(extcmd), &extcmd); in iwl_mvm_get_temp_cmd()
249 int iwl_mvm_get_temp(struct iwl_mvm *mvm, s32 *temp) in iwl_mvm_get_temp() argument
256 lockdep_assert_held(&mvm->mutex); in iwl_mvm_get_temp()
258 iwl_init_notification_wait(&mvm->notif_wait, &wait_temp_notif, in iwl_mvm_get_temp()
262 ret = iwl_mvm_get_temp_cmd(mvm); in iwl_mvm_get_temp()
264 IWL_ERR(mvm, "Failed to get the temperature (err=%d)\n", ret); in iwl_mvm_get_temp()
265 iwl_remove_notification(&mvm->notif_wait, &wait_temp_notif); in iwl_mvm_get_temp()
269 ret = iwl_wait_notification(&mvm->notif_wait, &wait_temp_notif, in iwl_mvm_get_temp()
272 IWL_ERR(mvm, "Getting the temperature timed out\n"); in iwl_mvm_get_temp()
280 struct iwl_mvm *mvm; in check_exit_ctkill() local
286 mvm = container_of(tt, struct iwl_mvm, thermal_throttle); in check_exit_ctkill()
288 if (iwl_mvm_is_tt_in_fw(mvm)) { in check_exit_ctkill()
289 iwl_mvm_exit_ctkill(mvm); in check_exit_ctkill()
296 mutex_lock(&mvm->mutex); in check_exit_ctkill()
298 if (__iwl_mvm_mac_start(mvm)) in check_exit_ctkill()
301 ret = iwl_mvm_get_temp(mvm, &temp); in check_exit_ctkill()
303 __iwl_mvm_mac_stop(mvm); in check_exit_ctkill()
308 IWL_DEBUG_TEMP(mvm, "NIC temperature: %d\n", temp); in check_exit_ctkill()
311 mutex_unlock(&mvm->mutex); in check_exit_ctkill()
312 iwl_mvm_exit_ctkill(mvm); in check_exit_ctkill()
317 mutex_unlock(&mvm->mutex); in check_exit_ctkill()
318 schedule_delayed_work(&mvm->thermal_throttle.ct_kill_exit, in check_exit_ctkill()
325 struct iwl_mvm *mvm = _data; in iwl_mvm_tt_smps_iterator() local
328 lockdep_assert_held(&mvm->mutex); in iwl_mvm_tt_smps_iterator()
330 if (mvm->thermal_throttle.dynamic_smps) in iwl_mvm_tt_smps_iterator()
338 iwl_mvm_update_smps(mvm, vif, IWL_MVM_SMPS_REQ_TT, smps_mode); in iwl_mvm_tt_smps_iterator()
341 static void iwl_mvm_tt_tx_protection(struct iwl_mvm *mvm, bool enable) in iwl_mvm_tt_tx_protection() argument
346 for (i = 0; i < ARRAY_SIZE(mvm->fw_id_to_mac_id); i++) { in iwl_mvm_tt_tx_protection()
347 mvmsta = iwl_mvm_sta_from_staid_protected(mvm, i); in iwl_mvm_tt_tx_protection()
353 err = iwl_mvm_tx_protection(mvm, mvmsta, enable); in iwl_mvm_tt_tx_protection()
355 IWL_ERR(mvm, "Failed to %s Tx protection\n", in iwl_mvm_tt_tx_protection()
358 IWL_DEBUG_TEMP(mvm, "%s Tx protection\n", in iwl_mvm_tt_tx_protection()
365 void iwl_mvm_tt_tx_backoff(struct iwl_mvm *mvm, u32 backoff) in iwl_mvm_tt_tx_backoff() argument
373 backoff = max(backoff, mvm->thermal_throttle.min_backoff); in iwl_mvm_tt_tx_backoff()
375 if (iwl_mvm_send_cmd(mvm, &cmd) == 0) { in iwl_mvm_tt_tx_backoff()
376 IWL_DEBUG_TEMP(mvm, "Set Thermal Tx backoff to: %u\n", in iwl_mvm_tt_tx_backoff()
378 mvm->thermal_throttle.tx_backoff = backoff; in iwl_mvm_tt_tx_backoff()
380 IWL_ERR(mvm, "Failed to change Thermal Tx backoff\n"); in iwl_mvm_tt_tx_backoff()
384 void iwl_mvm_tt_handler(struct iwl_mvm *mvm) in iwl_mvm_tt_handler() argument
386 struct iwl_tt_params *params = &mvm->thermal_throttle.params; in iwl_mvm_tt_handler()
387 struct iwl_mvm_tt_mgmt *tt = &mvm->thermal_throttle; in iwl_mvm_tt_handler()
388 s32 temperature = mvm->temperature; in iwl_mvm_tt_handler()
393 IWL_DEBUG_TEMP(mvm, "NIC temperature: %d\n", mvm->temperature); in iwl_mvm_tt_handler()
396 iwl_mvm_enter_ctkill(mvm); in iwl_mvm_tt_handler()
402 iwl_mvm_exit_ctkill(mvm); in iwl_mvm_tt_handler()
409 IWL_DEBUG_TEMP(mvm, "Enable dynamic SMPS\n"); in iwl_mvm_tt_handler()
412 mvm->hw, IEEE80211_IFACE_ITER_NORMAL, in iwl_mvm_tt_handler()
413 iwl_mvm_tt_smps_iterator, mvm); in iwl_mvm_tt_handler()
417 IWL_DEBUG_TEMP(mvm, "Disable dynamic SMPS\n"); in iwl_mvm_tt_handler()
420 mvm->hw, IEEE80211_IFACE_ITER_NORMAL, in iwl_mvm_tt_handler()
421 iwl_mvm_tt_smps_iterator, mvm); in iwl_mvm_tt_handler()
427 iwl_mvm_tt_tx_protection(mvm, true); in iwl_mvm_tt_handler()
430 iwl_mvm_tt_tx_protection(mvm, false); in iwl_mvm_tt_handler()
445 iwl_mvm_tt_tx_backoff(mvm, tx_backoff); in iwl_mvm_tt_handler()
449 IWL_WARN(mvm, in iwl_mvm_tt_handler()
455 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
736 if (!iwl_mvm_is_tt_in_fw(mvm)) { in iwl_mvm_thermal_zone_register()
737 mvm->tz_device.tzone = NULL; in iwl_mvm_thermal_zone_register()
744 mvm->tz_device.tzone = thermal_zone_device_register(name, in iwl_mvm_thermal_zone_register()
747 mvm, &tzone_ops, in iwl_mvm_thermal_zone_register()
749 if (IS_ERR(mvm->tz_device.tzone)) { in iwl_mvm_thermal_zone_register()
750 IWL_DEBUG_TEMP(mvm, in iwl_mvm_thermal_zone_register()
752 PTR_ERR(mvm->tz_device.tzone)); in iwl_mvm_thermal_zone_register()
753 mvm->tz_device.tzone = NULL; in iwl_mvm_thermal_zone_register()
761 mvm->tz_device.temp_trips[i] = S16_MIN; in iwl_mvm_thermal_zone_register()
775 struct iwl_mvm *mvm = (struct iwl_mvm *)(cdev->devdata); in iwl_mvm_tcool_get_cur_state() local
777 *state = mvm->cooling_dev.cur_state; in iwl_mvm_tcool_get_cur_state()
785 struct iwl_mvm *mvm = (struct iwl_mvm *)(cdev->devdata); in iwl_mvm_tcool_set_cur_state() local
788 mutex_lock(&mvm->mutex); in iwl_mvm_tcool_set_cur_state()
790 if (!iwl_mvm_firmware_running(mvm) || in iwl_mvm_tcool_set_cur_state()
791 mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) { in iwl_mvm_tcool_set_cur_state()
801 ret = iwl_mvm_ctdp_command(mvm, CTDP_CMD_OPERATION_START, in iwl_mvm_tcool_set_cur_state()
805 mutex_unlock(&mvm->mutex); in iwl_mvm_tcool_set_cur_state()
815 static void iwl_mvm_cooling_device_register(struct iwl_mvm *mvm) in iwl_mvm_cooling_device_register() argument
819 if (!iwl_mvm_is_ctdp_supported(mvm)) in iwl_mvm_cooling_device_register()
824 mvm->cooling_dev.cdev = in iwl_mvm_cooling_device_register()
826 mvm, in iwl_mvm_cooling_device_register()
829 if (IS_ERR(mvm->cooling_dev.cdev)) { in iwl_mvm_cooling_device_register()
830 IWL_DEBUG_TEMP(mvm, in iwl_mvm_cooling_device_register()
832 PTR_ERR(mvm->cooling_dev.cdev)); in iwl_mvm_cooling_device_register()
833 mvm->cooling_dev.cdev = NULL; in iwl_mvm_cooling_device_register()
838 static void iwl_mvm_thermal_zone_unregister(struct iwl_mvm *mvm) in iwl_mvm_thermal_zone_unregister() argument
840 if (!iwl_mvm_is_tt_in_fw(mvm) || !mvm->tz_device.tzone) in iwl_mvm_thermal_zone_unregister()
843 IWL_DEBUG_TEMP(mvm, "Thermal zone device unregister\n"); in iwl_mvm_thermal_zone_unregister()
844 if (mvm->tz_device.tzone) { in iwl_mvm_thermal_zone_unregister()
845 thermal_zone_device_unregister(mvm->tz_device.tzone); in iwl_mvm_thermal_zone_unregister()
846 mvm->tz_device.tzone = NULL; in iwl_mvm_thermal_zone_unregister()
850 static void iwl_mvm_cooling_device_unregister(struct iwl_mvm *mvm) in iwl_mvm_cooling_device_unregister() argument
852 if (!iwl_mvm_is_ctdp_supported(mvm) || !mvm->cooling_dev.cdev) in iwl_mvm_cooling_device_unregister()
855 IWL_DEBUG_TEMP(mvm, "Cooling device unregister\n"); in iwl_mvm_cooling_device_unregister()
856 if (mvm->cooling_dev.cdev) { in iwl_mvm_cooling_device_unregister()
857 thermal_cooling_device_unregister(mvm->cooling_dev.cdev); in iwl_mvm_cooling_device_unregister()
858 mvm->cooling_dev.cdev = NULL; in iwl_mvm_cooling_device_unregister()
863 void iwl_mvm_thermal_initialize(struct iwl_mvm *mvm, u32 min_backoff) in iwl_mvm_thermal_initialize() argument
865 struct iwl_mvm_tt_mgmt *tt = &mvm->thermal_throttle; in iwl_mvm_thermal_initialize()
867 IWL_DEBUG_TEMP(mvm, "Initialize Thermal Throttling\n"); in iwl_mvm_thermal_initialize()
869 if (mvm->cfg->thermal_params) in iwl_mvm_thermal_initialize()
870 tt->params = *mvm->cfg->thermal_params; in iwl_mvm_thermal_initialize()
880 iwl_mvm_cooling_device_register(mvm); in iwl_mvm_thermal_initialize()
881 iwl_mvm_thermal_zone_register(mvm); in iwl_mvm_thermal_initialize()
883 mvm->init_status |= IWL_MVM_INIT_STATUS_THERMAL_INIT_COMPLETE; in iwl_mvm_thermal_initialize()
886 void iwl_mvm_thermal_exit(struct iwl_mvm *mvm) in iwl_mvm_thermal_exit() argument
888 if (!(mvm->init_status & IWL_MVM_INIT_STATUS_THERMAL_INIT_COMPLETE)) in iwl_mvm_thermal_exit()
891 cancel_delayed_work_sync(&mvm->thermal_throttle.ct_kill_exit); in iwl_mvm_thermal_exit()
892 IWL_DEBUG_TEMP(mvm, "Exit Thermal Throttling\n"); in iwl_mvm_thermal_exit()
895 iwl_mvm_cooling_device_unregister(mvm); in iwl_mvm_thermal_exit()
896 iwl_mvm_thermal_zone_unregister(mvm); in iwl_mvm_thermal_exit()
898 mvm->init_status &= ~IWL_MVM_INIT_STATUS_THERMAL_INIT_COMPLETE; in iwl_mvm_thermal_exit()