hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/net/wireless/ath/wil6210/pm.c
....@@ -1,18 +1,7 @@
1
+// SPDX-License-Identifier: ISC
12 /*
23 * Copyright (c) 2014,2017 Qualcomm Atheros, Inc.
3
- * Copyright (c) 2018, The Linux Foundation. All rights reserved.
4
- *
5
- * Permission to use, copy, modify, and/or distribute this software for any
6
- * purpose with or without fee is hereby granted, provided that the above
7
- * copyright notice and this permission notice appear in all copies.
8
- *
9
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
4
+ * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
165 */
176
187 #include "wil6210.h"
....@@ -26,7 +15,7 @@
2615 int i;
2716
2817 mutex_lock(&wil->vif_mutex);
29
- for (i = 0; i < wil->max_vifs; i++) {
18
+ for (i = 0; i < GET_MAX_VIFS(wil); i++) {
3019 struct wil6210_vif *vif = wil->vifs[i];
3120
3221 if (vif && test_bit(wil_vif_fwconnected, vif->status))
....@@ -40,7 +29,7 @@
4029 int i;
4130
4231 mutex_lock(&wil->vif_mutex);
43
- for (i = 0; i < wil->max_vifs; i++) {
32
+ for (i = 0; i < GET_MAX_VIFS(wil); i++) {
4433 struct wil6210_vif *vif = wil->vifs[i];
4534
4635 if (vif)
....@@ -123,7 +112,7 @@
123112
124113 /* interface is running */
125114 mutex_lock(&wil->vif_mutex);
126
- for (i = 0; i < wil->max_vifs; i++) {
115
+ for (i = 0; i < GET_MAX_VIFS(wil); i++) {
127116 struct wil6210_vif *vif = wil->vifs[i];
128117
129118 if (!vif)
....@@ -190,19 +179,23 @@
190179 static int wil_suspend_keep_radio_on(struct wil6210_priv *wil)
191180 {
192181 int rc = 0;
193
- unsigned long start, data_comp_to;
182
+ unsigned long data_comp_to;
194183
195184 wil_dbg_pm(wil, "suspend keep radio on\n");
196185
197186 /* Prevent handling of new tx and wmi commands */
198
- set_bit(wil_status_suspending, wil->status);
199
- if (test_bit(wil_status_collecting_dumps, wil->status)) {
200
- /* Device collects crash dump, cancel the suspend */
201
- wil_dbg_pm(wil, "reject suspend while collecting crash dump\n");
202
- clear_bit(wil_status_suspending, wil->status);
187
+ rc = down_write_trylock(&wil->mem_lock);
188
+ if (!rc) {
189
+ wil_err(wil,
190
+ "device is busy. down_write_trylock failed, returned (0x%x)\n",
191
+ rc);
203192 wil->suspend_stats.rejected_by_host++;
204193 return -EBUSY;
205194 }
195
+
196
+ set_bit(wil_status_suspending, wil->status);
197
+ up_write(&wil->mem_lock);
198
+
206199 wil_pm_stop_all_net_queues(wil);
207200
208201 if (!wil_is_tx_idle(wil)) {
....@@ -232,7 +225,6 @@
232225 }
233226
234227 /* Wait for completion of the pending RX packets */
235
- start = jiffies;
236228 data_comp_to = jiffies + msecs_to_jiffies(WIL_DATA_COMPLETION_TO_MS);
237229 if (test_bit(wil_status_napi_en, wil->status)) {
238230 while (!wil->txrx_ops.is_rx_idle(wil)) {
....@@ -311,15 +303,18 @@
311303
312304 wil_dbg_pm(wil, "suspend radio off\n");
313305
314
- set_bit(wil_status_suspending, wil->status);
315
- if (test_bit(wil_status_collecting_dumps, wil->status)) {
316
- /* Device collects crash dump, cancel the suspend */
317
- wil_dbg_pm(wil, "reject suspend while collecting crash dump\n");
318
- clear_bit(wil_status_suspending, wil->status);
306
+ rc = down_write_trylock(&wil->mem_lock);
307
+ if (!rc) {
308
+ wil_err(wil,
309
+ "device is busy. down_write_trylock failed, returned (0x%x)\n",
310
+ rc);
319311 wil->suspend_stats.rejected_by_host++;
320312 return -EBUSY;
321313 }
322314
315
+ set_bit(wil_status_suspending, wil->status);
316
+ up_write(&wil->mem_lock);
317
+
323318 /* if netif up, hardware is alive, shut it down */
324319 mutex_lock(&wil->vif_mutex);
325320 active_ifaces = wil_has_active_ifaces(wil, true, false);