Lines Matching +full:cooling +full:- +full:device

1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
3 * Copyright (C) 2012-2014, 2019-2022, 2024-2025 Intel Corporation
4 * Copyright (C) 2013-2014 Intel Mobile Communications GmbH
5 * Copyright (C) 2015-2016 Intel Deutschland GmbH
20 struct iwl_mvm_tt_mgmt *tt = &mvm->thermal_throttle; in iwl_mvm_enter_ctkill()
21 u32 duration = tt->params.ct_kill_duration; in iwl_mvm_enter_ctkill()
23 if (test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status)) in iwl_mvm_enter_ctkill()
30 tt->throttle = false; in iwl_mvm_enter_ctkill()
31 tt->dynamic_smps = false; in iwl_mvm_enter_ctkill()
38 if (!mvm->temperature_test) in iwl_mvm_enter_ctkill()
39 schedule_delayed_work(&tt->ct_kill_exit, in iwl_mvm_enter_ctkill()
45 if (!test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status)) in iwl_mvm_exit_ctkill()
55 if (mvm->temperature_test) in iwl_mvm_tt_temp_changed()
58 if (mvm->temperature == temp) in iwl_mvm_tt_temp_changed()
61 mvm->temperature = temp; in iwl_mvm_tt_temp_changed()
77 return -EINVAL; in iwl_mvm_temp_notif_parse()
80 notif_v1 = (void *)pkt->data; in iwl_mvm_temp_notif_parse()
82 temp = le32_to_cpu(notif_v1->temp); in iwl_mvm_temp_notif_parse()
88 IWL_DEBUG_TEMP(mvm, "DTS_MEASUREMENT_NOTIFICATION - %d\n", temp); in iwl_mvm_temp_notif_parse()
119 if (test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status)) in iwl_mvm_temp_notif()
135 notif_v2 = (void *)pkt->data; in iwl_mvm_temp_notif()
136 ths_crossed = le32_to_cpu(notif_v2->threshold_idx); in iwl_mvm_temp_notif()
151 if (mvm->tz_device.tzone) { in iwl_mvm_temp_notif()
152 struct iwl_mvm_thermal_device *tz_dev = &mvm->tz_device; in iwl_mvm_temp_notif()
154 thermal_zone_device_update(tz_dev->tzone, in iwl_mvm_temp_notif()
165 notif = (struct ct_kill_notif *)pkt->data; in iwl_mvm_ct_kill_notif()
167 notif->temperature); in iwl_mvm_ct_kill_notif()
168 if (iwl_fw_lookup_notif_ver(mvm->fw, PHY_OPS_GROUP, in iwl_mvm_ct_kill_notif()
172 notif->dts, notif->scheme); in iwl_mvm_ct_kill_notif()
197 if (fw_has_capa(&mvm->fw->ucode_capa, in iwl_mvm_send_temp_cmd()
217 "Sending temperature measurement command - %s response\n", in iwl_mvm_send_temp_cmd()
229 resp = (void *)cmd.resp_pkt->data; in iwl_mvm_send_temp_cmd()
230 *temp = le32_to_cpu(resp->temp); in iwl_mvm_send_temp_cmd()
253 cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw, in iwl_mvm_get_temp()
259 lockdep_assert_held(&mvm->mutex); in iwl_mvm_get_temp()
261 iwl_init_notification_wait(&mvm->notif_wait, &wait_temp_notif, in iwl_mvm_get_temp()
267 iwl_remove_notification(&mvm->notif_wait, &wait_temp_notif); in iwl_mvm_get_temp()
271 ret = iwl_wait_notification(&mvm->notif_wait, &wait_temp_notif, in iwl_mvm_get_temp()
296 duration = tt->params.ct_kill_duration; in check_exit_ctkill()
298 flush_work(&mvm->roc_done_wk); in check_exit_ctkill()
300 mutex_lock(&mvm->mutex); in check_exit_ctkill()
314 if (temp <= tt->params.ct_kill_exit) { in check_exit_ctkill()
315 mutex_unlock(&mvm->mutex); in check_exit_ctkill()
321 mutex_unlock(&mvm->mutex); in check_exit_ctkill()
322 schedule_delayed_work(&mvm->thermal_throttle.ct_kill_exit, in check_exit_ctkill()
332 lockdep_assert_held(&mvm->mutex); in iwl_mvm_tt_smps_iterator()
334 if (mvm->thermal_throttle.dynamic_smps) in iwl_mvm_tt_smps_iterator()
339 if (vif->type != NL80211_IFTYPE_STATION) in iwl_mvm_tt_smps_iterator()
350 for (i = 0; i < mvm->fw->ucode_capa.num_stations; i++) { in iwl_mvm_tt_tx_protection()
355 if (enable == mvmsta->tt_tx_protection) in iwl_mvm_tt_tx_protection()
364 mvmsta->tt_tx_protection = enable; in iwl_mvm_tt_tx_protection()
377 backoff = max(backoff, mvm->thermal_throttle.min_backoff); in iwl_mvm_tt_tx_backoff()
382 mvm->thermal_throttle.tx_backoff = backoff; in iwl_mvm_tt_tx_backoff()
390 struct iwl_tt_params *params = &mvm->thermal_throttle.params; in iwl_mvm_tt_handler()
391 struct iwl_mvm_tt_mgmt *tt = &mvm->thermal_throttle; in iwl_mvm_tt_handler()
392 s32 temperature = mvm->temperature; in iwl_mvm_tt_handler()
397 IWL_DEBUG_TEMP(mvm, "NIC temperature: %d\n", mvm->temperature); in iwl_mvm_tt_handler()
399 if (params->support_ct_kill && temperature >= params->ct_kill_entry) { in iwl_mvm_tt_handler()
404 if (params->support_ct_kill && in iwl_mvm_tt_handler()
405 temperature <= params->ct_kill_exit) { in iwl_mvm_tt_handler()
410 if (params->support_dynamic_smps) { in iwl_mvm_tt_handler()
411 if (!tt->dynamic_smps && in iwl_mvm_tt_handler()
412 temperature >= params->dynamic_smps_entry) { in iwl_mvm_tt_handler()
414 tt->dynamic_smps = true; in iwl_mvm_tt_handler()
416 mvm->hw, IEEE80211_IFACE_ITER_NORMAL, in iwl_mvm_tt_handler()
419 } else if (tt->dynamic_smps && in iwl_mvm_tt_handler()
420 temperature <= params->dynamic_smps_exit) { in iwl_mvm_tt_handler()
422 tt->dynamic_smps = false; in iwl_mvm_tt_handler()
424 mvm->hw, IEEE80211_IFACE_ITER_NORMAL, in iwl_mvm_tt_handler()
429 if (params->support_tx_protection) { in iwl_mvm_tt_handler()
430 if (temperature >= params->tx_protection_entry) { in iwl_mvm_tt_handler()
433 } else if (temperature <= params->tx_protection_exit) { in iwl_mvm_tt_handler()
438 if (params->support_tx_backoff) { in iwl_mvm_tt_handler()
439 tx_backoff = tt->min_backoff; in iwl_mvm_tt_handler()
441 if (temperature < params->tx_backoff[i].temperature) in iwl_mvm_tt_handler()
443 tx_backoff = max(tt->min_backoff, in iwl_mvm_tt_handler()
444 params->tx_backoff[i].backoff); in iwl_mvm_tt_handler()
446 if (tx_backoff != tt->min_backoff) in iwl_mvm_tt_handler()
448 if (tt->tx_backoff != tx_backoff) in iwl_mvm_tt_handler()
452 if (!tt->throttle && throttle_enable) { in iwl_mvm_tt_handler()
455 tt->throttle = true; in iwl_mvm_tt_handler()
456 } else if (tt->throttle && !tt->dynamic_smps && in iwl_mvm_tt_handler()
457 tt->tx_backoff == tt->min_backoff && in iwl_mvm_tt_handler()
458 temperature <= params->tx_protection_exit) { in iwl_mvm_tt_handler()
461 tt->throttle = false; in iwl_mvm_tt_handler()
497 lockdep_assert_held(&mvm->mutex); in iwl_mvm_ctdp_command()
502 budget = ((mvm->thermal_throttle.power_budget_mw - in iwl_mvm_ctdp_command()
504 (IWL_MVM_NUM_CTDP_STEPS - 1 - state)) / in iwl_mvm_ctdp_command()
505 (IWL_MVM_NUM_CTDP_STEPS - 1) + in iwl_mvm_ctdp_command()
522 mvm->cooling_dev.cur_state = state; in iwl_mvm_ctdp_command()
545 return ((s16)le16_to_cpu(*(const __le16 *)a) - in compare_temps()
558 if (trip->temperature == THERMAL_TEMP_INVALID) in iwl_trip_temp_cb()
561 twd->thresholds[twd->count++] = cpu_to_le16((s16)(trip->temperature / 1000)); in iwl_trip_temp_cb()
573 lockdep_assert_held(&mvm->mutex); in iwl_mvm_send_temp_report_ths_cmd()
575 if (!mvm->tz_device.tzone) in iwl_mvm_send_temp_report_ths_cmd()
585 for_each_thermal_trip(mvm->tz_device.tzone, iwl_trip_temp_cb, &twd); in iwl_mvm_send_temp_report_ths_cmd()
604 static int iwl_mvm_tzone_get_temp(struct thermal_zone_device *device, in iwl_mvm_tzone_get_temp() argument
607 struct iwl_mvm *mvm = thermal_zone_device_priv(device); in iwl_mvm_tzone_get_temp()
614 mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) { in iwl_mvm_tzone_get_temp()
631 static int iwl_mvm_tzone_set_trip_temp(struct thermal_zone_device *device, in iwl_mvm_tzone_set_trip_temp() argument
634 struct iwl_mvm *mvm = thermal_zone_device_priv(device); in iwl_mvm_tzone_set_trip_temp()
639 mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) in iwl_mvm_tzone_set_trip_temp()
640 return -EIO; in iwl_mvm_tzone_set_trip_temp()
643 return -EINVAL; in iwl_mvm_tzone_set_trip_temp()
660 mvm->tz_device.tzone = NULL; in iwl_mvm_thermal_zone_register()
673 mvm->tz_device.trips[i].temperature = THERMAL_TEMP_INVALID; in iwl_mvm_thermal_zone_register()
674 mvm->tz_device.trips[i].type = THERMAL_TRIP_PASSIVE; in iwl_mvm_thermal_zone_register()
675 mvm->tz_device.trips[i].flags = THERMAL_TRIP_FLAG_RW_TEMP; in iwl_mvm_thermal_zone_register()
677 mvm->tz_device.tzone = thermal_zone_device_register_with_trips(name, in iwl_mvm_thermal_zone_register()
678 mvm->tz_device.trips, in iwl_mvm_thermal_zone_register()
682 if (IS_ERR(mvm->tz_device.tzone)) { in iwl_mvm_thermal_zone_register()
685 PTR_ERR(mvm->tz_device.tzone)); in iwl_mvm_thermal_zone_register()
686 mvm->tz_device.tzone = NULL; in iwl_mvm_thermal_zone_register()
690 ret = thermal_zone_device_enable(mvm->tz_device.tzone); in iwl_mvm_thermal_zone_register()
693 thermal_zone_device_unregister(mvm->tz_device.tzone); in iwl_mvm_thermal_zone_register()
700 *state = IWL_MVM_NUM_CTDP_STEPS - 1; in iwl_mvm_tcool_get_max_state()
708 struct iwl_mvm *mvm = (struct iwl_mvm *)(cdev->devdata); in iwl_mvm_tcool_get_cur_state()
710 *state = mvm->cooling_dev.cur_state; in iwl_mvm_tcool_get_cur_state()
718 struct iwl_mvm *mvm = (struct iwl_mvm *)(cdev->devdata); in iwl_mvm_tcool_set_cur_state()
723 mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) in iwl_mvm_tcool_set_cur_state()
724 return -EIO; in iwl_mvm_tcool_set_cur_state()
727 return -EINVAL; in iwl_mvm_tcool_set_cur_state()
748 mvm->cooling_dev.cdev = in iwl_mvm_cooling_device_register()
753 if (IS_ERR(mvm->cooling_dev.cdev)) { in iwl_mvm_cooling_device_register()
755 "Failed to register to cooling device (err = %ld)\n", in iwl_mvm_cooling_device_register()
756 PTR_ERR(mvm->cooling_dev.cdev)); in iwl_mvm_cooling_device_register()
757 mvm->cooling_dev.cdev = NULL; in iwl_mvm_cooling_device_register()
764 if (!iwl_mvm_is_tt_in_fw(mvm) || !mvm->tz_device.tzone) in iwl_mvm_thermal_zone_unregister()
767 IWL_DEBUG_TEMP(mvm, "Thermal zone device unregister\n"); in iwl_mvm_thermal_zone_unregister()
768 if (mvm->tz_device.tzone) { in iwl_mvm_thermal_zone_unregister()
769 thermal_zone_device_unregister(mvm->tz_device.tzone); in iwl_mvm_thermal_zone_unregister()
770 mvm->tz_device.tzone = NULL; in iwl_mvm_thermal_zone_unregister()
776 if (!iwl_mvm_is_ctdp_supported(mvm) || !mvm->cooling_dev.cdev) in iwl_mvm_cooling_device_unregister()
779 IWL_DEBUG_TEMP(mvm, "Cooling device unregister\n"); in iwl_mvm_cooling_device_unregister()
780 if (mvm->cooling_dev.cdev) { in iwl_mvm_cooling_device_unregister()
781 thermal_cooling_device_unregister(mvm->cooling_dev.cdev); in iwl_mvm_cooling_device_unregister()
782 mvm->cooling_dev.cdev = NULL; in iwl_mvm_cooling_device_unregister()
792 switch (CSR_HW_RFID_TYPE(mvm->trans->info.hw_rf_id)) { in iwl_mvm_ctdp_get_max_budget()
802 /* dual-radio devices have a higher budget */ in iwl_mvm_ctdp_get_max_budget()
803 if (CSR_HW_RFID_IS_CDB(mvm->trans->info.hw_rf_id)) in iwl_mvm_ctdp_get_max_budget()
816 iwl_bios_get_pwr_limit(&mvm->fwrt, &bios_power_budget); in iwl_mvm_ctdp_get_max_budget()
830 struct iwl_mvm_tt_mgmt *tt = &mvm->thermal_throttle; in iwl_mvm_thermal_initialize()
834 if (mvm->cfg->thermal_params) in iwl_mvm_thermal_initialize()
835 tt->params = *mvm->cfg->thermal_params; in iwl_mvm_thermal_initialize()
837 tt->params = iwl_mvm_default_tt_params; in iwl_mvm_thermal_initialize()
839 tt->power_budget_mw = iwl_mvm_ctdp_get_max_budget(mvm); in iwl_mvm_thermal_initialize()
840 IWL_DEBUG_TEMP(mvm, "cTDP power budget: %d mW\n", tt->power_budget_mw); in iwl_mvm_thermal_initialize()
841 tt->throttle = false; in iwl_mvm_thermal_initialize()
842 tt->dynamic_smps = false; in iwl_mvm_thermal_initialize()
843 tt->min_backoff = min_backoff; in iwl_mvm_thermal_initialize()
844 INIT_DELAYED_WORK(&tt->ct_kill_exit, check_exit_ctkill); in iwl_mvm_thermal_initialize()
850 mvm->init_status |= IWL_MVM_INIT_STATUS_THERMAL_INIT_COMPLETE; in iwl_mvm_thermal_initialize()
855 if (!(mvm->init_status & IWL_MVM_INIT_STATUS_THERMAL_INIT_COMPLETE)) in iwl_mvm_thermal_exit()
858 cancel_delayed_work_sync(&mvm->thermal_throttle.ct_kill_exit); in iwl_mvm_thermal_exit()
865 mvm->init_status &= ~IWL_MVM_INIT_STATUS_THERMAL_INIT_COMPLETE; in iwl_mvm_thermal_exit()