blob: 58b762f1e0b54a2cd40a1db7b71580d179d5b765 [file] [log] [blame]
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +03001/******************************************************************************
2 *
3 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
5 *
6 * GPL LICENSE SUMMARY
7 *
Emmanuel Grumbach51368bf2013-12-30 13:15:54 +02008 * Copyright(c) 2013 - 2014 Intel Corporation. All rights reserved.
Johannes Berg8b4139d2014-07-24 14:05:26 +02009 * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +030010 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of version 2 of the GNU General Public License as
13 * published by the Free Software Foundation.
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
23 * USA
24 *
25 * The full GNU General Public License is included in this distribution
26 * in the file called COPYING.
27 *
28 * Contact Information:
29 * Intel Linux Wireless <ilw@linux.intel.com>
30 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
31 *
32 * BSD LICENSE
33 *
Emmanuel Grumbach51368bf2013-12-30 13:15:54 +020034 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
Johannes Berg8b4139d2014-07-24 14:05:26 +020035 * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
Sara Sharon6eb031d2015-07-13 14:50:47 +030036 * Copyright(c) 2015 Intel Deutschland GmbH
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +030037 * All rights reserved.
38 *
39 * Redistribution and use in source and binary forms, with or without
40 * modification, are permitted provided that the following conditions
41 * are met:
42 *
43 * * Redistributions of source code must retain the above copyright
44 * notice, this list of conditions and the following disclaimer.
45 * * Redistributions in binary form must reproduce the above copyright
46 * notice, this list of conditions and the following disclaimer in
47 * the documentation and/or other materials provided with the
48 * distribution.
49 * * Neither the name Intel Corporation nor the names of its
50 * contributors may be used to endorse or promote products derived
51 * from this software without specific prior written permission.
52 *
53 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
54 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
55 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
56 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
57 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
58 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
59 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
60 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
61 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
62 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
63 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
64 *
65 *****************************************************************************/
66
67#include "mvm.h"
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +030068
Luciano Coelhoa0a09242014-09-04 12:29:15 +030069#define IWL_MVM_TEMP_NOTIF_WAIT_TIMEOUT HZ
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +030070
71static void iwl_mvm_enter_ctkill(struct iwl_mvm *mvm)
72{
Luciano Coelho19789ab2014-12-15 14:15:15 +020073 struct iwl_mvm_tt_mgmt *tt = &mvm->thermal_throttle;
Chaya Rachel Ivgi34446822015-04-19 12:26:39 +030074 u32 duration = tt->params.ct_kill_duration;
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +030075
Luciano Coelhob689fa72014-08-20 17:26:58 +030076 if (test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status))
77 return;
78
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +030079 IWL_ERR(mvm, "Enter CT Kill\n");
80 iwl_mvm_set_hw_ctkill_state(mvm, true);
Luciano Coelhoefc36db2014-08-20 17:58:20 +030081
Luciano Coelho19789ab2014-12-15 14:15:15 +020082 tt->throttle = false;
83 tt->dynamic_smps = false;
84
Luciano Coelhoefc36db2014-08-20 17:58:20 +030085 /* Don't schedule an exit work if we're in test mode, since
86 * the temperature will not change unless we manually set it
87 * again (or disable testing).
88 */
89 if (!mvm->temperature_test)
Luciano Coelho19789ab2014-12-15 14:15:15 +020090 schedule_delayed_work(&tt->ct_kill_exit,
Luciano Coelhoefc36db2014-08-20 17:58:20 +030091 round_jiffies_relative(duration * HZ));
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +030092}
93
94static void iwl_mvm_exit_ctkill(struct iwl_mvm *mvm)
95{
Luciano Coelhob689fa72014-08-20 17:26:58 +030096 if (!test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status))
97 return;
98
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +030099 IWL_ERR(mvm, "Exit CT Kill\n");
100 iwl_mvm_set_hw_ctkill_state(mvm, false);
101}
102
Luciano Coelhofd1f7552014-11-04 16:17:46 +0200103void iwl_mvm_tt_temp_changed(struct iwl_mvm *mvm, u32 temp)
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300104{
Luciano Coelhofd1f7552014-11-04 16:17:46 +0200105 /* ignore the notification if we are in test mode */
106 if (mvm->temperature_test)
107 return;
108
109 if (mvm->temperature == temp)
110 return;
111
112 mvm->temperature = temp;
113 iwl_mvm_tt_handler(mvm);
114}
115
116static int iwl_mvm_temp_notif_parse(struct iwl_mvm *mvm,
117 struct iwl_rx_packet *pkt)
118{
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300119 struct iwl_dts_measurement_notif *notif;
120 int len = iwl_rx_packet_payload_len(pkt);
Luciano Coelhofd1f7552014-11-04 16:17:46 +0200121 int temp;
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300122
123 if (WARN_ON_ONCE(len != sizeof(*notif))) {
124 IWL_ERR(mvm, "Invalid DTS_MEASUREMENT_NOTIFICATION\n");
Luciano Coelhofd1f7552014-11-04 16:17:46 +0200125 return -EINVAL;
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300126 }
127
128 notif = (void *)pkt->data;
129
Luciano Coelhofd1f7552014-11-04 16:17:46 +0200130 temp = le32_to_cpu(notif->temp);
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300131
132 /* shouldn't be negative, but since it's s32, make sure it isn't */
Luciano Coelhofd1f7552014-11-04 16:17:46 +0200133 if (WARN_ON_ONCE(temp < 0))
134 temp = 0;
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300135
Luciano Coelhofd1f7552014-11-04 16:17:46 +0200136 IWL_DEBUG_TEMP(mvm, "DTS_MEASUREMENT_NOTIFICATION - %d\n", temp);
137
138 return temp;
139}
140
141static bool iwl_mvm_temp_notif_wait(struct iwl_notif_wait_data *notif_wait,
142 struct iwl_rx_packet *pkt, void *data)
143{
144 struct iwl_mvm *mvm =
145 container_of(notif_wait, struct iwl_mvm, notif_wait);
146 int *temp = data;
147 int ret;
148
149 ret = iwl_mvm_temp_notif_parse(mvm, pkt);
150 if (ret < 0)
151 return true;
152
153 *temp = ret;
154
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300155 return true;
156}
157
Johannes Berg04168412015-06-23 21:22:09 +0200158void iwl_mvm_temp_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb)
Luciano Coelhoea9af242014-11-06 10:34:49 +0200159{
160 struct iwl_rx_packet *pkt = rxb_addr(rxb);
161 int temp;
162
163 /* the notification is handled synchronously in ctkill, so skip here */
164 if (test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status))
Johannes Berg04168412015-06-23 21:22:09 +0200165 return;
Luciano Coelhoea9af242014-11-06 10:34:49 +0200166
167 temp = iwl_mvm_temp_notif_parse(mvm, pkt);
168 if (temp < 0)
Johannes Berg04168412015-06-23 21:22:09 +0200169 return;
Luciano Coelhoea9af242014-11-06 10:34:49 +0200170
171 iwl_mvm_tt_temp_changed(mvm, temp);
Luciano Coelhoea9af242014-11-06 10:34:49 +0200172}
173
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300174static int iwl_mvm_get_temp_cmd(struct iwl_mvm *mvm)
175{
176 struct iwl_dts_measurement_cmd cmd = {
177 .flags = cpu_to_le32(DTS_TRIGGER_CMD_FLAGS_TEMP),
178 };
Aviya Erenfeld09eef332015-09-01 19:34:38 +0300179 u32 cmdid;
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300180
Aviya Erenfeld09eef332015-09-01 19:34:38 +0300181 if (fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_WIDE_CMD_HDR))
182 cmdid = iwl_cmd_id(CMD_DTS_MEASUREMENT_TRIGGER_WIDE,
183 PHY_OPS_GROUP, 0);
184 else
185 cmdid = CMD_DTS_MEASUREMENT_TRIGGER;
186 return iwl_mvm_send_cmd_pdu(mvm, cmdid, 0,
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300187 sizeof(cmd), &cmd);
188}
189
Luciano Coelhoc549e392014-09-04 15:58:47 +0300190int iwl_mvm_get_temp(struct iwl_mvm *mvm)
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300191{
192 struct iwl_notification_wait wait_temp_notif;
Aviya Erenfeld09eef332015-09-01 19:34:38 +0300193 static u16 temp_notif[] = { WIDE_ID(PHY_OPS_GROUP,
194 DTS_MEASUREMENT_NOTIF_WIDE) };
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300195 int ret, temp;
196
Aviya Erenfeld09eef332015-09-01 19:34:38 +0300197 if (!fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_WIDE_CMD_HDR))
198 temp_notif[0] = DTS_MEASUREMENT_NOTIFICATION;
199
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300200 lockdep_assert_held(&mvm->mutex);
201
202 iwl_init_notification_wait(&mvm->notif_wait, &wait_temp_notif,
203 temp_notif, ARRAY_SIZE(temp_notif),
Luciano Coelhofd1f7552014-11-04 16:17:46 +0200204 iwl_mvm_temp_notif_wait, &temp);
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300205
206 ret = iwl_mvm_get_temp_cmd(mvm);
207 if (ret) {
208 IWL_ERR(mvm, "Failed to get the temperature (err=%d)\n", ret);
209 iwl_remove_notification(&mvm->notif_wait, &wait_temp_notif);
210 return ret;
211 }
212
213 ret = iwl_wait_notification(&mvm->notif_wait, &wait_temp_notif,
214 IWL_MVM_TEMP_NOTIF_WAIT_TIMEOUT);
215 if (ret) {
216 IWL_ERR(mvm, "Getting the temperature timed out\n");
217 return ret;
218 }
219
220 return temp;
221}
222
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300223static void check_exit_ctkill(struct work_struct *work)
224{
225 struct iwl_mvm_tt_mgmt *tt;
226 struct iwl_mvm *mvm;
227 u32 duration;
228 s32 temp;
229
230 tt = container_of(work, struct iwl_mvm_tt_mgmt, ct_kill_exit.work);
231 mvm = container_of(tt, struct iwl_mvm, thermal_throttle);
232
Chaya Rachel Ivgi34446822015-04-19 12:26:39 +0300233 duration = tt->params.ct_kill_duration;
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300234
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300235 mutex_lock(&mvm->mutex);
236
237 if (__iwl_mvm_mac_start(mvm))
Eliad Peller576eeee2014-07-01 18:38:38 +0300238 goto reschedule;
239
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300240 /* make sure the device is available for direct read/writes */
241 if (iwl_mvm_ref_sync(mvm, IWL_MVM_REF_CHECK_CTKILL)) {
242 __iwl_mvm_mac_stop(mvm);
243 goto reschedule;
244 }
245
246 temp = iwl_mvm_get_temp(mvm);
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300247
Eliad Peller576eeee2014-07-01 18:38:38 +0300248 iwl_mvm_unref(mvm, IWL_MVM_REF_CHECK_CTKILL);
249
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300250 __iwl_mvm_mac_stop(mvm);
251
252 if (temp < 0)
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300253 goto reschedule;
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300254
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300255 IWL_DEBUG_TEMP(mvm, "NIC temperature: %d\n", temp);
256
Chaya Rachel Ivgi34446822015-04-19 12:26:39 +0300257 if (temp <= tt->params.ct_kill_exit) {
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300258 mutex_unlock(&mvm->mutex);
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300259 iwl_mvm_exit_ctkill(mvm);
260 return;
261 }
262
263reschedule:
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300264 mutex_unlock(&mvm->mutex);
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300265 schedule_delayed_work(&mvm->thermal_throttle.ct_kill_exit,
266 round_jiffies(duration * HZ));
267}
268
269static void iwl_mvm_tt_smps_iterator(void *_data, u8 *mac,
270 struct ieee80211_vif *vif)
271{
272 struct iwl_mvm *mvm = _data;
273 enum ieee80211_smps_mode smps_mode;
274
275 lockdep_assert_held(&mvm->mutex);
276
277 if (mvm->thermal_throttle.dynamic_smps)
278 smps_mode = IEEE80211_SMPS_DYNAMIC;
279 else
280 smps_mode = IEEE80211_SMPS_AUTOMATIC;
281
Eytan Lifshitzfded3132013-06-04 12:28:51 +0300282 if (vif->type != NL80211_IFTYPE_STATION)
283 return;
284
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300285 iwl_mvm_update_smps(mvm, vif, IWL_MVM_SMPS_REQ_TT, smps_mode);
286}
287
288static void iwl_mvm_tt_tx_protection(struct iwl_mvm *mvm, bool enable)
289{
290 struct ieee80211_sta *sta;
291 struct iwl_mvm_sta *mvmsta;
292 int i, err;
293
294 for (i = 0; i < IWL_MVM_STATION_COUNT; i++) {
295 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[i],
296 lockdep_is_held(&mvm->mutex));
297 if (IS_ERR_OR_NULL(sta))
298 continue;
Johannes Berg5b577a92013-11-14 18:20:04 +0100299 mvmsta = iwl_mvm_sta_from_mac80211(sta);
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300300 if (enable == mvmsta->tt_tx_protection)
301 continue;
Johannes Berge126b5d2013-06-28 13:39:18 +0200302 err = iwl_mvm_tx_protection(mvm, mvmsta, enable);
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300303 if (err) {
304 IWL_ERR(mvm, "Failed to %s Tx protection\n",
305 enable ? "enable" : "disable");
306 } else {
307 IWL_DEBUG_TEMP(mvm, "%s Tx protection\n",
308 enable ? "Enable" : "Disable");
309 mvmsta->tt_tx_protection = enable;
310 }
311 }
312}
313
Ido Yariv0c0e2c72014-01-16 21:12:02 -0500314void iwl_mvm_tt_tx_backoff(struct iwl_mvm *mvm, u32 backoff)
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300315{
316 struct iwl_host_cmd cmd = {
317 .id = REPLY_THERMAL_MNG_BACKOFF,
318 .len = { sizeof(u32), },
319 .data = { &backoff, },
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300320 };
321
Ido Yariv0c0e2c72014-01-16 21:12:02 -0500322 backoff = max(backoff, mvm->thermal_throttle.min_backoff);
323
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300324 if (iwl_mvm_send_cmd(mvm, &cmd) == 0) {
325 IWL_DEBUG_TEMP(mvm, "Set Thermal Tx backoff to: %u\n",
326 backoff);
327 mvm->thermal_throttle.tx_backoff = backoff;
328 } else {
329 IWL_ERR(mvm, "Failed to change Thermal Tx backoff\n");
330 }
331}
332
333void iwl_mvm_tt_handler(struct iwl_mvm *mvm)
334{
Chaya Rachel Ivgi34446822015-04-19 12:26:39 +0300335 struct iwl_tt_params *params = &mvm->thermal_throttle.params;
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300336 struct iwl_mvm_tt_mgmt *tt = &mvm->thermal_throttle;
337 s32 temperature = mvm->temperature;
eytan lifshitzdafe6c42013-06-18 14:28:56 +0300338 bool throttle_enable = false;
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300339 int i;
340 u32 tx_backoff;
341
342 IWL_DEBUG_TEMP(mvm, "NIC temperature: %d\n", mvm->temperature);
343
344 if (params->support_ct_kill && temperature >= params->ct_kill_entry) {
345 iwl_mvm_enter_ctkill(mvm);
346 return;
347 }
348
Luciano Coelhob689fa72014-08-20 17:26:58 +0300349 if (params->support_ct_kill &&
Chaya Rachel Ivgi34446822015-04-19 12:26:39 +0300350 temperature <= params->ct_kill_exit) {
Luciano Coelhob689fa72014-08-20 17:26:58 +0300351 iwl_mvm_exit_ctkill(mvm);
352 return;
353 }
354
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300355 if (params->support_dynamic_smps) {
356 if (!tt->dynamic_smps &&
357 temperature >= params->dynamic_smps_entry) {
358 IWL_DEBUG_TEMP(mvm, "Enable dynamic SMPS\n");
359 tt->dynamic_smps = true;
360 ieee80211_iterate_active_interfaces_atomic(
361 mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
362 iwl_mvm_tt_smps_iterator, mvm);
eytan lifshitzdafe6c42013-06-18 14:28:56 +0300363 throttle_enable = true;
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300364 } else if (tt->dynamic_smps &&
365 temperature <= params->dynamic_smps_exit) {
366 IWL_DEBUG_TEMP(mvm, "Disable dynamic SMPS\n");
367 tt->dynamic_smps = false;
368 ieee80211_iterate_active_interfaces_atomic(
369 mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
370 iwl_mvm_tt_smps_iterator, mvm);
371 }
372 }
373
374 if (params->support_tx_protection) {
eytan lifshitzdafe6c42013-06-18 14:28:56 +0300375 if (temperature >= params->tx_protection_entry) {
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300376 iwl_mvm_tt_tx_protection(mvm, true);
eytan lifshitzdafe6c42013-06-18 14:28:56 +0300377 throttle_enable = true;
378 } else if (temperature <= params->tx_protection_exit) {
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300379 iwl_mvm_tt_tx_protection(mvm, false);
eytan lifshitzdafe6c42013-06-18 14:28:56 +0300380 }
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300381 }
382
383 if (params->support_tx_backoff) {
Eytan Lifshitz1b8ebbd2014-04-01 16:44:21 +0300384 tx_backoff = tt->min_backoff;
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300385 for (i = 0; i < TT_TX_BACKOFF_SIZE; i++) {
386 if (temperature < params->tx_backoff[i].temperature)
387 break;
Eytan Lifshitz1b8ebbd2014-04-01 16:44:21 +0300388 tx_backoff = max(tt->min_backoff,
389 params->tx_backoff[i].backoff);
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300390 }
Eytan Lifshitz1b8ebbd2014-04-01 16:44:21 +0300391 if (tx_backoff != tt->min_backoff)
eytan lifshitzdafe6c42013-06-18 14:28:56 +0300392 throttle_enable = true;
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300393 if (tt->tx_backoff != tx_backoff)
394 iwl_mvm_tt_tx_backoff(mvm, tx_backoff);
395 }
eytan lifshitzdafe6c42013-06-18 14:28:56 +0300396
397 if (!tt->throttle && throttle_enable) {
398 IWL_WARN(mvm,
399 "Due to high temperature thermal throttling initiated\n");
400 tt->throttle = true;
Eytan Lifshitz19a04bd2014-04-02 21:37:57 +0300401 } else if (tt->throttle && !tt->dynamic_smps &&
402 tt->tx_backoff == tt->min_backoff &&
eytan lifshitzdafe6c42013-06-18 14:28:56 +0300403 temperature <= params->tx_protection_exit) {
404 IWL_WARN(mvm,
405 "Temperature is back to normal thermal throttling stopped\n");
406 tt->throttle = false;
407 }
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300408}
409
Chaya Rachel Ivgi34446822015-04-19 12:26:39 +0300410static const struct iwl_tt_params iwl_mvm_default_tt_params = {
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300411 .ct_kill_entry = 118,
412 .ct_kill_exit = 96,
413 .ct_kill_duration = 5,
414 .dynamic_smps_entry = 114,
415 .dynamic_smps_exit = 110,
416 .tx_protection_entry = 114,
417 .tx_protection_exit = 108,
418 .tx_backoff = {
419 {.temperature = 112, .backoff = 200},
420 {.temperature = 113, .backoff = 600},
421 {.temperature = 114, .backoff = 1200},
422 {.temperature = 115, .backoff = 2000},
423 {.temperature = 116, .backoff = 4000},
424 {.temperature = 117, .backoff = 10000},
425 },
426 .support_ct_kill = true,
427 .support_dynamic_smps = true,
428 .support_tx_protection = true,
429 .support_tx_backoff = true,
430};
431
Ido Yariv0c0e2c72014-01-16 21:12:02 -0500432void iwl_mvm_tt_initialize(struct iwl_mvm *mvm, u32 min_backoff)
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300433{
434 struct iwl_mvm_tt_mgmt *tt = &mvm->thermal_throttle;
435
436 IWL_DEBUG_TEMP(mvm, "Initialize Thermal Throttling\n");
Eytan Lifshitz6be497f2013-07-24 14:49:18 +0300437
Chaya Rachel Ivgi34446822015-04-19 12:26:39 +0300438 if (mvm->cfg->thermal_params)
439 tt->params = *mvm->cfg->thermal_params;
Eytan Lifshitz6be497f2013-07-24 14:49:18 +0300440 else
Chaya Rachel Ivgi34446822015-04-19 12:26:39 +0300441 tt->params = iwl_mvm_default_tt_params;
Eytan Lifshitz6be497f2013-07-24 14:49:18 +0300442
eytan lifshitzdafe6c42013-06-18 14:28:56 +0300443 tt->throttle = false;
Luciano Coelho19789ab2014-12-15 14:15:15 +0200444 tt->dynamic_smps = false;
Ido Yariv0c0e2c72014-01-16 21:12:02 -0500445 tt->min_backoff = min_backoff;
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300446 INIT_DELAYED_WORK(&tt->ct_kill_exit, check_exit_ctkill);
447}
448
449void iwl_mvm_tt_exit(struct iwl_mvm *mvm)
450{
451 cancel_delayed_work_sync(&mvm->thermal_throttle.ct_kill_exit);
452 IWL_DEBUG_TEMP(mvm, "Exit Thermal Throttling\n");
453}