All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/4] staging: wilc1000: use completions in host_interface
@ 2016-03-14 17:33 Alison Schofield
  2016-03-14 17:34 ` [PATCH v3 1/4] staging: wilc1000: replace semaphore sem_inactive_time with a completion Alison Schofield
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Alison Schofield @ 2016-03-14 17:33 UTC (permalink / raw)
  To: outreachy-kernel

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(-)

-- 
2.1.4



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v3 1/4] staging: wilc1000: replace semaphore sem_inactive_time with a completion
  2016-03-14 17:33 [PATCH v3 0/4] staging: wilc1000: use completions in host_interface Alison Schofield
@ 2016-03-14 17:34 ` Alison Schofield
  2016-03-14 17:34 ` [PATCH v3 2/4] staging: wilc1000: replace semaphore sem_get_rssi " Alison Schofield
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Alison Schofield @ 2016-03-14 17:34 UTC (permalink / raw)
  To: outreachy-kernel

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.

Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Tested-by: Leo Kim <leo.kim@atmel.com>
---
 drivers/staging/wilc1000/host_interface.c | 7 ++++---
 drivers/staging/wilc1000/host_interface.h | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c
index 0a922c7..25634ae 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -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);
diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h
index 01f3222..68852b3 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -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;
-- 
2.1.4



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v3 2/4] staging: wilc1000: replace semaphore sem_get_rssi with a completion
  2016-03-14 17:33 [PATCH v3 0/4] staging: wilc1000: use completions in host_interface Alison Schofield
  2016-03-14 17:34 ` [PATCH v3 1/4] staging: wilc1000: replace semaphore sem_inactive_time with a completion Alison Schofield
@ 2016-03-14 17:34 ` Alison Schofield
  2016-03-14 17:35 ` [PATCH v3 3/4] staging: wilc1000: replace sem_test_disconn_block " Alison Schofield
  2016-03-14 17:35 ` [PATCH v3 4/4] staging: wilc1000: replace sem_test_key_block " Alison Schofield
  3 siblings, 0 replies; 5+ messages in thread
From: Alison Schofield @ 2016-03-14 17:34 UTC (permalink / raw)
  To: outreachy-kernel

Semaphore 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.

Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Tested-by: Leo Kim <leo.kim@atmel.com>
---
 drivers/staging/wilc1000/host_interface.c | 6 +++---
 drivers/staging/wilc1000/host_interface.h | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c
index 25634ae..22b328f 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -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)	{
diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h
index 68852b3..085adee 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -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;
-- 
2.1.4



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v3 3/4] staging: wilc1000: replace sem_test_disconn_block with a completion
  2016-03-14 17:33 [PATCH v3 0/4] staging: wilc1000: use completions in host_interface Alison Schofield
  2016-03-14 17:34 ` [PATCH v3 1/4] staging: wilc1000: replace semaphore sem_inactive_time with a completion Alison Schofield
  2016-03-14 17:34 ` [PATCH v3 2/4] staging: wilc1000: replace semaphore sem_get_rssi " Alison Schofield
@ 2016-03-14 17:35 ` Alison Schofield
  2016-03-14 17:35 ` [PATCH v3 4/4] staging: wilc1000: replace sem_test_key_block " Alison Schofield
  3 siblings, 0 replies; 5+ messages in thread
From: Alison Schofield @ 2016-03-14 17:35 UTC (permalink / raw)
  To: outreachy-kernel

Semaphore 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.

Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Tested-by: Leo Kim <leo.kim@atmel.com>
---
 drivers/staging/wilc1000/host_interface.c | 6 +++---
 drivers/staging/wilc1000/host_interface.h | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c
index 22b328f..054f330 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -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);
 
diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h
index 085adee..3ab94a7 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -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;
 
-- 
2.1.4



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v3 4/4] staging: wilc1000: replace sem_test_key_block with a completion
  2016-03-14 17:33 [PATCH v3 0/4] staging: wilc1000: use completions in host_interface Alison Schofield
                   ` (2 preceding siblings ...)
  2016-03-14 17:35 ` [PATCH v3 3/4] staging: wilc1000: replace sem_test_disconn_block " Alison Schofield
@ 2016-03-14 17:35 ` Alison Schofield
  3 siblings, 0 replies; 5+ messages in thread
From: Alison Schofield @ 2016-03-14 17:35 UTC (permalink / raw)
  To: outreachy-kernel

    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.

Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Tested-by: Leo Kim <leo.kim@atmel.com>
---
 drivers/staging/wilc1000/host_interface.c | 24 ++++++++++++------------
 drivers/staging/wilc1000/host_interface.h |  2 +-
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c
index 054f330..d0a34b5 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -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);
diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h
index 3ab94a7..8d2dd0d 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -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;
-- 
2.1.4



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-03-14 17:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-14 17:33 [PATCH v3 0/4] staging: wilc1000: use completions in host_interface Alison Schofield
2016-03-14 17:34 ` [PATCH v3 1/4] staging: wilc1000: replace semaphore sem_inactive_time with a completion Alison Schofield
2016-03-14 17:34 ` [PATCH v3 2/4] staging: wilc1000: replace semaphore sem_get_rssi " Alison Schofield
2016-03-14 17:35 ` [PATCH v3 3/4] staging: wilc1000: replace sem_test_disconn_block " Alison Schofield
2016-03-14 17:35 ` [PATCH v3 4/4] staging: wilc1000: replace sem_test_key_block " Alison Schofield

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.