]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
staging: wilc1000: use mutex lock to synchronized sending 'wid' cmd to firmware
authorAjay Singh <ajay.kathat@microchip.com>
Sun, 2 Dec 2018 18:02:25 +0000 (18:02 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 5 Dec 2018 08:48:45 +0000 (09:48 +0100)
Use mutex lock to protect the issuing of wid cmd to the firmware.
Currently the wid commands are synchronized by use of hif_workqueue work
queue.
Now, these changes are required to synchronize the access to wid
command, so the commands can be issued directly from cfg80211 context
and 'WILC_wq' thread.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/wilc1000/linux_wlan.c
drivers/staging/wilc1000/wilc_wfi_netdevice.h
drivers/staging/wilc1000/wilc_wlan.c

index c92ee79ab2e4c82fba29037066eb16d16b10fa59..e246d18896e4f19496d6e9ef38aa151dee71d74b 100644 (file)
@@ -531,6 +531,7 @@ static void wlan_deinit_locks(struct net_device *dev)
 
        mutex_destroy(&wilc->hif_cs);
        mutex_destroy(&wilc->rxq_cs);
+       mutex_destroy(&wilc->cfg_cmd_lock);
        mutex_destroy(&wilc->txq_add_to_head_cs);
 }
 
@@ -592,6 +593,7 @@ static void wlan_init_locks(struct net_device *dev)
 
        mutex_init(&wl->hif_cs);
        mutex_init(&wl->rxq_cs);
+       mutex_init(&wl->cfg_cmd_lock);
 
        spin_lock_init(&wl->txq_spinlock);
        mutex_init(&wl->txq_add_to_head_cs);
index e71d94989d3084602b65ad7dc815bb7e861ad421..02970c35dd6958552ebfe5283cd519b291b9c74e 100644 (file)
@@ -247,7 +247,8 @@ struct wilc {
        struct task_struct *txq_thread;
 
        int quit;
-       int cfg_frame_in_use;
+       /* lock to protect issue of wid command to firmware */
+       struct mutex cfg_cmd_lock;
        struct wilc_cfg_frame cfg_frame;
        u32 cfg_frame_offset;
        int cfg_seq_no;
index f0b10e275204f871d594b335c2727a5aa19488c0..3c5e9e030cadcff05cde6f37dc3c63ec5fc6f2b4 100644 (file)
@@ -1122,8 +1122,7 @@ int wilc_wlan_cfg_set(struct wilc_vif *vif, int start, u16 wid, u8 *buffer,
        int ret_size;
        struct wilc *wilc = vif->wilc;
 
-       if (wilc->cfg_frame_in_use)
-               return 0;
+       mutex_lock(&wilc->cfg_cmd_lock);
 
        if (start)
                wilc->cfg_frame_offset = 0;
@@ -1134,11 +1133,12 @@ int wilc_wlan_cfg_set(struct wilc_vif *vif, int start, u16 wid, u8 *buffer,
        offset += ret_size;
        wilc->cfg_frame_offset = offset;
 
-       if (!commit)
+       if (!commit) {
+               mutex_unlock(&wilc->cfg_cmd_lock);
                return ret_size;
+       }
 
        netdev_dbg(vif->ndev, "%s: seqno[%d]\n", __func__, wilc->cfg_seq_no);
-       wilc->cfg_frame_in_use = 1;
 
        if (wilc_wlan_cfg_commit(vif, WILC_CFG_SET, drv_handler))
                ret_size = 0;
@@ -1149,9 +1149,9 @@ int wilc_wlan_cfg_set(struct wilc_vif *vif, int start, u16 wid, u8 *buffer,
                ret_size = 0;
        }
 
-       wilc->cfg_frame_in_use = 0;
        wilc->cfg_frame_offset = 0;
        wilc->cfg_seq_no += 1;
+       mutex_unlock(&wilc->cfg_cmd_lock);
 
        return ret_size;
 }
@@ -1163,8 +1163,7 @@ int wilc_wlan_cfg_get(struct wilc_vif *vif, int start, u16 wid, int commit,
        int ret_size;
        struct wilc *wilc = vif->wilc;
 
-       if (wilc->cfg_frame_in_use)
-               return 0;
+       mutex_lock(&wilc->cfg_cmd_lock);
 
        if (start)
                wilc->cfg_frame_offset = 0;
@@ -1174,10 +1173,10 @@ int wilc_wlan_cfg_get(struct wilc_vif *vif, int start, u16 wid, int commit,
        offset += ret_size;
        wilc->cfg_frame_offset = offset;
 
-       if (!commit)
+       if (!commit) {
+               mutex_unlock(&wilc->cfg_cmd_lock);
                return ret_size;
-
-       wilc->cfg_frame_in_use = 1;
+       }
 
        if (wilc_wlan_cfg_commit(vif, WILC_CFG_QUERY, drv_handler))
                ret_size = 0;
@@ -1187,9 +1186,9 @@ int wilc_wlan_cfg_get(struct wilc_vif *vif, int start, u16 wid, int commit,
                netdev_dbg(vif->ndev, "%s: Timed Out\n", __func__);
                ret_size = 0;
        }
-       wilc->cfg_frame_in_use = 0;
        wilc->cfg_frame_offset = 0;
        wilc->cfg_seq_no += 1;
+       mutex_unlock(&wilc->cfg_cmd_lock);
 
        return ret_size;
 }