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 <ajay.kathat@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Ajay Singh 2018-12-02 18:02:25 +00:00 committed by Greg Kroah-Hartman
parent f78d5db98b
commit 6dea33021f
3 changed files with 14 additions and 12 deletions

View 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);

View 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;

View 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;
}