blob: 58fc7b3c711c735c04fedddb94691a70c9aeef70 [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
Chaya Rachel Ivgi0a3b7112015-12-16 16:34:55 +020010 * Copyright(c) 2015 - 2016 Intel Deutschland GmbH
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +030011 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of version 2 of the GNU General Public License as
14 * published by the Free Software Foundation.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
24 * USA
25 *
26 * The full GNU General Public License is included in this distribution
27 * in the file called COPYING.
28 *
29 * Contact Information:
Emmanuel Grumbachd01c5362015-11-17 15:39:56 +020030 * Intel Linux Wireless <linuxwifi@intel.com>
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +030031 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
32 *
33 * BSD LICENSE
34 *
Emmanuel Grumbach51368bf2013-12-30 13:15:54 +020035 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
Johannes Berg8b4139d2014-07-24 14:05:26 +020036 * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
Chaya Rachel Ivgi0a3b7112015-12-16 16:34:55 +020037 * Copyright(c) 2015 - 2016 Intel Deutschland GmbH
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +030038 * All rights reserved.
39 *
40 * Redistribution and use in source and binary forms, with or without
41 * modification, are permitted provided that the following conditions
42 * are met:
43 *
44 * * Redistributions of source code must retain the above copyright
45 * notice, this list of conditions and the following disclaimer.
46 * * Redistributions in binary form must reproduce the above copyright
47 * notice, this list of conditions and the following disclaimer in
48 * the documentation and/or other materials provided with the
49 * distribution.
50 * * Neither the name Intel Corporation nor the names of its
51 * contributors may be used to endorse or promote products derived
52 * from this software without specific prior written permission.
53 *
54 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
55 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
56 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
57 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
58 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
59 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
60 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
61 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
62 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
63 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
64 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
65 *
66 *****************************************************************************/
67
Chaya Rachel Ivgic221daf2015-12-29 09:54:49 +020068#include <linux/sort.h>
69
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +030070#include "mvm.h"
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +030071
Luciano Coelhoa0a09242014-09-04 12:29:15 +030072#define IWL_MVM_TEMP_NOTIF_WAIT_TIMEOUT HZ
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +030073
74static void iwl_mvm_enter_ctkill(struct iwl_mvm *mvm)
75{
Luciano Coelho19789ab2014-12-15 14:15:15 +020076 struct iwl_mvm_tt_mgmt *tt = &mvm->thermal_throttle;
Chaya Rachel Ivgi34446822015-04-19 12:26:39 +030077 u32 duration = tt->params.ct_kill_duration;
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +030078
Luciano Coelhob689fa72014-08-20 17:26:58 +030079 if (test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status))
80 return;
81
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +030082 IWL_ERR(mvm, "Enter CT Kill\n");
83 iwl_mvm_set_hw_ctkill_state(mvm, true);
Luciano Coelhoefc36db2014-08-20 17:58:20 +030084
Chaya Rachel Ivgic221daf2015-12-29 09:54:49 +020085 if (!iwl_mvm_is_tt_in_fw(mvm)) {
86 tt->throttle = false;
87 tt->dynamic_smps = false;
88 }
Luciano Coelho19789ab2014-12-15 14:15:15 +020089
Luciano Coelhoefc36db2014-08-20 17:58:20 +030090 /* Don't schedule an exit work if we're in test mode, since
91 * the temperature will not change unless we manually set it
92 * again (or disable testing).
93 */
94 if (!mvm->temperature_test)
Luciano Coelho19789ab2014-12-15 14:15:15 +020095 schedule_delayed_work(&tt->ct_kill_exit,
Luciano Coelhoefc36db2014-08-20 17:58:20 +030096 round_jiffies_relative(duration * HZ));
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +030097}
98
99static void iwl_mvm_exit_ctkill(struct iwl_mvm *mvm)
100{
Luciano Coelhob689fa72014-08-20 17:26:58 +0300101 if (!test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status))
102 return;
103
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300104 IWL_ERR(mvm, "Exit CT Kill\n");
105 iwl_mvm_set_hw_ctkill_state(mvm, false);
106}
107
Luciano Coelhofd1f7552014-11-04 16:17:46 +0200108void iwl_mvm_tt_temp_changed(struct iwl_mvm *mvm, u32 temp)
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300109{
Luciano Coelhofd1f7552014-11-04 16:17:46 +0200110 /* ignore the notification if we are in test mode */
111 if (mvm->temperature_test)
112 return;
113
114 if (mvm->temperature == temp)
115 return;
116
117 mvm->temperature = temp;
118 iwl_mvm_tt_handler(mvm);
119}
120
121static int iwl_mvm_temp_notif_parse(struct iwl_mvm *mvm,
122 struct iwl_rx_packet *pkt)
123{
Chaya Rachel Ivgic221daf2015-12-29 09:54:49 +0200124 struct iwl_dts_measurement_notif_v1 *notif_v1;
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300125 int len = iwl_rx_packet_payload_len(pkt);
Luciano Coelhofd1f7552014-11-04 16:17:46 +0200126 int temp;
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300127
Chaya Rachel Ivgic221daf2015-12-29 09:54:49 +0200128 /* we can use notif_v1 only, because v2 only adds an additional
129 * parameter, which is not used in this function.
130 */
131 if (WARN_ON_ONCE(len < sizeof(*notif_v1))) {
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300132 IWL_ERR(mvm, "Invalid DTS_MEASUREMENT_NOTIFICATION\n");
Luciano Coelhofd1f7552014-11-04 16:17:46 +0200133 return -EINVAL;
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300134 }
135
Chaya Rachel Ivgic221daf2015-12-29 09:54:49 +0200136 notif_v1 = (void *)pkt->data;
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300137
Chaya Rachel Ivgic221daf2015-12-29 09:54:49 +0200138 temp = le32_to_cpu(notif_v1->temp);
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300139
140 /* shouldn't be negative, but since it's s32, make sure it isn't */
Luciano Coelhofd1f7552014-11-04 16:17:46 +0200141 if (WARN_ON_ONCE(temp < 0))
142 temp = 0;
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300143
Luciano Coelhofd1f7552014-11-04 16:17:46 +0200144 IWL_DEBUG_TEMP(mvm, "DTS_MEASUREMENT_NOTIFICATION - %d\n", temp);
145
146 return temp;
147}
148
149static bool iwl_mvm_temp_notif_wait(struct iwl_notif_wait_data *notif_wait,
150 struct iwl_rx_packet *pkt, void *data)
151{
152 struct iwl_mvm *mvm =
153 container_of(notif_wait, struct iwl_mvm, notif_wait);
154 int *temp = data;
155 int ret;
156
157 ret = iwl_mvm_temp_notif_parse(mvm, pkt);
158 if (ret < 0)
159 return true;
160
161 *temp = ret;
162
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300163 return true;
164}
165
Johannes Berg04168412015-06-23 21:22:09 +0200166void iwl_mvm_temp_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb)
Luciano Coelhoea9af242014-11-06 10:34:49 +0200167{
168 struct iwl_rx_packet *pkt = rxb_addr(rxb);
Chaya Rachel Ivgic221daf2015-12-29 09:54:49 +0200169 struct iwl_dts_measurement_notif_v2 *notif_v2;
170 int len = iwl_rx_packet_payload_len(pkt);
Luciano Coelhoea9af242014-11-06 10:34:49 +0200171 int temp;
Chaya Rachel Ivgic221daf2015-12-29 09:54:49 +0200172 u32 ths_crossed;
Luciano Coelhoea9af242014-11-06 10:34:49 +0200173
174 /* the notification is handled synchronously in ctkill, so skip here */
175 if (test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status))
Johannes Berg04168412015-06-23 21:22:09 +0200176 return;
Luciano Coelhoea9af242014-11-06 10:34:49 +0200177
178 temp = iwl_mvm_temp_notif_parse(mvm, pkt);
Chaya Rachel Ivgic221daf2015-12-29 09:54:49 +0200179
180 if (!iwl_mvm_is_tt_in_fw(mvm)) {
181 if (temp >= 0)
182 iwl_mvm_tt_temp_changed(mvm, temp);
183 return;
184 }
185
186 if (WARN_ON_ONCE(len < sizeof(*notif_v2))) {
187 IWL_ERR(mvm, "Invalid DTS_MEASUREMENT_NOTIFICATION\n");
188 return;
189 }
190
191 notif_v2 = (void *)pkt->data;
192 ths_crossed = le32_to_cpu(notif_v2->threshold_idx);
193
194 /* 0xFF in ths_crossed means the notification is not related
195 * to a trip, so we can ignore it here.
196 */
197 if (ths_crossed == 0xFF)
Johannes Berg04168412015-06-23 21:22:09 +0200198 return;
Luciano Coelhoea9af242014-11-06 10:34:49 +0200199
Chaya Rachel Ivgic221daf2015-12-29 09:54:49 +0200200 IWL_DEBUG_TEMP(mvm, "Temp = %d Threshold crossed = %d\n",
201 temp, ths_crossed);
202
203#ifdef CONFIG_THERMAL
204 if (WARN_ON(ths_crossed >= IWL_MAX_DTS_TRIPS))
205 return;
206
Emmanuel Grumbach91f66a32016-02-28 10:15:08 +0200207 if (mvm->tz_device.tzone) {
208 struct iwl_mvm_thermal_device *tz_dev = &mvm->tz_device;
209
Emmanuel Grumbach91f66a32016-02-28 10:15:08 +0200210 thermal_notify_framework(tz_dev->tzone,
211 tz_dev->fw_trips_index[ths_crossed]);
Emmanuel Grumbach91f66a32016-02-28 10:15:08 +0200212 }
Chaya Rachel Ivgic221daf2015-12-29 09:54:49 +0200213#endif /* CONFIG_THERMAL */
Luciano Coelhoea9af242014-11-06 10:34:49 +0200214}
215
Chaya Rachel Ivgi0a3b7112015-12-16 16:34:55 +0200216void iwl_mvm_ct_kill_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb)
217{
218 struct iwl_rx_packet *pkt = rxb_addr(rxb);
219 struct ct_kill_notif *notif;
220 int len = iwl_rx_packet_payload_len(pkt);
221
222 if (WARN_ON_ONCE(len != sizeof(*notif))) {
223 IWL_ERR(mvm, "Invalid CT_KILL_NOTIFICATION\n");
224 return;
225 }
226
227 notif = (struct ct_kill_notif *)pkt->data;
228 IWL_DEBUG_TEMP(mvm, "CT Kill notification temperature = %d\n",
229 notif->temperature);
230
231 iwl_mvm_enter_ctkill(mvm);
232}
233
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300234static int iwl_mvm_get_temp_cmd(struct iwl_mvm *mvm)
235{
236 struct iwl_dts_measurement_cmd cmd = {
237 .flags = cpu_to_le32(DTS_TRIGGER_CMD_FLAGS_TEMP),
238 };
Arik Nemtsov78efc702015-10-06 12:22:47 +0300239 struct iwl_ext_dts_measurement_cmd extcmd = {
240 .control_mode = cpu_to_le32(DTS_AUTOMATIC),
241 };
Aviya Erenfeld09eef332015-09-01 19:34:38 +0300242 u32 cmdid;
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300243
Aviya Erenfeld09eef332015-09-01 19:34:38 +0300244 if (fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_WIDE_CMD_HDR))
245 cmdid = iwl_cmd_id(CMD_DTS_MEASUREMENT_TRIGGER_WIDE,
246 PHY_OPS_GROUP, 0);
247 else
248 cmdid = CMD_DTS_MEASUREMENT_TRIGGER;
Arik Nemtsov78efc702015-10-06 12:22:47 +0300249
250 if (!fw_has_capa(&mvm->fw->ucode_capa,
251 IWL_UCODE_TLV_CAPA_EXTENDED_DTS_MEASURE))
252 return iwl_mvm_send_cmd_pdu(mvm, cmdid, 0, sizeof(cmd), &cmd);
253
254 return iwl_mvm_send_cmd_pdu(mvm, cmdid, 0, sizeof(extcmd), &extcmd);
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300255}
256
Chaya Rachel Ivgi78693182015-12-27 13:45:42 +0200257int iwl_mvm_get_temp(struct iwl_mvm *mvm, s32 *temp)
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300258{
259 struct iwl_notification_wait wait_temp_notif;
Aviya Erenfeld09eef332015-09-01 19:34:38 +0300260 static u16 temp_notif[] = { WIDE_ID(PHY_OPS_GROUP,
261 DTS_MEASUREMENT_NOTIF_WIDE) };
Chaya Rachel Ivgi78693182015-12-27 13:45:42 +0200262 int ret;
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300263
Aviya Erenfeld09eef332015-09-01 19:34:38 +0300264 if (!fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_WIDE_CMD_HDR))
265 temp_notif[0] = DTS_MEASUREMENT_NOTIFICATION;
266
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300267 lockdep_assert_held(&mvm->mutex);
268
269 iwl_init_notification_wait(&mvm->notif_wait, &wait_temp_notif,
270 temp_notif, ARRAY_SIZE(temp_notif),
Chaya Rachel Ivgi78693182015-12-27 13:45:42 +0200271 iwl_mvm_temp_notif_wait, temp);
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300272
273 ret = iwl_mvm_get_temp_cmd(mvm);
274 if (ret) {
275 IWL_ERR(mvm, "Failed to get the temperature (err=%d)\n", ret);
276 iwl_remove_notification(&mvm->notif_wait, &wait_temp_notif);
277 return ret;
278 }
279
280 ret = iwl_wait_notification(&mvm->notif_wait, &wait_temp_notif,
281 IWL_MVM_TEMP_NOTIF_WAIT_TIMEOUT);
Chaya Rachel Ivgi78693182015-12-27 13:45:42 +0200282 if (ret)
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300283 IWL_ERR(mvm, "Getting the temperature timed out\n");
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300284
Chaya Rachel Ivgi78693182015-12-27 13:45:42 +0200285 return ret;
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300286}
287
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300288static void check_exit_ctkill(struct work_struct *work)
289{
290 struct iwl_mvm_tt_mgmt *tt;
291 struct iwl_mvm *mvm;
292 u32 duration;
293 s32 temp;
Chaya Rachel Ivgi78693182015-12-27 13:45:42 +0200294 int ret;
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300295
296 tt = container_of(work, struct iwl_mvm_tt_mgmt, ct_kill_exit.work);
297 mvm = container_of(tt, struct iwl_mvm, thermal_throttle);
298
Chaya Rachel Ivgi0a3b7112015-12-16 16:34:55 +0200299 if (iwl_mvm_is_tt_in_fw(mvm)) {
300 iwl_mvm_exit_ctkill(mvm);
301
302 return;
303 }
304
Chaya Rachel Ivgi34446822015-04-19 12:26:39 +0300305 duration = tt->params.ct_kill_duration;
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300306
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300307 mutex_lock(&mvm->mutex);
308
309 if (__iwl_mvm_mac_start(mvm))
Eliad Peller576eeee2014-07-01 18:38:38 +0300310 goto reschedule;
311
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300312 /* make sure the device is available for direct read/writes */
313 if (iwl_mvm_ref_sync(mvm, IWL_MVM_REF_CHECK_CTKILL)) {
314 __iwl_mvm_mac_stop(mvm);
315 goto reschedule;
316 }
317
Chaya Rachel Ivgi78693182015-12-27 13:45:42 +0200318 ret = iwl_mvm_get_temp(mvm, &temp);
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300319
Eliad Peller576eeee2014-07-01 18:38:38 +0300320 iwl_mvm_unref(mvm, IWL_MVM_REF_CHECK_CTKILL);
321
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300322 __iwl_mvm_mac_stop(mvm);
323
Chaya Rachel Ivgi78693182015-12-27 13:45:42 +0200324 if (ret)
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300325 goto reschedule;
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300326
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300327 IWL_DEBUG_TEMP(mvm, "NIC temperature: %d\n", temp);
328
Chaya Rachel Ivgi34446822015-04-19 12:26:39 +0300329 if (temp <= tt->params.ct_kill_exit) {
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300330 mutex_unlock(&mvm->mutex);
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300331 iwl_mvm_exit_ctkill(mvm);
332 return;
333 }
334
335reschedule:
Luciano Coelhoa0a09242014-09-04 12:29:15 +0300336 mutex_unlock(&mvm->mutex);
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300337 schedule_delayed_work(&mvm->thermal_throttle.ct_kill_exit,
338 round_jiffies(duration * HZ));
339}
340
341static void iwl_mvm_tt_smps_iterator(void *_data, u8 *mac,
342 struct ieee80211_vif *vif)
343{
344 struct iwl_mvm *mvm = _data;
345 enum ieee80211_smps_mode smps_mode;
346
347 lockdep_assert_held(&mvm->mutex);
348
349 if (mvm->thermal_throttle.dynamic_smps)
350 smps_mode = IEEE80211_SMPS_DYNAMIC;
351 else
352 smps_mode = IEEE80211_SMPS_AUTOMATIC;
353
Eytan Lifshitzfded3132013-06-04 12:28:51 +0300354 if (vif->type != NL80211_IFTYPE_STATION)
355 return;
356
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300357 iwl_mvm_update_smps(mvm, vif, IWL_MVM_SMPS_REQ_TT, smps_mode);
358}
359
360static void iwl_mvm_tt_tx_protection(struct iwl_mvm *mvm, bool enable)
361{
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300362 struct iwl_mvm_sta *mvmsta;
363 int i, err;
364
365 for (i = 0; i < IWL_MVM_STATION_COUNT; i++) {
Sara Sharon13303c02016-04-10 15:51:54 +0300366 mvmsta = iwl_mvm_sta_from_staid_protected(mvm, i);
367 if (!mvmsta)
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300368 continue;
Sara Sharon13303c02016-04-10 15:51:54 +0300369
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300370 if (enable == mvmsta->tt_tx_protection)
371 continue;
Johannes Berge126b5d2013-06-28 13:39:18 +0200372 err = iwl_mvm_tx_protection(mvm, mvmsta, enable);
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300373 if (err) {
374 IWL_ERR(mvm, "Failed to %s Tx protection\n",
375 enable ? "enable" : "disable");
376 } else {
377 IWL_DEBUG_TEMP(mvm, "%s Tx protection\n",
378 enable ? "Enable" : "Disable");
379 mvmsta->tt_tx_protection = enable;
380 }
381 }
382}
383
Ido Yariv0c0e2c72014-01-16 21:12:02 -0500384void iwl_mvm_tt_tx_backoff(struct iwl_mvm *mvm, u32 backoff)
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300385{
386 struct iwl_host_cmd cmd = {
387 .id = REPLY_THERMAL_MNG_BACKOFF,
388 .len = { sizeof(u32), },
389 .data = { &backoff, },
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300390 };
391
Ido Yariv0c0e2c72014-01-16 21:12:02 -0500392 backoff = max(backoff, mvm->thermal_throttle.min_backoff);
393
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300394 if (iwl_mvm_send_cmd(mvm, &cmd) == 0) {
395 IWL_DEBUG_TEMP(mvm, "Set Thermal Tx backoff to: %u\n",
396 backoff);
397 mvm->thermal_throttle.tx_backoff = backoff;
398 } else {
399 IWL_ERR(mvm, "Failed to change Thermal Tx backoff\n");
400 }
401}
402
403void iwl_mvm_tt_handler(struct iwl_mvm *mvm)
404{
Chaya Rachel Ivgi34446822015-04-19 12:26:39 +0300405 struct iwl_tt_params *params = &mvm->thermal_throttle.params;
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300406 struct iwl_mvm_tt_mgmt *tt = &mvm->thermal_throttle;
407 s32 temperature = mvm->temperature;
eytan lifshitzdafe6c42013-06-18 14:28:56 +0300408 bool throttle_enable = false;
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300409 int i;
410 u32 tx_backoff;
411
412 IWL_DEBUG_TEMP(mvm, "NIC temperature: %d\n", mvm->temperature);
413
414 if (params->support_ct_kill && temperature >= params->ct_kill_entry) {
415 iwl_mvm_enter_ctkill(mvm);
416 return;
417 }
418
Luciano Coelhob689fa72014-08-20 17:26:58 +0300419 if (params->support_ct_kill &&
Chaya Rachel Ivgi34446822015-04-19 12:26:39 +0300420 temperature <= params->ct_kill_exit) {
Luciano Coelhob689fa72014-08-20 17:26:58 +0300421 iwl_mvm_exit_ctkill(mvm);
422 return;
423 }
424
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300425 if (params->support_dynamic_smps) {
426 if (!tt->dynamic_smps &&
427 temperature >= params->dynamic_smps_entry) {
428 IWL_DEBUG_TEMP(mvm, "Enable dynamic SMPS\n");
429 tt->dynamic_smps = true;
430 ieee80211_iterate_active_interfaces_atomic(
431 mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
432 iwl_mvm_tt_smps_iterator, mvm);
eytan lifshitzdafe6c42013-06-18 14:28:56 +0300433 throttle_enable = true;
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300434 } else if (tt->dynamic_smps &&
435 temperature <= params->dynamic_smps_exit) {
436 IWL_DEBUG_TEMP(mvm, "Disable dynamic SMPS\n");
437 tt->dynamic_smps = false;
438 ieee80211_iterate_active_interfaces_atomic(
439 mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
440 iwl_mvm_tt_smps_iterator, mvm);
441 }
442 }
443
444 if (params->support_tx_protection) {
eytan lifshitzdafe6c42013-06-18 14:28:56 +0300445 if (temperature >= params->tx_protection_entry) {
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300446 iwl_mvm_tt_tx_protection(mvm, true);
eytan lifshitzdafe6c42013-06-18 14:28:56 +0300447 throttle_enable = true;
448 } else if (temperature <= params->tx_protection_exit) {
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300449 iwl_mvm_tt_tx_protection(mvm, false);
eytan lifshitzdafe6c42013-06-18 14:28:56 +0300450 }
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300451 }
452
453 if (params->support_tx_backoff) {
Eytan Lifshitz1b8ebbd2014-04-01 16:44:21 +0300454 tx_backoff = tt->min_backoff;
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300455 for (i = 0; i < TT_TX_BACKOFF_SIZE; i++) {
456 if (temperature < params->tx_backoff[i].temperature)
457 break;
Eytan Lifshitz1b8ebbd2014-04-01 16:44:21 +0300458 tx_backoff = max(tt->min_backoff,
459 params->tx_backoff[i].backoff);
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300460 }
Eytan Lifshitz1b8ebbd2014-04-01 16:44:21 +0300461 if (tx_backoff != tt->min_backoff)
eytan lifshitzdafe6c42013-06-18 14:28:56 +0300462 throttle_enable = true;
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300463 if (tt->tx_backoff != tx_backoff)
464 iwl_mvm_tt_tx_backoff(mvm, tx_backoff);
465 }
eytan lifshitzdafe6c42013-06-18 14:28:56 +0300466
467 if (!tt->throttle && throttle_enable) {
468 IWL_WARN(mvm,
469 "Due to high temperature thermal throttling initiated\n");
470 tt->throttle = true;
Eytan Lifshitz19a04bd2014-04-02 21:37:57 +0300471 } else if (tt->throttle && !tt->dynamic_smps &&
472 tt->tx_backoff == tt->min_backoff &&
eytan lifshitzdafe6c42013-06-18 14:28:56 +0300473 temperature <= params->tx_protection_exit) {
474 IWL_WARN(mvm,
475 "Temperature is back to normal thermal throttling stopped\n");
476 tt->throttle = false;
477 }
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300478}
479
Chaya Rachel Ivgi34446822015-04-19 12:26:39 +0300480static const struct iwl_tt_params iwl_mvm_default_tt_params = {
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300481 .ct_kill_entry = 118,
482 .ct_kill_exit = 96,
483 .ct_kill_duration = 5,
484 .dynamic_smps_entry = 114,
485 .dynamic_smps_exit = 110,
486 .tx_protection_entry = 114,
487 .tx_protection_exit = 108,
488 .tx_backoff = {
489 {.temperature = 112, .backoff = 200},
490 {.temperature = 113, .backoff = 600},
491 {.temperature = 114, .backoff = 1200},
492 {.temperature = 115, .backoff = 2000},
493 {.temperature = 116, .backoff = 4000},
494 {.temperature = 117, .backoff = 10000},
495 },
496 .support_ct_kill = true,
497 .support_dynamic_smps = true,
498 .support_tx_protection = true,
499 .support_tx_backoff = true,
500};
501
Chaya Rachel Ivgib3589932016-02-14 14:03:10 +0200502/* budget in mWatt */
503static const u32 iwl_mvm_cdev_budgets[] = {
504 2000, /* cooling state 0 */
505 1800, /* cooling state 1 */
506 1600, /* cooling state 2 */
507 1400, /* cooling state 3 */
508 1200, /* cooling state 4 */
509 1000, /* cooling state 5 */
510 900, /* cooling state 6 */
511 800, /* cooling state 7 */
512 700, /* cooling state 8 */
513 650, /* cooling state 9 */
514 600, /* cooling state 10 */
515 550, /* cooling state 11 */
516 500, /* cooling state 12 */
517 450, /* cooling state 13 */
518 400, /* cooling state 14 */
519 350, /* cooling state 15 */
520 300, /* cooling state 16 */
521 250, /* cooling state 17 */
522 200, /* cooling state 18 */
523 150, /* cooling state 19 */
524};
525
526int iwl_mvm_ctdp_command(struct iwl_mvm *mvm, u32 op, u32 state)
Chaya Rachel Ivgi00f481b2016-02-24 12:19:22 +0200527{
528 struct iwl_mvm_ctdp_cmd cmd = {
529 .operation = cpu_to_le32(op),
Chaya Rachel Ivgib3589932016-02-14 14:03:10 +0200530 .budget = cpu_to_le32(iwl_mvm_cdev_budgets[state]),
Chaya Rachel Ivgi00f481b2016-02-24 12:19:22 +0200531 .window_size = 0,
532 };
533 int ret;
534 u32 status;
535
536 lockdep_assert_held(&mvm->mutex);
537
538 ret = iwl_mvm_send_cmd_pdu_status(mvm, WIDE_ID(PHY_OPS_GROUP,
539 CTDP_CONFIG_CMD),
540 sizeof(cmd), &cmd, &status);
541
542 if (ret) {
543 IWL_ERR(mvm, "cTDP command failed (err=%d)\n", ret);
544 return ret;
545 }
546
547 switch (op) {
548 case CTDP_CMD_OPERATION_START:
549#ifdef CONFIG_THERMAL
Chaya Rachel Ivgib3589932016-02-14 14:03:10 +0200550 mvm->cooling_dev.cur_state = state;
Chaya Rachel Ivgi00f481b2016-02-24 12:19:22 +0200551#endif /* CONFIG_THERMAL */
552 break;
553 case CTDP_CMD_OPERATION_REPORT:
554 IWL_DEBUG_TEMP(mvm, "cTDP avg energy in mWatt = %d\n", status);
555 /* when the function is called with CTDP_CMD_OPERATION_REPORT
556 * option the function should return the average budget value
557 * that is received from the FW.
558 * The budget can't be less or equal to 0, so it's possible
559 * to distinguish between error values and budgets.
560 */
561 return status;
562 case CTDP_CMD_OPERATION_STOP:
563 IWL_DEBUG_TEMP(mvm, "cTDP stopped successfully\n");
564 break;
565 }
566
567 return 0;
568}
569
Chaya Rachel Ivgic221daf2015-12-29 09:54:49 +0200570#ifdef CONFIG_THERMAL
571static int compare_temps(const void *a, const void *b)
572{
573 return ((s16)le16_to_cpu(*(__le16 *)a) -
574 (s16)le16_to_cpu(*(__le16 *)b));
575}
576
577int iwl_mvm_send_temp_report_ths_cmd(struct iwl_mvm *mvm)
578{
579 struct temp_report_ths_cmd cmd = {0};
580 int ret, i, j, idx = 0;
581
582 lockdep_assert_held(&mvm->mutex);
583
Emmanuel Grumbach91f66a32016-02-28 10:15:08 +0200584 if (!mvm->tz_device.tzone)
585 return -EINVAL;
586
Chaya Rachel Ivgic221daf2015-12-29 09:54:49 +0200587 /* The driver holds array of temperature trips that are unsorted
588 * and uncompressed, the FW should get it compressed and sorted
589 */
590
591 /* compress temp_trips to cmd array, remove uninitialized values*/
Emmanuel Grumbach91f66a32016-02-28 10:15:08 +0200592 for (i = 0; i < IWL_MAX_DTS_TRIPS; i++) {
Chaya Rachel Ivgic221daf2015-12-29 09:54:49 +0200593 if (mvm->tz_device.temp_trips[i] != S16_MIN) {
594 cmd.thresholds[idx++] =
595 cpu_to_le16(mvm->tz_device.temp_trips[i]);
596 }
Emmanuel Grumbach91f66a32016-02-28 10:15:08 +0200597 }
Chaya Rachel Ivgic221daf2015-12-29 09:54:49 +0200598 cmd.num_temps = cpu_to_le32(idx);
599
600 if (!idx)
601 goto send;
602
603 /*sort cmd array*/
604 sort(cmd.thresholds, idx, sizeof(s16), compare_temps, NULL);
605
606 /* we should save the indexes of trips because we sort
607 * and compress the orginal array
608 */
609 for (i = 0; i < idx; i++) {
610 for (j = 0; j < IWL_MAX_DTS_TRIPS; j++) {
611 if (le16_to_cpu(cmd.thresholds[i]) ==
612 mvm->tz_device.temp_trips[j])
613 mvm->tz_device.fw_trips_index[i] = j;
614 }
615 }
616
617send:
618 ret = iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(PHY_OPS_GROUP,
619 TEMP_REPORTING_THRESHOLDS_CMD),
620 0, sizeof(cmd), &cmd);
621 if (ret)
622 IWL_ERR(mvm, "TEMP_REPORT_THS_CMD command failed (err=%d)\n",
623 ret);
624
625 return ret;
626}
627
628static int iwl_mvm_tzone_get_temp(struct thermal_zone_device *device,
629 int *temperature)
630{
631 struct iwl_mvm *mvm = (struct iwl_mvm *)device->devdata;
632 int ret;
633 int temp;
634
635 mutex_lock(&mvm->mutex);
636
637 if (!mvm->ucode_loaded || !(mvm->cur_ucode == IWL_UCODE_REGULAR)) {
638 ret = -EIO;
639 goto out;
640 }
641
642 ret = iwl_mvm_get_temp(mvm, &temp);
643 if (ret)
644 goto out;
645
646 *temperature = temp * 1000;
647
648out:
649 mutex_unlock(&mvm->mutex);
650 return ret;
651}
652
653static int iwl_mvm_tzone_get_trip_temp(struct thermal_zone_device *device,
654 int trip, int *temp)
655{
656 struct iwl_mvm *mvm = (struct iwl_mvm *)device->devdata;
657
658 if (trip < 0 || trip >= IWL_MAX_DTS_TRIPS)
659 return -EINVAL;
660
661 *temp = mvm->tz_device.temp_trips[trip] * 1000;
662
663 return 0;
664}
665
666static int iwl_mvm_tzone_get_trip_type(struct thermal_zone_device *device,
667 int trip, enum thermal_trip_type *type)
668{
669 if (trip < 0 || trip >= IWL_MAX_DTS_TRIPS)
670 return -EINVAL;
671
672 *type = THERMAL_TRIP_PASSIVE;
673
674 return 0;
675}
676
677static int iwl_mvm_tzone_set_trip_temp(struct thermal_zone_device *device,
678 int trip, int temp)
679{
680 struct iwl_mvm *mvm = (struct iwl_mvm *)device->devdata;
681 struct iwl_mvm_thermal_device *tzone;
682 int i, ret;
683 s16 temperature;
684
685 mutex_lock(&mvm->mutex);
686
687 if (!mvm->ucode_loaded || !(mvm->cur_ucode == IWL_UCODE_REGULAR)) {
688 ret = -EIO;
689 goto out;
690 }
691
692 if (trip < 0 || trip >= IWL_MAX_DTS_TRIPS) {
693 ret = -EINVAL;
694 goto out;
695 }
696
697 if ((temp / 1000) > S16_MAX) {
698 ret = -EINVAL;
699 goto out;
700 }
701
702 temperature = (s16)(temp / 1000);
703 tzone = &mvm->tz_device;
704
705 if (!tzone) {
706 ret = -EIO;
707 goto out;
708 }
709
710 /* no updates*/
711 if (tzone->temp_trips[trip] == temperature) {
712 ret = 0;
713 goto out;
714 }
715
716 /* already existing temperature */
717 for (i = 0; i < IWL_MAX_DTS_TRIPS; i++) {
718 if (tzone->temp_trips[i] == temperature) {
719 ret = -EINVAL;
720 goto out;
721 }
722 }
723
724 tzone->temp_trips[trip] = temperature;
725
726 ret = iwl_mvm_send_temp_report_ths_cmd(mvm);
727out:
728 mutex_unlock(&mvm->mutex);
729 return ret;
730}
731
732static struct thermal_zone_device_ops tzone_ops = {
733 .get_temp = iwl_mvm_tzone_get_temp,
734 .get_trip_temp = iwl_mvm_tzone_get_trip_temp,
735 .get_trip_type = iwl_mvm_tzone_get_trip_type,
736 .set_trip_temp = iwl_mvm_tzone_set_trip_temp,
737};
738
739/* make all trips writable */
740#define IWL_WRITABLE_TRIPS_MSK (BIT(IWL_MAX_DTS_TRIPS) - 1)
741
742static void iwl_mvm_thermal_zone_register(struct iwl_mvm *mvm)
743{
744 int i;
745 char name[] = "iwlwifi";
746
747 if (!iwl_mvm_is_tt_in_fw(mvm)) {
748 mvm->tz_device.tzone = NULL;
749
750 return;
751 }
752
753 BUILD_BUG_ON(ARRAY_SIZE(name) >= THERMAL_NAME_LENGTH);
754
755 mvm->tz_device.tzone = thermal_zone_device_register(name,
756 IWL_MAX_DTS_TRIPS,
757 IWL_WRITABLE_TRIPS_MSK,
758 mvm, &tzone_ops,
759 NULL, 0, 0);
760 if (IS_ERR(mvm->tz_device.tzone)) {
761 IWL_DEBUG_TEMP(mvm,
762 "Failed to register to thermal zone (err = %ld)\n",
763 PTR_ERR(mvm->tz_device.tzone));
Emmanuel Grumbach91f66a32016-02-28 10:15:08 +0200764 mvm->tz_device.tzone = NULL;
Chaya Rachel Ivgic221daf2015-12-29 09:54:49 +0200765 return;
766 }
767
768 /* 0 is a valid temperature,
769 * so initialize the array with S16_MIN which invalid temperature
770 */
771 for (i = 0 ; i < IWL_MAX_DTS_TRIPS; i++)
772 mvm->tz_device.temp_trips[i] = S16_MIN;
773}
774
Chaya Rachel Ivgi5c89e7b2016-01-05 10:34:47 +0200775static int iwl_mvm_tcool_get_max_state(struct thermal_cooling_device *cdev,
776 unsigned long *state)
777{
778 *state = ARRAY_SIZE(iwl_mvm_cdev_budgets) - 1;
779
780 return 0;
781}
782
783static int iwl_mvm_tcool_get_cur_state(struct thermal_cooling_device *cdev,
784 unsigned long *state)
785{
786 struct iwl_mvm *mvm = (struct iwl_mvm *)(cdev->devdata);
787
Chaya Rachel Ivgi5c89e7b2016-01-05 10:34:47 +0200788 *state = mvm->cooling_dev.cur_state;
Chaya Rachel Ivgib3589932016-02-14 14:03:10 +0200789
Chaya Rachel Ivgi5c89e7b2016-01-05 10:34:47 +0200790 return 0;
791}
792
793static int iwl_mvm_tcool_set_cur_state(struct thermal_cooling_device *cdev,
794 unsigned long new_state)
795{
796 struct iwl_mvm *mvm = (struct iwl_mvm *)(cdev->devdata);
797 int ret;
798
799 if (!mvm->ucode_loaded || !(mvm->cur_ucode == IWL_UCODE_REGULAR))
800 return -EIO;
801
Chaya Rachel Ivgi5c89e7b2016-01-05 10:34:47 +0200802 mutex_lock(&mvm->mutex);
803
804 if (new_state >= ARRAY_SIZE(iwl_mvm_cdev_budgets)) {
805 ret = -EINVAL;
806 goto unlock;
807 }
808
809 ret = iwl_mvm_ctdp_command(mvm, CTDP_CMD_OPERATION_START,
Chaya Rachel Ivgib3589932016-02-14 14:03:10 +0200810 new_state);
Chaya Rachel Ivgi5c89e7b2016-01-05 10:34:47 +0200811
812unlock:
813 mutex_unlock(&mvm->mutex);
814 return ret;
815}
816
817static struct thermal_cooling_device_ops tcooling_ops = {
818 .get_max_state = iwl_mvm_tcool_get_max_state,
819 .get_cur_state = iwl_mvm_tcool_get_cur_state,
820 .set_cur_state = iwl_mvm_tcool_set_cur_state,
821};
822
Emmanuel Grumbach91f66a32016-02-28 10:15:08 +0200823static void iwl_mvm_cooling_device_register(struct iwl_mvm *mvm)
Chaya Rachel Ivgi5c89e7b2016-01-05 10:34:47 +0200824{
825 char name[] = "iwlwifi";
826
Emmanuel Grumbach91f66a32016-02-28 10:15:08 +0200827 if (!iwl_mvm_is_ctdp_supported(mvm))
828 return;
Chaya Rachel Ivgi5c89e7b2016-01-05 10:34:47 +0200829
830 BUILD_BUG_ON(ARRAY_SIZE(name) >= THERMAL_NAME_LENGTH);
831
832 mvm->cooling_dev.cdev =
833 thermal_cooling_device_register(name,
834 mvm,
835 &tcooling_ops);
836
837 if (IS_ERR(mvm->cooling_dev.cdev)) {
838 IWL_DEBUG_TEMP(mvm,
839 "Failed to register to cooling device (err = %ld)\n",
840 PTR_ERR(mvm->cooling_dev.cdev));
Emmanuel Grumbach91f66a32016-02-28 10:15:08 +0200841 mvm->cooling_dev.cdev = NULL;
842 return;
Chaya Rachel Ivgi5c89e7b2016-01-05 10:34:47 +0200843 }
Chaya Rachel Ivgi5c89e7b2016-01-05 10:34:47 +0200844}
845
Chaya Rachel Ivgic221daf2015-12-29 09:54:49 +0200846static void iwl_mvm_thermal_zone_unregister(struct iwl_mvm *mvm)
847{
Emmanuel Grumbach91f66a32016-02-28 10:15:08 +0200848 if (!iwl_mvm_is_tt_in_fw(mvm) || !mvm->tz_device.tzone)
Chaya Rachel Ivgic221daf2015-12-29 09:54:49 +0200849 return;
850
Emmanuel Grumbach91f66a32016-02-28 10:15:08 +0200851 IWL_DEBUG_TEMP(mvm, "Thermal zone device unregister\n");
852 thermal_zone_device_unregister(mvm->tz_device.tzone);
853 mvm->tz_device.tzone = NULL;
Chaya Rachel Ivgic221daf2015-12-29 09:54:49 +0200854}
Chaya Rachel Ivgi5c89e7b2016-01-05 10:34:47 +0200855
856static void iwl_mvm_cooling_device_unregister(struct iwl_mvm *mvm)
857{
Emmanuel Grumbach91f66a32016-02-28 10:15:08 +0200858 if (!iwl_mvm_is_ctdp_supported(mvm) || !mvm->cooling_dev.cdev)
Chaya Rachel Ivgi5c89e7b2016-01-05 10:34:47 +0200859 return;
860
Emmanuel Grumbach91f66a32016-02-28 10:15:08 +0200861 IWL_DEBUG_TEMP(mvm, "Cooling device unregister\n");
862 thermal_cooling_device_unregister(mvm->cooling_dev.cdev);
863 mvm->cooling_dev.cdev = NULL;
Chaya Rachel Ivgi5c89e7b2016-01-05 10:34:47 +0200864}
Chaya Rachel Ivgic221daf2015-12-29 09:54:49 +0200865#endif /* CONFIG_THERMAL */
866
867void iwl_mvm_thermal_initialize(struct iwl_mvm *mvm, u32 min_backoff)
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300868{
869 struct iwl_mvm_tt_mgmt *tt = &mvm->thermal_throttle;
870
871 IWL_DEBUG_TEMP(mvm, "Initialize Thermal Throttling\n");
Eytan Lifshitz6be497f2013-07-24 14:49:18 +0300872
Chaya Rachel Ivgi34446822015-04-19 12:26:39 +0300873 if (mvm->cfg->thermal_params)
874 tt->params = *mvm->cfg->thermal_params;
Eytan Lifshitz6be497f2013-07-24 14:49:18 +0300875 else
Chaya Rachel Ivgi34446822015-04-19 12:26:39 +0300876 tt->params = iwl_mvm_default_tt_params;
Eytan Lifshitz6be497f2013-07-24 14:49:18 +0300877
eytan lifshitzdafe6c42013-06-18 14:28:56 +0300878 tt->throttle = false;
Luciano Coelho19789ab2014-12-15 14:15:15 +0200879 tt->dynamic_smps = false;
Ido Yariv0c0e2c72014-01-16 21:12:02 -0500880 tt->min_backoff = min_backoff;
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300881 INIT_DELAYED_WORK(&tt->ct_kill_exit, check_exit_ctkill);
Chaya Rachel Ivgic221daf2015-12-29 09:54:49 +0200882
883#ifdef CONFIG_THERMAL
Chaya Rachel Ivgi5c89e7b2016-01-05 10:34:47 +0200884 iwl_mvm_cooling_device_register(mvm);
Chaya Rachel Ivgic221daf2015-12-29 09:54:49 +0200885 iwl_mvm_thermal_zone_register(mvm);
886#endif
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300887}
888
Chaya Rachel Ivgic221daf2015-12-29 09:54:49 +0200889void iwl_mvm_thermal_exit(struct iwl_mvm *mvm)
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300890{
891 cancel_delayed_work_sync(&mvm->thermal_throttle.ct_kill_exit);
892 IWL_DEBUG_TEMP(mvm, "Exit Thermal Throttling\n");
Chaya Rachel Ivgic221daf2015-12-29 09:54:49 +0200893
894#ifdef CONFIG_THERMAL
Chaya Rachel Ivgi5c89e7b2016-01-05 10:34:47 +0200895 iwl_mvm_cooling_device_unregister(mvm);
Chaya Rachel Ivgic221daf2015-12-29 09:54:49 +0200896 iwl_mvm_thermal_zone_unregister(mvm);
897#endif
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300898}