staging: wilc1000: use completions in host_interface
v3 cover staging: wilc1000: use completions in host_interface
This patchset replaces the semaphores in struct host_if_drv with the more preferred locking mechanisms completions.
Each semaphore was used in the send/receive of HOST_IF_MSG_* messages. Each builds and queues a message (LOCK!) and then a corresponding "Handler" function is called from the hostIFthread() when the message is returned (UNLOCK).
Note that in Patch 4 you will not see a 1:1 correspondence between wait_for_completion and complete. Whereas 6 different functions build the KEY messages, only 5 handlers are used.
Changes in v2
- spun off patch 5 as a separate patch so that this set only includes
semaphores->completions
- rebase/rebuild
Changes in v3
- rebase/rebuild
Alison Schofield (4):
staging: wilc1000: replace semaphore sem_inactive_time with a
completion
staging: wilc1000: replace semaphore sem_get_rssi with a completion
staging: wilc1000: replace sem_test_disconn_block with a completion
staging: wilc1000: replace sem_test_key_block with a completion
drivers/staging/wilc1000/host_interface.c | 43 ++++++++++++++++--------------- drivers/staging/wilc1000/host_interface.h | 8 +++--- 2 files changed, 26 insertions(+), 25 deletions(-)
Signature · 1 line
2.1.4
PATCH v3 1/4 staging: wilc1000: replace semaphore sem_inactive_time with a completion
Semaphore sem_inactive_time is used to signal completion of its host interface message. Since the thread locking this semaphore will have to wait, completions are the preferred mechanism and will offer a performance improvement.
--- drivers/staging/wilc1000/host_interface.c | 7 ++++--- drivers/staging/wilc1000/host_interface.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/staging/wilc1000/host_interface.c +4 -3
@@ -2,6 +2,7 @@#include <linux/time.h> #include <linux/kthread.h> #include <linux/delay.h> +#include <linux/completion.h> #include "host_interface.h" #include "coreconfigurator.h" #include "wilc_wlan.h"
@@ -1979,7 +1980,7 @@ static s32 Handle_Get_InActiveTime(struct wilc_vif *vif,return -EFAULT ; } -up (&hif_drv->sem_inactive_time); +complete (&hif_drv->comp_inactive_time);return result; }
@@ -3220,7 +3221,7 @@ s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac,if (result)netdev_err (vif->ndev,"Failed to send get host ch param\n" ); -down (&hif_drv->sem_inactive_time); +wait_for_completion (&hif_drv->comp_inactive_time); *pu32InactiveTime = inactive_time;
@@ -3407,7 +3408,7 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler)sema_init (&hif_drv->sem_test_key_block,0 );sema_init (&hif_drv->sem_test_disconn_block,0 );sema_init (&hif_drv->sem_get_rssi,0 ); -sema_init (&hif_drv->sem_inactive_time,0 ); +init_completion (&hif_drv->comp_inactive_time);if (clients_count ==0 ) { result =wilc_mq_create (&hif_msg_q);
drivers/staging/wilc1000/host_interface.h +1 -1
@@ -278,7 +278,7 @@ struct host_if_drv {struct semaphore sem_test_key_block;struct semaphore sem_test_disconn_block;struct semaphore sem_get_rssi; -struct semaphore sem_inactive_time; +struct completion comp_inactive_time;struct timer_list scan_timer;struct timer_list connect_timer;
Signature · 1 line
2.1.4
PATCH v3 2/4 staging: wilc1000: replace semaphore sem_get_rssi with a completion
In reply to Alison SchofieldSemaphore sem_get_rssi is used to signal completion of its host interface message. Since the thread locking this semaphore will have to wait, completions are the preferred mechanism and will offer a performance improvement.
--- drivers/staging/wilc1000/host_interface.c | 6 +++--- drivers/staging/wilc1000/host_interface.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/staging/wilc1000/host_interface.c +3 -3
@@ -1886,7 +1886,7 @@ static void Handle_GetRssi(struct wilc_vif *vif) result = -EFAULT ; } -up (&vif->hif_drv->sem_get_rssi); +complete (&vif->hif_drv->comp_get_rssi); } static s32 Handle_GetStatistics(struct wilc_vif *vif,
@@ -3244,7 +3244,7 @@ int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level)return -EFAULT ; } -down (&hif_drv->sem_get_rssi); +wait_for_completion (&hif_drv->comp_get_rssi);if (!rssi_level) {netdev_err (vif->ndev,"RSS pointer value is null\n" );
@@ -3407,7 +3407,7 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler)sema_init (&hif_drv->sem_test_key_block,0 );sema_init (&hif_drv->sem_test_disconn_block,0 ); -sema_init (&hif_drv->sem_get_rssi,0 ); +init_completion (&hif_drv->comp_get_rssi);init_completion (&hif_drv->comp_inactive_time);if (clients_count ==0 ) {
drivers/staging/wilc1000/host_interface.h +1 -1
@@ -277,7 +277,7 @@ struct host_if_drv {struct mutex cfg_values_lock;struct semaphore sem_test_key_block;struct semaphore sem_test_disconn_block; -struct semaphore sem_get_rssi; +struct completion comp_get_rssi;struct completion comp_inactive_time;struct timer_list scan_timer;
Signature · 1 line
2.1.4
PATCH v3 3/4 staging: wilc1000: replace sem_test_disconn_block with a completion
In reply to Alison SchofieldSemaphore sem_test_disconn_block is used to signal completion of its host interface message. Since the thread locking this semaphore will have to wait, completions are the preferred mechanism and will offer a performance improvement.
--- drivers/staging/wilc1000/host_interface.c | 6 +++--- drivers/staging/wilc1000/host_interface.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/staging/wilc1000/host_interface.c +3 -3
@@ -1857,7 +1857,7 @@ static void Handle_Disconnect(struct wilc_vif *vif) } } -up (&hif_drv->sem_test_disconn_block); +complete (&hif_drv->comp_test_disconn_block); }void wilc_resolve_disconnect_aberration (struct wilc_vif *vif)
@@ -3099,7 +3099,7 @@ int wilc_disconnect(struct wilc_vif *vif, u16 reason_code)if (result)netdev_err (vif->ndev,"Failed to send message: disconnect\n" ); -down (&hif_drv->sem_test_disconn_block); +wait_for_completion (&hif_drv->comp_test_disconn_block);return result; }
@@ -3406,7 +3406,7 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler) }sema_init (&hif_drv->sem_test_key_block,0 ); -sema_init (&hif_drv->sem_test_disconn_block,0 ); +init_completion (&hif_drv->comp_test_disconn_block);init_completion (&hif_drv->comp_get_rssi);init_completion (&hif_drv->comp_inactive_time);
drivers/staging/wilc1000/host_interface.h +1 -1
@@ -276,7 +276,7 @@ struct host_if_drv {struct mutex cfg_values_lock;struct semaphore sem_test_key_block; -struct semaphore sem_test_disconn_block; +struct completion comp_test_disconn_block;struct completion comp_get_rssi;struct completion comp_inactive_time;
Signature · 1 line
2.1.4
PATCH v3 4/4 staging: wilc1000: replace sem_test_key_block with a completion
In reply to Alison Schofield Semaphore sem_test_key_block is used to signal completion of its host interface message. Since the thread locking this semaphore will have to wait, completions are the preferred mechanism and will offer a performance improvement.
--- drivers/staging/wilc1000/host_interface.c | 24 ++++++++++++------------ drivers/staging/wilc1000/host_interface.h | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-)
drivers/staging/wilc1000/host_interface.c +12 -12
@@ -1611,7 +1611,7 @@ static int Handle_Key(struct wilc_vif *vif, &wid,1 , wilc_get_vif_idx(vif)); } -up (&hif_drv->sem_test_key_block); +complete (&hif_drv->comp_test_key_block);break ;case WPA_RX_GTK :
@@ -1645,7 +1645,7 @@ static int Handle_Key(struct wilc_vif *vif, wilc_get_vif_idx(vif));kfree (pu8keybuf); -up (&hif_drv->sem_test_key_block); +complete (&hif_drv->comp_test_key_block); }else if (pstrHostIFkeyAttr->action &ADDKEY ) { pu8keybuf =kzalloc (RX_MIC_KEY_MSG_LEN ,GFP_KERNEL );if (pu8keybuf ==NULL ) {
@@ -1674,7 +1674,7 @@ static int Handle_Key(struct wilc_vif *vif, wilc_get_vif_idx(vif));kfree (pu8keybuf); -up (&hif_drv->sem_test_key_block); +complete (&hif_drv->comp_test_key_block); } _WPARxGtk_end_case_:kfree (pstrHostIFkeyAttr->attr.wpa.key);
@@ -1712,7 +1712,7 @@ _WPARxGtk_end_case_: strWIDList,2 , wilc_get_vif_idx(vif));kfree (pu8keybuf); -up (&hif_drv->sem_test_key_block); +complete (&hif_drv->comp_test_key_block); }else if (pstrHostIFkeyAttr->action &ADDKEY ) { pu8keybuf =kmalloc (PTK_KEY_MSG_LEN ,GFP_KERNEL );if (!pu8keybuf) {
@@ -1735,7 +1735,7 @@ _WPARxGtk_end_case_: &wid,1 , wilc_get_vif_idx(vif));kfree (pu8keybuf); -up (&hif_drv->sem_test_key_block); +complete (&hif_drv->comp_test_key_block); } _WPAPtk_end_case_:
@@ -2731,7 +2731,7 @@ int wilc_remove_wep_key(struct wilc_vif *vif, u8 index) result =wilc_mq_send (&hif_msg_q, &msg,sizeof (struct host_if_msg ));if (result)netdev_err (vif->ndev,"Request to remove WEP key\n" ); -down (&hif_drv->sem_test_key_block); +wait_for_completion (&hif_drv->comp_test_key_block);return result; }
@@ -2759,7 +2759,7 @@ int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index) result =wilc_mq_send (&hif_msg_q, &msg,sizeof (struct host_if_msg ));if (result)netdev_err (vif->ndev,"Default key index\n" ); -down (&hif_drv->sem_test_key_block); +wait_for_completion (&hif_drv->comp_test_key_block);return result; }
@@ -2792,7 +2792,7 @@ int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len, result =wilc_mq_send (&hif_msg_q, &msg,sizeof (struct host_if_msg ));if (result)netdev_err (vif->ndev,"STA - WEP Key\n" ); -down (&hif_drv->sem_test_key_block); +wait_for_completion (&hif_drv->comp_test_key_block);return result; }
@@ -2828,7 +2828,7 @@ int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len,if (result)netdev_err (vif->ndev,"AP - WEP Key\n" ); -down (&hif_drv->sem_test_key_block); +wait_for_completion (&hif_drv->comp_test_key_block);return result; }
@@ -2884,7 +2884,7 @@ int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len,if (result)netdev_err (vif->ndev,"PTK Key\n" ); -down (&hif_drv->sem_test_key_block); +wait_for_completion (&hif_drv->comp_test_key_block);return result; }
@@ -2952,7 +2952,7 @@ int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len,if (result)netdev_err (vif->ndev,"RX GTK\n" ); -down (&hif_drv->sem_test_key_block); +wait_for_completion (&hif_drv->comp_test_key_block);return result; }
@@ -3405,7 +3405,7 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler)sema_init (&hif_sema_deinit,1 ); } -sema_init (&hif_drv->sem_test_key_block,0 ); +init_completion (&hif_drv->comp_test_key_block);init_completion (&hif_drv->comp_test_disconn_block);init_completion (&hif_drv->comp_get_rssi);init_completion (&hif_drv->comp_inactive_time);
drivers/staging/wilc1000/host_interface.h +1 -1
@@ -275,7 +275,7 @@ struct host_if_drv {struct cfg_param_attr cfg_values;struct mutex cfg_values_lock; -struct semaphore sem_test_key_block; +struct completion comp_test_key_block;struct completion comp_test_disconn_block;struct completion comp_get_rssi;struct completion comp_inactive_time;
Signature · 1 line
2.1.4