Lines Matching defs:priv

86 bool iwl_tt_is_low_power_state(struct iwl_priv *priv)
88 struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
95 u8 iwl_tt_current_power_mode(struct iwl_priv *priv)
97 struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
102 bool iwl_ht_enabled(struct iwl_priv *priv)
104 struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
107 if (!priv->thermal_throttle.advanced_tt)
113 static bool iwl_within_ct_kill_margin(struct iwl_priv *priv)
115 s32 temp = priv->temperature; /* degrees CELSIUS except specified */
118 if (!priv->thermal_throttle.advanced_tt)
127 bool iwl_check_for_ct_kill(struct iwl_priv *priv)
131 if (iwl_within_ct_kill_margin(priv)) {
132 iwl_tt_enter_ct_kill(priv);
138 enum iwl_antenna_ok iwl_tx_ant_restriction(struct iwl_priv *priv)
140 struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
143 if (!priv->thermal_throttle.advanced_tt)
149 enum iwl_antenna_ok iwl_rx_ant_restriction(struct iwl_priv *priv)
151 struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
154 if (!priv->thermal_throttle.advanced_tt)
173 struct iwl_priv *priv = (struct iwl_priv *)data;
174 struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
177 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
181 if (priv->thermal_throttle.ct_kill_toggle) {
182 iwl_write32(trans(priv), CSR_UCODE_DRV_GP1_CLR,
184 priv->thermal_throttle.ct_kill_toggle = false;
186 iwl_write32(trans(priv), CSR_UCODE_DRV_GP1_SET,
188 priv->thermal_throttle.ct_kill_toggle = true;
190 iwl_read32(trans(priv), CSR_UCODE_DRV_GP1);
191 spin_lock_irqsave(&trans(priv)->reg_lock, flags);
192 if (likely(iwl_grab_nic_access(trans(priv))))
193 iwl_release_nic_access(trans(priv));
194 spin_unlock_irqrestore(&trans(priv)->reg_lock, flags);
199 IWL_DEBUG_TEMP(priv, "schedule ct_kill exit timer\n");
200 mod_timer(&priv->thermal_throttle.ct_kill_exit_tm,
205 static void iwl_perform_ct_kill_task(struct iwl_priv *priv,
209 IWL_DEBUG_TEMP(priv, "Stop all queues\n");
210 if (priv->mac80211_registered)
211 ieee80211_stop_queues(priv->hw);
212 IWL_DEBUG_TEMP(priv,
214 mod_timer(&priv->thermal_throttle.ct_kill_exit_tm,
217 IWL_DEBUG_TEMP(priv, "Wake all queues\n");
218 if (priv->mac80211_registered)
219 ieee80211_wake_queues(priv->hw);
225 struct iwl_priv *priv = (struct iwl_priv *)data;
226 struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
228 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
233 IWL_DEBUG_TEMP(priv, "entering CT_KILL state when "
236 set_bit(STATUS_CT_KILL, &priv->status);
237 iwl_perform_ct_kill_task(priv, true);
241 static void iwl_prepare_ct_kill_task(struct iwl_priv *priv)
243 IWL_DEBUG_TEMP(priv, "Prepare to enter IWL_TI_CT_KILL\n");
245 iwl_send_statistics_request(priv, CMD_SYNC, false);
247 mod_timer(&priv->thermal_throttle.ct_kill_waiting_tm,
264 static void iwl_legacy_tt_handler(struct iwl_priv *priv, s32 temp, bool force)
266 struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
274 IWL_DEBUG_TEMP(priv,
294 del_timer_sync(&priv->thermal_throttle.ct_kill_waiting_tm);
314 mutex_lock(&priv->mutex);
316 clear_bit(STATUS_CT_KILL, &priv->status);
318 iwl_power_update_mode(priv, true)) {
323 set_bit(STATUS_CT_KILL, &priv->status);
325 IWL_ERR(priv, "Cannot update power mode, "
330 set_bit(STATUS_CT_KILL, &priv->status);
331 iwl_perform_ct_kill_task(priv, true);
333 iwl_prepare_ct_kill_task(priv);
338 iwl_perform_ct_kill_task(priv, false);
339 IWL_DEBUG_TEMP(priv, "Temperature state changed %u\n",
341 IWL_DEBUG_TEMP(priv, "Power Index change to %u\n",
344 mutex_unlock(&priv->mutex);
369 static void iwl_advance_tt_handler(struct iwl_priv *priv, s32 temp, bool force)
371 struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
398 IWL_DEBUG_TEMP(priv,
415 del_timer_sync(&priv->thermal_throttle.ct_kill_waiting_tm);
421 if (!iwl_ht_enabled(priv)) {
424 for_each_context(priv, ctx) {
440 iwl_set_rxon_ht(priv, &priv->current_ht_config);
452 iwl_set_rxon_ht(priv, &priv->current_ht_config);
454 mutex_lock(&priv->mutex);
456 clear_bit(STATUS_CT_KILL, &priv->status);
458 iwl_power_update_mode(priv, true)) {
462 IWL_ERR(priv, "Cannot update power mode, "
465 set_bit(STATUS_CT_KILL, &priv->status);
468 IWL_DEBUG_TEMP(priv,
474 IWL_DEBUG_TEMP(priv,
476 set_bit(STATUS_CT_KILL, &priv->status);
477 iwl_perform_ct_kill_task(priv, true);
479 iwl_prepare_ct_kill_task(priv);
484 IWL_DEBUG_TEMP(priv, "Exit IWL_TI_CT_KILL\n");
485 iwl_perform_ct_kill_task(priv, false);
488 mutex_unlock(&priv->mutex);
504 struct iwl_priv *priv = container_of(work, struct iwl_priv, ct_enter);
505 struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
507 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
510 if (!iwl_is_ready(priv))
514 IWL_ERR(priv, "Device reached critical temperature "
516 if (!priv->thermal_throttle.advanced_tt)
517 iwl_legacy_tt_handler(priv,
521 iwl_advance_tt_handler(priv,
533 struct iwl_priv *priv = container_of(work, struct iwl_priv, ct_exit);
534 struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
536 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
539 if (!iwl_is_ready(priv))
543 del_timer_sync(&priv->thermal_throttle.ct_kill_exit_tm);
546 IWL_ERR(priv,
553 priv->temperature = 0;
554 if (!priv->thermal_throttle.advanced_tt)
555 iwl_legacy_tt_handler(priv,
559 iwl_advance_tt_handler(priv, CT_KILL_EXIT_THRESHOLD,
564 void iwl_tt_enter_ct_kill(struct iwl_priv *priv)
566 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
569 IWL_DEBUG_TEMP(priv, "Queueing critical temperature enter.\n");
570 queue_work(priv->workqueue, &priv->ct_enter);
573 void iwl_tt_exit_ct_kill(struct iwl_priv *priv)
575 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
578 IWL_DEBUG_TEMP(priv, "Queueing critical temperature exit.\n");
579 queue_work(priv->workqueue, &priv->ct_exit);
584 struct iwl_priv *priv = container_of(work, struct iwl_priv, tt_work);
585 s32 temp = priv->temperature; /* degrees CELSIUS except specified */
587 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
590 if (!priv->thermal_throttle.advanced_tt)
591 iwl_legacy_tt_handler(priv, temp, false);
593 iwl_advance_tt_handler(priv, temp, false);
596 void iwl_tt_handler(struct iwl_priv *priv)
598 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
601 IWL_DEBUG_TEMP(priv, "Queueing thermal throttling work.\n");
602 queue_work(priv->workqueue, &priv->tt_work);
610 void iwl_tt_initialize(struct iwl_priv *priv)
612 struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
616 IWL_DEBUG_TEMP(priv, "Initialize Thermal Throttling\n");
621 init_timer(&priv->thermal_throttle.ct_kill_exit_tm);
622 priv->thermal_throttle.ct_kill_exit_tm.data = (unsigned long)priv;
623 priv->thermal_throttle.ct_kill_exit_tm.function =
625 init_timer(&priv->thermal_throttle.ct_kill_waiting_tm);
626 priv->thermal_throttle.ct_kill_waiting_tm.data =
627 (unsigned long)priv;
628 priv->thermal_throttle.ct_kill_waiting_tm.function =
631 INIT_WORK(&priv->tt_work, iwl_bg_tt_work);
632 INIT_WORK(&priv->ct_enter, iwl_bg_ct_enter);
633 INIT_WORK(&priv->ct_exit, iwl_bg_ct_exit);
635 if (cfg(priv)->base_params->adv_thermal_throttle) {
636 IWL_DEBUG_TEMP(priv, "Advanced Thermal Throttling\n");
645 IWL_ERR(priv, "Fallback to Legacy Throttling\n");
646 priv->thermal_throttle.advanced_tt = false;
668 priv->thermal_throttle.advanced_tt = true;
671 IWL_DEBUG_TEMP(priv, "Legacy Thermal Throttling\n");
672 priv->thermal_throttle.advanced_tt = false;
677 void iwl_tt_exit(struct iwl_priv *priv)
679 struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
682 del_timer_sync(&priv->thermal_throttle.ct_kill_exit_tm);
684 del_timer_sync(&priv->thermal_throttle.ct_kill_waiting_tm);
685 cancel_work_sync(&priv->tt_work);
686 cancel_work_sync(&priv->ct_enter);
687 cancel_work_sync(&priv->ct_exit);
689 if (priv->thermal_throttle.advanced_tt) {