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 cc81fcd..a23791d 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 a67f7da..d53e1e8 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 7614a42..a7e8b96 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 e0dcd3e..d206f04 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 33170af..2a9cfd5 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 ae30c39..edbe4af 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);