.. | .. |
---|
| 1 | +// SPDX-License-Identifier: ISC |
---|
1 | 2 | /* |
---|
2 | 3 | * 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. |
---|
16 | 5 | */ |
---|
17 | 6 | |
---|
18 | 7 | #include "wil6210.h" |
---|
.. | .. |
---|
26 | 15 | int i; |
---|
27 | 16 | |
---|
28 | 17 | mutex_lock(&wil->vif_mutex); |
---|
29 | | - for (i = 0; i < wil->max_vifs; i++) { |
---|
| 18 | + for (i = 0; i < GET_MAX_VIFS(wil); i++) { |
---|
30 | 19 | struct wil6210_vif *vif = wil->vifs[i]; |
---|
31 | 20 | |
---|
32 | 21 | if (vif && test_bit(wil_vif_fwconnected, vif->status)) |
---|
.. | .. |
---|
40 | 29 | int i; |
---|
41 | 30 | |
---|
42 | 31 | mutex_lock(&wil->vif_mutex); |
---|
43 | | - for (i = 0; i < wil->max_vifs; i++) { |
---|
| 32 | + for (i = 0; i < GET_MAX_VIFS(wil); i++) { |
---|
44 | 33 | struct wil6210_vif *vif = wil->vifs[i]; |
---|
45 | 34 | |
---|
46 | 35 | if (vif) |
---|
.. | .. |
---|
123 | 112 | |
---|
124 | 113 | /* interface is running */ |
---|
125 | 114 | mutex_lock(&wil->vif_mutex); |
---|
126 | | - for (i = 0; i < wil->max_vifs; i++) { |
---|
| 115 | + for (i = 0; i < GET_MAX_VIFS(wil); i++) { |
---|
127 | 116 | struct wil6210_vif *vif = wil->vifs[i]; |
---|
128 | 117 | |
---|
129 | 118 | if (!vif) |
---|
.. | .. |
---|
190 | 179 | static int wil_suspend_keep_radio_on(struct wil6210_priv *wil) |
---|
191 | 180 | { |
---|
192 | 181 | int rc = 0; |
---|
193 | | - unsigned long start, data_comp_to; |
---|
| 182 | + unsigned long data_comp_to; |
---|
194 | 183 | |
---|
195 | 184 | wil_dbg_pm(wil, "suspend keep radio on\n"); |
---|
196 | 185 | |
---|
197 | 186 | /* 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); |
---|
203 | 192 | wil->suspend_stats.rejected_by_host++; |
---|
204 | 193 | return -EBUSY; |
---|
205 | 194 | } |
---|
| 195 | + |
---|
| 196 | + set_bit(wil_status_suspending, wil->status); |
---|
| 197 | + up_write(&wil->mem_lock); |
---|
| 198 | + |
---|
206 | 199 | wil_pm_stop_all_net_queues(wil); |
---|
207 | 200 | |
---|
208 | 201 | if (!wil_is_tx_idle(wil)) { |
---|
.. | .. |
---|
232 | 225 | } |
---|
233 | 226 | |
---|
234 | 227 | /* Wait for completion of the pending RX packets */ |
---|
235 | | - start = jiffies; |
---|
236 | 228 | data_comp_to = jiffies + msecs_to_jiffies(WIL_DATA_COMPLETION_TO_MS); |
---|
237 | 229 | if (test_bit(wil_status_napi_en, wil->status)) { |
---|
238 | 230 | while (!wil->txrx_ops.is_rx_idle(wil)) { |
---|
.. | .. |
---|
311 | 303 | |
---|
312 | 304 | wil_dbg_pm(wil, "suspend radio off\n"); |
---|
313 | 305 | |
---|
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); |
---|
319 | 311 | wil->suspend_stats.rejected_by_host++; |
---|
320 | 312 | return -EBUSY; |
---|
321 | 313 | } |
---|
322 | 314 | |
---|
| 315 | + set_bit(wil_status_suspending, wil->status); |
---|
| 316 | + up_write(&wil->mem_lock); |
---|
| 317 | + |
---|
323 | 318 | /* if netif up, hardware is alive, shut it down */ |
---|
324 | 319 | mutex_lock(&wil->vif_mutex); |
---|
325 | 320 | active_ifaces = wil_has_active_ifaces(wil, true, false); |
---|