mwifiex: cancel pending commands during host sleep
authorAmitkumar Karwar <akarwar@marvell.com>
Wed, 26 Mar 2014 02:01:20 +0000 (19:01 -0700)
committerJohn W. Linville <linville@tuxdriver.com>
Thu, 27 Mar 2014 18:20:06 +0000 (14:20 -0400)
Sometimes we may end up downloading other commands when host
sleep is configured. This patch makes sure that pending
commands are cancelled and we stop queueing further commands
during host sleep.

Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/mwifiex/cmdevt.c
drivers/net/wireless/mwifiex/main.h
drivers/net/wireless/mwifiex/pcie.c
drivers/net/wireless/mwifiex/sdio.c
drivers/net/wireless/mwifiex/sta_ioctl.c
drivers/net/wireless/mwifiex/usb.c

index cc81fcd35959331ec24c996bed6a336aaa08e6a3..a23791d4995561b1531e3123989a41ce3a38e940 100644 (file)
@@ -509,6 +509,11 @@ int mwifiex_send_cmd(struct mwifiex_private *priv, u16 cmd_no,
                return -1;
        }
 
+       if (adapter->hs_enabling && cmd_no != HostCmd_CMD_802_11_HS_CFG_ENH) {
+               dev_err(adapter->dev, "PREP_CMD: host entering sleep state\n");
+               return -1;
+       }
+
        if (adapter->surprise_removed) {
                dev_err(adapter->dev, "PREP_CMD: card is removed\n");
                return -1;
index a67f7da12b30e9f00c2b6c3c52ff5f306f56cef7..d53e1e8c9467a62663c4d28df86e623237cdc45f 100644 (file)
@@ -774,6 +774,7 @@ struct mwifiex_adapter {
        u16 hs_activate_wait_q_woken;
        wait_queue_head_t hs_activate_wait_q;
        bool is_suspended;
+       bool hs_enabling;
        u8 event_body[MAX_EVENT_SIZE];
        u32 hw_dot_11n_dev_cap;
        u8 hw_dev_mcs_support;
index 7614a42f9c36dc0735803098a4882ce30e60eba3..a7e8b96b2d9024de8c34e5e04b317c66d2e22820 100644 (file)
@@ -120,6 +120,7 @@ static int mwifiex_pcie_suspend(struct device *dev)
 
        /* Indicate device suspended */
        adapter->is_suspended = true;
+       adapter->hs_enabling = false;
 
        return 0;
 }
index e0dcd3ed7a69d01d1a5342be587a8901e2b34b57..d206f04d499498d6d9c7ba92a80685588ae7bc96 100644 (file)
@@ -237,6 +237,7 @@ static int mwifiex_sdio_suspend(struct device *dev)
        /* Enable the Host Sleep */
        if (!mwifiex_enable_hs(adapter)) {
                dev_err(adapter->dev, "cmd: failed to suspend\n");
+               adapter->hs_enabling = false;
                return -EFAULT;
        }
 
@@ -245,6 +246,7 @@ static int mwifiex_sdio_suspend(struct device *dev)
 
        /* Indicate device suspended */
        adapter->is_suspended = true;
+       adapter->hs_enabling = false;
 
        return ret;
 }
index 33170af150f6da3823ad3a5743f472fc6f141c98..2a9cfd563a07c7e1221e3d4230e14b2bd0ea939a 100644 (file)
@@ -508,6 +508,9 @@ int mwifiex_enable_hs(struct mwifiex_adapter *adapter)
        memset(&hscfg, 0, sizeof(struct mwifiex_ds_hs_cfg));
        hscfg.is_invoke_hostcmd = true;
 
+       adapter->hs_enabling = true;
+       mwifiex_cancel_all_pending_cmd(adapter);
+
        if (mwifiex_set_hs_params(mwifiex_get_priv(adapter,
                                                   MWIFIEX_BSS_ROLE_STA),
                                  HostCmd_ACT_GEN_SET, MWIFIEX_SYNC_CMD,
index ae30c390ebd31c215674c842c2d9b03af57b93ee..edbe4aff00d85b569534372ea34e7e017552b234 100644 (file)
@@ -459,6 +459,7 @@ static int mwifiex_usb_suspend(struct usb_interface *intf, pm_message_t message)
         * 'suspended' state and a 'disconnect' one.
         */
        adapter->is_suspended = true;
+       adapter->hs_enabling = false;
 
        if (atomic_read(&card->rx_cmd_urb_pending) && card->rx_cmd.urb)
                usb_kill_urb(card->rx_cmd.urb);