mwifiex: Fix issue in the SDIO reset path of mwifiex.
authorMaithili Hinge <maithili@marvell.com>
Mon, 23 Mar 2015 06:01:25 +0000 (23:01 -0700)
committerKalle Valo <kvalo@codeaurora.org>
Mon, 30 Mar 2015 08:32:56 +0000 (11:32 +0300)
SDIO reset was not happening properly on mwifiex as cancel_work_sync
in mwifiex_sdio_remove used to kill the calling work function itself.
Due to this, the interface was not getting removed and card was not
getting added again. Reset work function has been made independent
of adapter variable and cancel_work_sync has been moved to cleanup
function.

Signed-off-by: Maithili Hinge <maithili@marvell.com>
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/mwifiex/main.c
drivers/net/wireless/mwifiex/main.h
drivers/net/wireless/mwifiex/pcie.c
drivers/net/wireless/mwifiex/sdio.c

index eaaacecbdef65a1b1e1e45e7b86126194d251990..a3c2bb122c0907bbea47d9c2d827a4df057f8e22 100644 (file)
@@ -1149,9 +1149,6 @@ mwifiex_add_card(void *card, struct semaphore *sem,
                INIT_WORK(&adapter->rx_work, mwifiex_rx_work_queue);
        }
 
-       if (adapter->if_ops.iface_work)
-               INIT_WORK(&adapter->iface_work, adapter->if_ops.iface_work);
-
        /* Register the device. Fill up the private data structure with relevant
           information from the card. */
        if (adapter->if_ops.register_dev(adapter)) {
index 842fa0beb18841c4dbfee76f27a57b6b6b0c6072..b97b85b7f2a17e96bc79f5d25c8798848f4bcb42 100644 (file)
@@ -898,8 +898,6 @@ struct mwifiex_adapter {
        bool ext_scan;
        u8 fw_api_ver;
        u8 key_api_major_ver, key_api_minor_ver;
-       struct work_struct iface_work;
-       unsigned long iface_work_flags;
        struct memory_type_mapping *mem_type_mapping_tbl;
        u8 num_mem_types;
        u8 curr_mem_idx;
index b31c9a70ffaaa4de5f0a426966d39eb888b2959a..bcc7751d883c3773b558ef8c8b8bb8c3a8a3c474 100644 (file)
@@ -234,8 +234,6 @@ static void mwifiex_pcie_remove(struct pci_dev *pdev)
        if (!adapter || !adapter->priv_num)
                return;
 
-       cancel_work_sync(&adapter->iface_work);
-
        if (user_rmmod) {
 #ifdef CONFIG_PM_SLEEP
                if (adapter->is_suspended)
@@ -2373,25 +2371,26 @@ done:
        adapter->curr_mem_idx = 0;
 }
 
+static unsigned long iface_work_flags;
+static struct mwifiex_adapter *save_adapter;
 static void mwifiex_pcie_work(struct work_struct *work)
 {
-       struct mwifiex_adapter *adapter =
-                       container_of(work, struct mwifiex_adapter, iface_work);
-
        if (test_and_clear_bit(MWIFIEX_IFACE_WORK_FW_DUMP,
-                              &adapter->iface_work_flags))
-               mwifiex_pcie_fw_dump_work(adapter);
+                              &iface_work_flags))
+               mwifiex_pcie_fw_dump_work(save_adapter);
 }
 
+static DECLARE_WORK(pcie_work, mwifiex_pcie_work);
 /* This function dumps FW information */
 static void mwifiex_pcie_fw_dump(struct mwifiex_adapter *adapter)
 {
-       if (test_bit(MWIFIEX_IFACE_WORK_FW_DUMP, &adapter->iface_work_flags))
+       save_adapter = adapter;
+       if (test_bit(MWIFIEX_IFACE_WORK_FW_DUMP, &iface_work_flags))
                return;
 
-       set_bit(MWIFIEX_IFACE_WORK_FW_DUMP, &adapter->iface_work_flags);
+       set_bit(MWIFIEX_IFACE_WORK_FW_DUMP, &iface_work_flags);
 
-       schedule_work(&adapter->iface_work);
+       schedule_work(&pcie_work);
 }
 
 /*
@@ -2619,7 +2618,6 @@ static struct mwifiex_if_ops pcie_ops = {
        .init_fw_port =                 mwifiex_pcie_init_fw_port,
        .clean_pcie_ring =              mwifiex_clean_pcie_ring_buf,
        .fw_dump =                      mwifiex_pcie_fw_dump,
-       .iface_work =                   mwifiex_pcie_work,
 };
 
 /*
@@ -2665,6 +2663,7 @@ static void mwifiex_pcie_cleanup_module(void)
        /* Set the flag as user is removing this module. */
        user_rmmod = 1;
 
+       cancel_work_sync(&pcie_work);
        pci_unregister_driver(&mwifiex_pcie);
 }
 
index 4f08c58989aff8a491c4e0e836858f09021b0c87..6af7a08253f278cb225774a08bf0686c2e7d7567 100644 (file)
@@ -47,6 +47,7 @@
 static u8 user_rmmod;
 
 static struct mwifiex_if_ops sdio_ops;
+static unsigned long iface_work_flags;
 
 static struct semaphore add_remove_card_sem;
 
@@ -200,8 +201,6 @@ mwifiex_sdio_remove(struct sdio_func *func)
        if (!adapter || !adapter->priv_num)
                return;
 
-       cancel_work_sync(&adapter->iface_work);
-
        if (user_rmmod) {
                if (adapter->is_suspended)
                        mwifiex_sdio_resume(adapter->dev);
@@ -2040,6 +2039,7 @@ mwifiex_update_mp_end_port(struct mwifiex_adapter *adapter, u16 port)
                port, card->mp_data_port_mask);
 }
 
+static struct mwifiex_adapter *save_adapter;
 static void mwifiex_sdio_card_reset_work(struct mwifiex_adapter *adapter)
 {
        struct sdio_mmc_card *card = adapter->card;
@@ -2108,10 +2108,8 @@ rdwr_status mwifiex_sdio_rdwr_firmware(struct mwifiex_adapter *adapter,
 }
 
 /* This function dump firmware memory to file */
-static void mwifiex_sdio_fw_dump_work(struct work_struct *work)
+static void mwifiex_sdio_fw_dump_work(struct mwifiex_adapter *adapter)
 {
-       struct mwifiex_adapter *adapter =
-                       container_of(work, struct mwifiex_adapter, iface_work);
        struct sdio_mmc_card *card = adapter->card;
        int ret = 0;
        unsigned int reg, reg_start, reg_end;
@@ -2233,36 +2231,36 @@ done:
 
 static void mwifiex_sdio_work(struct work_struct *work)
 {
-       struct mwifiex_adapter *adapter =
-                       container_of(work, struct mwifiex_adapter, iface_work);
-
-       if (test_and_clear_bit(MWIFIEX_IFACE_WORK_CARD_RESET,
-                              &adapter->iface_work_flags))
-               mwifiex_sdio_card_reset_work(adapter);
        if (test_and_clear_bit(MWIFIEX_IFACE_WORK_FW_DUMP,
-                              &adapter->iface_work_flags))
-               mwifiex_sdio_fw_dump_work(work);
+                              &iface_work_flags))
+               mwifiex_sdio_fw_dump_work(save_adapter);
+       if (test_and_clear_bit(MWIFIEX_IFACE_WORK_CARD_RESET,
+                              &iface_work_flags))
+               mwifiex_sdio_card_reset_work(save_adapter);
 }
 
+static DECLARE_WORK(sdio_work, mwifiex_sdio_work);
 /* This function resets the card */
 static void mwifiex_sdio_card_reset(struct mwifiex_adapter *adapter)
 {
-       if (test_bit(MWIFIEX_IFACE_WORK_CARD_RESET, &adapter->iface_work_flags))
+       save_adapter = adapter;
+       if (test_bit(MWIFIEX_IFACE_WORK_CARD_RESET, &iface_work_flags))
                return;
 
-       set_bit(MWIFIEX_IFACE_WORK_CARD_RESET, &adapter->iface_work_flags);
+       set_bit(MWIFIEX_IFACE_WORK_CARD_RESET, &iface_work_flags);
 
-       schedule_work(&adapter->iface_work);
+       schedule_work(&sdio_work);
 }
 
 /* This function dumps FW information */
 static void mwifiex_sdio_fw_dump(struct mwifiex_adapter *adapter)
 {
-       if (test_bit(MWIFIEX_IFACE_WORK_FW_DUMP, &adapter->iface_work_flags))
+       save_adapter = adapter;
+       if (test_bit(MWIFIEX_IFACE_WORK_FW_DUMP, &iface_work_flags))
                return;
 
-       set_bit(MWIFIEX_IFACE_WORK_FW_DUMP, &adapter->iface_work_flags);
-       schedule_work(&adapter->iface_work);
+       set_bit(MWIFIEX_IFACE_WORK_FW_DUMP, &iface_work_flags);
+       schedule_work(&sdio_work);
 }
 
 /* Function to dump SDIO function registers and SDIO scratch registers in case
@@ -2378,7 +2376,6 @@ static struct mwifiex_if_ops sdio_ops = {
        .cmdrsp_complete = mwifiex_sdio_cmdrsp_complete,
        .event_complete = mwifiex_sdio_event_complete,
        .card_reset = mwifiex_sdio_card_reset,
-       .iface_work = mwifiex_sdio_work,
        .fw_dump = mwifiex_sdio_fw_dump,
        .reg_dump = mwifiex_sdio_reg_dump,
        .deaggr_pkt = mwifiex_deaggr_sdio_pkt,
@@ -2418,6 +2415,7 @@ mwifiex_sdio_cleanup_module(void)
 
        /* Set the flag as user is removing this module. */
        user_rmmod = 1;
+       cancel_work_sync(&sdio_work);
 
        sdio_unregister_driver(&mwifiex_sdio);
 }