From: Ajay Singh Date: Sun, 2 Dec 2018 18:02:25 +0000 (+0000) Subject: staging: wilc1000: use mutex lock to synchronized sending 'wid' cmd to firmware X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=6dea33021f0b9a13ec0d634930e712eec40030c8;p=openwrt%2Fstaging%2Fblogic.git staging: wilc1000: use mutex lock to synchronized sending 'wid' cmd to firmware 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 Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index c92ee79ab2e4..e246d18896e4 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -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); diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index e71d94989d30..02970c35dd69 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -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; diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index f0b10e275204..3c5e9e030cad 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -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; }