Lines Matching refs:wil

13 static void wil_pm_wake_connected_net_queues(struct wil6210_priv *wil)  in wil_pm_wake_connected_net_queues()  argument
17 mutex_lock(&wil->vif_mutex); in wil_pm_wake_connected_net_queues()
18 for (i = 0; i < GET_MAX_VIFS(wil); i++) { in wil_pm_wake_connected_net_queues()
19 struct wil6210_vif *vif = wil->vifs[i]; in wil_pm_wake_connected_net_queues()
22 wil_update_net_queues_bh(wil, vif, NULL, false); in wil_pm_wake_connected_net_queues()
24 mutex_unlock(&wil->vif_mutex); in wil_pm_wake_connected_net_queues()
27 static void wil_pm_stop_all_net_queues(struct wil6210_priv *wil) in wil_pm_stop_all_net_queues() argument
31 mutex_lock(&wil->vif_mutex); in wil_pm_stop_all_net_queues()
32 for (i = 0; i < GET_MAX_VIFS(wil); i++) { in wil_pm_stop_all_net_queues()
33 struct wil6210_vif *vif = wil->vifs[i]; in wil_pm_stop_all_net_queues()
36 wil_update_net_queues_bh(wil, vif, NULL, true); in wil_pm_stop_all_net_queues()
38 mutex_unlock(&wil->vif_mutex); in wil_pm_stop_all_net_queues()
42 wil_can_suspend_vif(struct wil6210_priv *wil, struct wil6210_vif *vif, in wil_can_suspend_vif() argument
49 wil_dbg_pm(wil, "Sniffer\n"); in wil_can_suspend_vif()
56 wil_dbg_pm(wil, "Delay suspend when connecting\n"); in wil_can_suspend_vif()
60 wil_dbg_pm(wil, "STA-like interface\n"); in wil_can_suspend_vif()
66 wil_dbg_pm(wil, "AP-like interface\n"); in wil_can_suspend_vif()
73 int wil_can_suspend(struct wil6210_priv *wil, bool is_runtime) in wil_can_suspend() argument
77 wil->fw_capabilities); in wil_can_suspend()
80 wil_dbg_pm(wil, "can_suspend: %s\n", is_runtime ? "runtime" : "system"); in wil_can_suspend()
83 wil_dbg_pm(wil, "Deny any suspend - %s mode\n", in wil_can_suspend()
88 if (is_runtime && !wil->platform_ops.suspend) { in wil_can_suspend()
93 mutex_lock(&wil->vif_mutex); in wil_can_suspend()
94 active_ifaces = wil_has_active_ifaces(wil, true, false); in wil_can_suspend()
95 mutex_unlock(&wil->vif_mutex); in wil_can_suspend()
99 wil_dbg_pm(wil, "Interface is down\n"); in wil_can_suspend()
102 if (test_bit(wil_status_resetting, wil->status)) { in wil_can_suspend()
103 wil_dbg_pm(wil, "Delay suspend when resetting\n"); in wil_can_suspend()
107 if (wil->recovery_state != fw_recovery_idle) { in wil_can_suspend()
108 wil_dbg_pm(wil, "Delay suspend during recovery\n"); in wil_can_suspend()
114 mutex_lock(&wil->vif_mutex); in wil_can_suspend()
115 for (i = 0; i < GET_MAX_VIFS(wil); i++) { in wil_can_suspend()
116 struct wil6210_vif *vif = wil->vifs[i]; in wil_can_suspend()
120 if (!wil_can_suspend_vif(wil, vif, is_runtime)) { in wil_can_suspend()
122 mutex_unlock(&wil->vif_mutex); in wil_can_suspend()
126 mutex_unlock(&wil->vif_mutex); in wil_can_suspend()
129 wil_dbg_pm(wil, "can_suspend: %s => %s (%d)\n", in wil_can_suspend()
133 wil->suspend_stats.rejected_by_host++; in wil_can_suspend()
138 static int wil_resume_keep_radio_on(struct wil6210_priv *wil) in wil_resume_keep_radio_on() argument
145 set_bit(wil_status_resuming, wil->status); in wil_resume_keep_radio_on()
146 clear_bit(wil_status_suspended, wil->status); in wil_resume_keep_radio_on()
147 wil_c(wil, RGF_USER_CLKS_CTL_0, BIT_USER_CLKS_RST_PWGD); in wil_resume_keep_radio_on()
148 wil_unmask_irq(wil); in wil_resume_keep_radio_on()
150 wil6210_bus_request(wil, wil->bus_request_kbps_pre_suspend); in wil_resume_keep_radio_on()
153 rc = wmi_resume(wil); in wil_resume_keep_radio_on()
155 wil_err(wil, "device failed to resume (%d)\n", rc); in wil_resume_keep_radio_on()
158 rc = wil_down(wil); in wil_resume_keep_radio_on()
160 wil_err(wil, "wil_down failed (%d)\n", rc); in wil_resume_keep_radio_on()
163 rc = wil_up(wil); in wil_resume_keep_radio_on()
165 wil_err(wil, "wil_up failed (%d)\n", rc); in wil_resume_keep_radio_on()
171 wil_pm_wake_connected_net_queues(wil); in wil_resume_keep_radio_on()
175 set_bit(wil_status_suspended, wil->status); in wil_resume_keep_radio_on()
179 static int wil_suspend_keep_radio_on(struct wil6210_priv *wil) in wil_suspend_keep_radio_on() argument
184 wil_dbg_pm(wil, "suspend keep radio on\n"); in wil_suspend_keep_radio_on()
187 rc = down_write_trylock(&wil->mem_lock); in wil_suspend_keep_radio_on()
189 wil_err(wil, in wil_suspend_keep_radio_on()
192 wil->suspend_stats.rejected_by_host++; in wil_suspend_keep_radio_on()
196 set_bit(wil_status_suspending, wil->status); in wil_suspend_keep_radio_on()
197 up_write(&wil->mem_lock); in wil_suspend_keep_radio_on()
199 wil_pm_stop_all_net_queues(wil); in wil_suspend_keep_radio_on()
201 if (!wil_is_tx_idle(wil)) { in wil_suspend_keep_radio_on()
202 wil_dbg_pm(wil, "Pending TX data, reject suspend\n"); in wil_suspend_keep_radio_on()
203 wil->suspend_stats.rejected_by_host++; in wil_suspend_keep_radio_on()
207 if (!wil->txrx_ops.is_rx_idle(wil)) { in wil_suspend_keep_radio_on()
208 wil_dbg_pm(wil, "Pending RX data, reject suspend\n"); in wil_suspend_keep_radio_on()
209 wil->suspend_stats.rejected_by_host++; in wil_suspend_keep_radio_on()
213 if (!wil_is_wmi_idle(wil)) { in wil_suspend_keep_radio_on()
214 wil_dbg_pm(wil, "Pending WMI events, reject suspend\n"); in wil_suspend_keep_radio_on()
215 wil->suspend_stats.rejected_by_host++; in wil_suspend_keep_radio_on()
220 rc = wmi_suspend(wil); in wil_suspend_keep_radio_on()
222 wil_dbg_pm(wil, "wmi_suspend failed, reject suspend (%d)\n", in wil_suspend_keep_radio_on()
229 if (test_bit(wil_status_napi_en, wil->status)) { in wil_suspend_keep_radio_on()
230 while (!wil->txrx_ops.is_rx_idle(wil)) { in wil_suspend_keep_radio_on()
232 if (wil->txrx_ops.is_rx_idle(wil)) in wil_suspend_keep_radio_on()
234 wil_err(wil, in wil_suspend_keep_radio_on()
236 wil->suspend_stats.r_on.failed_suspends++; in wil_suspend_keep_radio_on()
239 wil_dbg_ratelimited(wil, "rx vring is not empty -> NAPI\n"); in wil_suspend_keep_radio_on()
240 napi_synchronize(&wil->napi_rx); in wil_suspend_keep_radio_on()
250 if (!wil_is_wmi_idle(wil)) { in wil_suspend_keep_radio_on()
251 wil_err(wil, "suspend failed due to pending WMI events\n"); in wil_suspend_keep_radio_on()
252 wil->suspend_stats.r_on.failed_suspends++; in wil_suspend_keep_radio_on()
256 wil_mask_irq(wil); in wil_suspend_keep_radio_on()
259 wil_s(wil, RGF_USER_CLKS_CTL_0, BIT_USER_CLKS_RST_PWGD); in wil_suspend_keep_radio_on()
261 if (wil->platform_ops.suspend) { in wil_suspend_keep_radio_on()
262 rc = wil->platform_ops.suspend(wil->platform_handle, true); in wil_suspend_keep_radio_on()
264 wil_err(wil, "platform device failed to suspend (%d)\n", in wil_suspend_keep_radio_on()
266 wil->suspend_stats.r_on.failed_suspends++; in wil_suspend_keep_radio_on()
267 wil_c(wil, RGF_USER_CLKS_CTL_0, BIT_USER_CLKS_RST_PWGD); in wil_suspend_keep_radio_on()
268 wil_unmask_irq(wil); in wil_suspend_keep_radio_on()
274 wil->bus_request_kbps_pre_suspend = wil->bus_request_kbps; in wil_suspend_keep_radio_on()
275 wil6210_bus_request(wil, 0); in wil_suspend_keep_radio_on()
277 set_bit(wil_status_suspended, wil->status); in wil_suspend_keep_radio_on()
278 clear_bit(wil_status_suspending, wil->status); in wil_suspend_keep_radio_on()
283 set_bit(wil_status_resuming, wil->status); in wil_suspend_keep_radio_on()
284 clear_bit(wil_status_suspending, wil->status); in wil_suspend_keep_radio_on()
285 rc = wmi_resume(wil); in wil_suspend_keep_radio_on()
289 wil_pm_wake_connected_net_queues(wil); in wil_suspend_keep_radio_on()
294 clear_bit(wil_status_suspending, wil->status); in wil_suspend_keep_radio_on()
295 wil_pm_wake_connected_net_queues(wil); in wil_suspend_keep_radio_on()
299 static int wil_suspend_radio_off(struct wil6210_priv *wil) in wil_suspend_radio_off() argument
304 wil_dbg_pm(wil, "suspend radio off\n"); in wil_suspend_radio_off()
306 rc = down_write_trylock(&wil->mem_lock); in wil_suspend_radio_off()
308 wil_err(wil, in wil_suspend_radio_off()
311 wil->suspend_stats.rejected_by_host++; in wil_suspend_radio_off()
315 set_bit(wil_status_suspending, wil->status); in wil_suspend_radio_off()
316 up_write(&wil->mem_lock); in wil_suspend_radio_off()
319 mutex_lock(&wil->vif_mutex); in wil_suspend_radio_off()
320 active_ifaces = wil_has_active_ifaces(wil, true, false); in wil_suspend_radio_off()
321 mutex_unlock(&wil->vif_mutex); in wil_suspend_radio_off()
324 rc = wil_down(wil); in wil_suspend_radio_off()
326 wil_err(wil, "wil_down : %d\n", rc); in wil_suspend_radio_off()
327 wil->suspend_stats.r_off.failed_suspends++; in wil_suspend_radio_off()
333 wil_dbg_pm(wil, "Disabling PCIe IRQ before suspending\n"); in wil_suspend_radio_off()
334 wil_disable_irq(wil); in wil_suspend_radio_off()
336 if (wil->platform_ops.suspend) { in wil_suspend_radio_off()
337 rc = wil->platform_ops.suspend(wil->platform_handle, false); in wil_suspend_radio_off()
339 wil_enable_irq(wil); in wil_suspend_radio_off()
340 wil->suspend_stats.r_off.failed_suspends++; in wil_suspend_radio_off()
345 set_bit(wil_status_suspended, wil->status); in wil_suspend_radio_off()
348 clear_bit(wil_status_suspending, wil->status); in wil_suspend_radio_off()
349 wil_dbg_pm(wil, "suspend radio off: %d\n", rc); in wil_suspend_radio_off()
354 static int wil_resume_radio_off(struct wil6210_priv *wil) in wil_resume_radio_off() argument
359 wil_dbg_pm(wil, "Enabling PCIe IRQ\n"); in wil_resume_radio_off()
360 wil_enable_irq(wil); in wil_resume_radio_off()
366 mutex_lock(&wil->vif_mutex); in wil_resume_radio_off()
367 active_ifaces = wil_has_active_ifaces(wil, true, false); in wil_resume_radio_off()
368 mutex_unlock(&wil->vif_mutex); in wil_resume_radio_off()
370 rc = wil_up(wil); in wil_resume_radio_off()
372 clear_bit(wil_status_suspended, wil->status); in wil_resume_radio_off()
377 int wil_suspend(struct wil6210_priv *wil, bool is_runtime, bool keep_radio_on) in wil_suspend() argument
381 wil_dbg_pm(wil, "suspend: %s\n", is_runtime ? "runtime" : "system"); in wil_suspend()
383 if (test_bit(wil_status_suspended, wil->status)) { in wil_suspend()
384 wil_dbg_pm(wil, "trying to suspend while suspended\n"); in wil_suspend()
389 rc = wil_suspend_radio_off(wil); in wil_suspend()
391 rc = wil_suspend_keep_radio_on(wil); in wil_suspend()
393 wil_dbg_pm(wil, "suspend: %s => %d\n", in wil_suspend()
399 int wil_resume(struct wil6210_priv *wil, bool is_runtime, bool keep_radio_on) in wil_resume() argument
403 wil_dbg_pm(wil, "resume: %s\n", is_runtime ? "runtime" : "system"); in wil_resume()
405 if (wil->platform_ops.resume) { in wil_resume()
406 rc = wil->platform_ops.resume(wil->platform_handle, in wil_resume()
409 wil_err(wil, "platform_ops.resume : %d\n", rc); in wil_resume()
415 rc = wil_resume_keep_radio_on(wil); in wil_resume()
417 rc = wil_resume_radio_off(wil); in wil_resume()
420 wil_dbg_pm(wil, "resume: %s => %d\n", is_runtime ? "runtime" : "system", in wil_resume()
425 void wil_pm_runtime_allow(struct wil6210_priv *wil) in wil_pm_runtime_allow() argument
427 struct device *dev = wil_to_dev(wil); in wil_pm_runtime_allow()
435 void wil_pm_runtime_forbid(struct wil6210_priv *wil) in wil_pm_runtime_forbid() argument
437 struct device *dev = wil_to_dev(wil); in wil_pm_runtime_forbid()
443 int wil_pm_runtime_get(struct wil6210_priv *wil) in wil_pm_runtime_get() argument
446 struct device *dev = wil_to_dev(wil); in wil_pm_runtime_get()
450 wil_err(wil, "pm_runtime_get_sync() failed, rc = %d\n", rc); in wil_pm_runtime_get()
458 void wil_pm_runtime_put(struct wil6210_priv *wil) in wil_pm_runtime_put() argument
460 struct device *dev = wil_to_dev(wil); in wil_pm_runtime_put()