summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvraham Stern <avraham.stern@intel.com>2022-11-02 15:59:58 +0100
committerGregory Greenman <gregory.greenman@intel.com>2022-11-10 12:27:11 +0100
commitb0b9b80599a30ee8862c0294b8a3b69c9c6df4f9 (patch)
tree3eaddacaee1785f5deeb819efc002133d7aa6c0e
parentwifi: iwlwifi: iwlmei: report disconnection as temporary (diff)
downloadlinux-b0b9b80599a30ee8862c0294b8a3b69c9c6df4f9.tar.xz
linux-b0b9b80599a30ee8862c0294b8a3b69c9c6df4f9.zip
wifi: iwlwifi: mei: wait for the mac to stop on suspend
When iwlmei driver is removed, it removes all the interfaces since CSME will take over the NIC while there is no SAP connection. When the iwlmei driver is removed due to the host being suspended, this results in the interface being down after resume since the interface was removed on suspend so mac80211 will not try to bring it up on resume. Since on suspend the mac is stopped anyway by mac80211, there is no need to remove the interface in this case. Wait for the mac to stop instead. Once the mac is stopped, the driver will not access the NIC anymore so it is safe for CSME to take over. Signed-off-by: Avraham Stern <avraham.stern@intel.com> Signed-off-by: Gregory Greenman <gregory.greenman@intel.com> Link: https://lore.kernel.org/r/20221102165239.371102f04586.I813a964607b3e92ea275a0cf56df57227c11ae88@changeid
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mei/main.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/drivers/net/wireless/intel/iwlwifi/mei/main.c b/drivers/net/wireless/intel/iwlwifi/mei/main.c
index 9a49361cd059..b89989b6399a 100644
--- a/drivers/net/wireless/intel/iwlwifi/mei/main.c
+++ b/drivers/net/wireless/intel/iwlwifi/mei/main.c
@@ -1990,6 +1990,7 @@ free:
}
#define SEND_SAP_MAX_WAIT_ITERATION 10
+#define IWLMEI_DEVICE_DOWN_WAIT_ITERATION 50
static void iwl_mei_remove(struct mei_cl_device *cldev)
{
@@ -2000,8 +2001,26 @@ static void iwl_mei_remove(struct mei_cl_device *cldev)
* We are being removed while the bus is active, it means we are
* going to suspend/ shutdown, so the NIC will disappear.
*/
- if (mei_cldev_enabled(cldev) && iwl_mei_cache.ops)
- iwl_mei_cache.ops->nic_stolen(iwl_mei_cache.priv);
+ if (mei_cldev_enabled(cldev) && iwl_mei_cache.ops) {
+ unsigned int iter = IWLMEI_DEVICE_DOWN_WAIT_ITERATION;
+ bool down = false;
+
+ /*
+ * In case of suspend, wait for the mac to stop and don't remove
+ * the interface. This will allow the interface to come back
+ * on resume.
+ */
+ while (!down && iter--) {
+ mdelay(1);
+
+ mutex_lock(&iwl_mei_mutex);
+ down = mei->device_down;
+ mutex_unlock(&iwl_mei_mutex);
+ }
+
+ if (!down)
+ iwl_mei_cache.ops->nic_stolen(iwl_mei_cache.priv);
+ }
if (rcu_access_pointer(iwl_mei_cache.netdev)) {
struct net_device *dev;