static void mlx5e_close_rq(struct mlx5e_rq *rq) { clear_bit(MLX5E_RQ_STATE_POST_WQES_ENABLE, &rq->state); napi_synchronize(&rq->channel->napi); /* prevent mlx5e_post_rx_wqes */ mlx5e_modify_rq(rq, MLX5_RQC_STATE_RDY, MLX5_RQC_STATE_ERR); while (!mlx5_wq_ll_is_empty(&rq->wq)) msleep(20); /* avoid destroying rq before mlx5e_poll_rx_cq() is done with it */ napi_synchronize(&rq->channel->napi); mlx5e_disable_rq(rq); mlx5e_destroy_rq(rq); }
static void mlx5e_close_sq(struct mlx5e_sq *sq) { clear_bit(MLX5E_SQ_STATE_WAKE_TXQ_ENABLE, &sq->state); napi_synchronize(&sq->channel->napi); /* prevent netif_tx_wake_queue */ netif_tx_disable_queue(sq->txq); /* ensure hw is notified of all pending wqes */ if (mlx5e_sq_has_room_for(sq, 1)) mlx5e_send_nop(sq); mlx5e_modify_sq(sq, MLX5_SQC_STATE_RDY, MLX5_SQC_STATE_ERR); while (sq->cc != sq->pc) /* wait till sq is empty */ msleep(20); /* avoid destroying sq before mlx5e_poll_tx_cq() is done with it */ napi_synchronize(&sq->channel->napi); mlx5e_disable_sq(sq); mlx5e_destroy_sq(sq); }
static void ath10k_ahb_hif_stop(struct ath10k *ar) { struct ath10k_ahb *ar_ahb = ath10k_ahb_priv(ar); ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot ahb hif stop\n"); ath10k_ahb_irq_disable(ar); synchronize_irq(ar_ahb->irq); napi_synchronize(&ar->napi); napi_disable(&ar->napi); ath10k_pci_flush(ar); }
/* * We reset all the structures, and we reset the UMAC. * After calling this routine, you're expected to reload * the firmware. */ int wil_reset(struct wil6210_priv *wil) { int rc; WARN_ON(!mutex_is_locked(&wil->mutex)); cancel_work_sync(&wil->disconnect_worker); wil6210_disconnect(wil, NULL); wil->status = 0; /* prevent NAPI from being scheduled */ if (test_bit(wil_status_napi_en, &wil->status)) { napi_synchronize(&wil->napi_rx); } if (wil->scan_request) { wil_dbg_misc(wil, "Abort scan_request 0x%p\n", wil->scan_request); del_timer_sync(&wil->scan_timer); cfg80211_scan_done(wil->scan_request, true); wil->scan_request = NULL; } wil6210_disable_irq(wil); wmi_event_flush(wil); flush_workqueue(wil->wmi_wq_conn); flush_workqueue(wil->wmi_wq); /* TODO: put MAC in reset */ wil_target_reset(wil); wil_rx_fini(wil); /* init after reset */ wil->pending_connect_cid = -1; reinit_completion(&wil->wmi_ready); /* TODO: release MAC reset */ wil6210_enable_irq(wil); /* we just started MAC, wait for FW ready */ rc = wil_wait_for_fw_ready(wil); return rc; }
static int wil_suspend_keep_radio_on(struct wil6210_priv *wil) { int rc = 0; unsigned long data_comp_to; wil_dbg_pm(wil, "suspend keep radio on\n"); /* Prevent handling of new tx and wmi commands */ rc = down_write_trylock(&wil->mem_lock); if (!rc) { wil_err(wil, "device is busy. down_write_trylock failed, returned (0x%x)\n", rc); wil->suspend_stats.rejected_by_host++; return -EBUSY; } set_bit(wil_status_suspending, wil->status); up_write(&wil->mem_lock); wil_pm_stop_all_net_queues(wil); if (!wil_is_tx_idle(wil)) { wil_dbg_pm(wil, "Pending TX data, reject suspend\n"); wil->suspend_stats.rejected_by_host++; goto reject_suspend; } if (!wil->txrx_ops.is_rx_idle(wil)) { wil_dbg_pm(wil, "Pending RX data, reject suspend\n"); wil->suspend_stats.rejected_by_host++; goto reject_suspend; } if (!wil_is_wmi_idle(wil)) { wil_dbg_pm(wil, "Pending WMI events, reject suspend\n"); wil->suspend_stats.rejected_by_host++; goto reject_suspend; } /* Send WMI suspend request to the device */ rc = wmi_suspend(wil); if (rc) { wil_dbg_pm(wil, "wmi_suspend failed, reject suspend (%d)\n", rc); goto reject_suspend; } /* Wait for completion of the pending RX packets */ data_comp_to = jiffies + msecs_to_jiffies(WIL_DATA_COMPLETION_TO_MS); if (test_bit(wil_status_napi_en, wil->status)) { while (!wil->txrx_ops.is_rx_idle(wil)) { if (time_after(jiffies, data_comp_to)) { if (wil->txrx_ops.is_rx_idle(wil)) break; wil_err(wil, "TO waiting for idle RX, suspend failed\n"); wil->suspend_stats.r_on.failed_suspends++; goto resume_after_fail; } wil_dbg_ratelimited(wil, "rx vring is not empty -> NAPI\n"); napi_synchronize(&wil->napi_rx); msleep(20); } } /* In case of pending WMI events, reject the suspend * and resume the device. * This can happen if the device sent the WMI events before * approving the suspend. */ if (!wil_is_wmi_idle(wil)) { wil_err(wil, "suspend failed due to pending WMI events\n"); wil->suspend_stats.r_on.failed_suspends++; goto resume_after_fail; } wil_mask_irq(wil); /* Disable device reset on PERST */ wil_s(wil, RGF_USER_CLKS_CTL_0, BIT_USER_CLKS_RST_PWGD); if (wil->platform_ops.suspend) { rc = wil->platform_ops.suspend(wil->platform_handle, true); if (rc) { wil_err(wil, "platform device failed to suspend (%d)\n", rc); wil->suspend_stats.r_on.failed_suspends++; wil_c(wil, RGF_USER_CLKS_CTL_0, BIT_USER_CLKS_RST_PWGD); wil_unmask_irq(wil); goto resume_after_fail; } } /* Save the current bus request to return to the same in resume */ wil->bus_request_kbps_pre_suspend = wil->bus_request_kbps; wil6210_bus_request(wil, 0); set_bit(wil_status_suspended, wil->status); clear_bit(wil_status_suspending, wil->status); return rc; resume_after_fail: set_bit(wil_status_resuming, wil->status); clear_bit(wil_status_suspending, wil->status); rc = wmi_resume(wil); /* if resume succeeded, reject the suspend */ if (!rc) { rc = -EBUSY; wil_pm_wake_connected_net_queues(wil); } return rc; reject_suspend: clear_bit(wil_status_suspending, wil->status); wil_pm_wake_connected_net_queues(wil); return -EBUSY; }