* [PATCH 0/4] *** rtl8188eu: Replace semaphores with mutexes or completions ***
@ 2016-06-03 9:58 Binoy Jayan
2016-06-03 9:59 ` [PATCH 1/4] irtl8188eu: Replace semaphore cmd_queue_sema with completion Binoy Jayan
` (6 more replies)
0 siblings, 7 replies; 17+ messages in thread
From: Binoy Jayan @ 2016-06-03 9:58 UTC (permalink / raw)
To: Greg Kroah-Hartman, Larry Finger
Cc: Jakub Sitnicki, Arnd Bergmann, driverdev-devel, linux-kernel,
Binoy Jayan
Hi,
These are a set of patches which removes semaphores from:
drivers/staging/rtl8188eu
These are part of a bigger effort to eliminate all semaphores
from the linux kernel.
They build correctly (individually and as a whole).
NB: I have not tested this as I do not have the following hardware:
"Realtek RTL8188EU Wireless LAN NIC driver"
Thanks,
Binoy
Binoy Jayan (4):
irtl8188eu: Replace semaphore cmd_queue_sema with completion
rtl8188eu: Replace semaphore terminate_cmdthread_sema with completion
rtl8188eu: pwrctrl_priv: Replace semaphore 'lock' with mutex
rtl8188eu: Remove unused semaphores
drivers/staging/rtl8188eu/core/rtw_cmd.c | 12 ++++++------
drivers/staging/rtl8188eu/core/rtw_pwrctrl.c | 20 ++++++++++----------
drivers/staging/rtl8188eu/core/rtw_xmit.c | 4 ----
drivers/staging/rtl8188eu/include/osdep_service.h | 4 +---
drivers/staging/rtl8188eu/include/rtw_cmd.h | 4 ++--
drivers/staging/rtl8188eu/include/rtw_event.h | 2 +-
drivers/staging/rtl8188eu/include/rtw_pwrctrl.h | 17 +----------------
drivers/staging/rtl8188eu/include/rtw_xmit.h | 3 ---
drivers/staging/rtl8188eu/os_dep/os_intfs.c | 6 +++---
drivers/staging/rtl8188eu/os_dep/osdep_service.c | 7 -------
drivers/staging/rtl8188eu/os_dep/usb_intf.c | 8 ++++----
11 files changed, 28 insertions(+), 59 deletions(-)
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 1/4] irtl8188eu: Replace semaphore cmd_queue_sema with completion
2016-06-03 9:58 [PATCH 0/4] *** rtl8188eu: Replace semaphores with mutexes or completions *** Binoy Jayan
@ 2016-06-03 9:59 ` Binoy Jayan
2016-06-05 16:31 ` Larry Finger
2016-06-03 9:59 ` [PATCH 2/4] rtl8188eu: Replace semaphore terminate_cmdthread_sema " Binoy Jayan
` (5 subsequent siblings)
6 siblings, 1 reply; 17+ messages in thread
From: Binoy Jayan @ 2016-06-03 9:59 UTC (permalink / raw)
To: Greg Kroah-Hartman, Larry Finger
Cc: Jakub Sitnicki, Arnd Bergmann, driverdev-devel, linux-kernel,
Binoy Jayan
The semaphore 'cmd_queue_sema' is used as completion,
so convert it to struct completion.
Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>
---
drivers/staging/rtl8188eu/core/rtw_cmd.c | 6 +++---
drivers/staging/rtl8188eu/include/rtw_cmd.h | 2 +-
drivers/staging/rtl8188eu/os_dep/os_intfs.c | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c b/drivers/staging/rtl8188eu/core/rtw_cmd.c
index 7748523..a2937e7 100644
--- a/drivers/staging/rtl8188eu/core/rtw_cmd.c
+++ b/drivers/staging/rtl8188eu/core/rtw_cmd.c
@@ -27,7 +27,7 @@ No irqsave is necessary.
int rtw_init_cmd_priv(struct cmd_priv *pcmdpriv)
{
- sema_init(&(pcmdpriv->cmd_queue_sema), 0);
+ init_completion(&pcmdpriv->cmd_queue_comp);
sema_init(&(pcmdpriv->terminate_cmdthread_sema), 0);
_rtw_init_queue(&(pcmdpriv->cmd_queue));
@@ -122,7 +122,7 @@ u32 rtw_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj)
res = _rtw_enqueue_cmd(&pcmdpriv->cmd_queue, cmd_obj);
if (res == _SUCCESS)
- up(&pcmdpriv->cmd_queue_sema);
+ complete(&pcmdpriv->cmd_queue_comp);
exit:
@@ -167,7 +167,7 @@ int rtw_cmd_thread(void *context)
RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("start r871x rtw_cmd_thread !!!!\n"));
while (1) {
- if (_rtw_down_sema(&pcmdpriv->cmd_queue_sema) == _FAIL)
+ if (wait_for_completion_interruptible(&pcmdpriv->cmd_queue_comp))
break;
if (padapter->bDriverStopped ||
diff --git a/drivers/staging/rtl8188eu/include/rtw_cmd.h b/drivers/staging/rtl8188eu/include/rtw_cmd.h
index 08ca592..3532dd1 100644
--- a/drivers/staging/rtl8188eu/include/rtw_cmd.h
+++ b/drivers/staging/rtl8188eu/include/rtw_cmd.h
@@ -39,7 +39,7 @@ struct cmd_obj {
};
struct cmd_priv {
- struct semaphore cmd_queue_sema;
+ struct completion cmd_queue_comp;
struct semaphore terminate_cmdthread_sema;
struct __queue cmd_queue;
u8 cmdthd_running;
diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c
index ae2caff..a696d2b 100644
--- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c
+++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c
@@ -772,7 +772,7 @@ void rtw_stop_drv_threads(struct adapter *padapter)
RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_stop_drv_threads\n"));
/* Below is to terminate rtw_cmd_thread & event_thread... */
- up(&padapter->cmdpriv.cmd_queue_sema);
+ complete(&padapter->cmdpriv.cmd_queue_comp);
if (padapter->cmdThread)
_rtw_down_sema(&padapter->cmdpriv.terminate_cmdthread_sema);
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 2/4] rtl8188eu: Replace semaphore terminate_cmdthread_sema with completion
2016-06-03 9:58 [PATCH 0/4] *** rtl8188eu: Replace semaphores with mutexes or completions *** Binoy Jayan
2016-06-03 9:59 ` [PATCH 1/4] irtl8188eu: Replace semaphore cmd_queue_sema with completion Binoy Jayan
@ 2016-06-03 9:59 ` Binoy Jayan
2016-06-03 9:59 ` [PATCH 3/4] rtl8188eu: pwrctrl_priv: Replace semaphore 'lock' with mutex Binoy Jayan
` (4 subsequent siblings)
6 siblings, 0 replies; 17+ messages in thread
From: Binoy Jayan @ 2016-06-03 9:59 UTC (permalink / raw)
To: Greg Kroah-Hartman, Larry Finger
Cc: Jakub Sitnicki, Arnd Bergmann, driverdev-devel, linux-kernel,
Binoy Jayan
The semaphore 'terminate_cmdthread_sema' is used as completion,
so convert it to struct completion.
Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>
---
This patch depends on the following patch:
irtl8188eu: Replace semaphore cmd_queue_sema with completion
drivers/staging/rtl8188eu/core/rtw_cmd.c | 6 +++---
drivers/staging/rtl8188eu/include/rtw_cmd.h | 2 +-
drivers/staging/rtl8188eu/os_dep/os_intfs.c | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c b/drivers/staging/rtl8188eu/core/rtw_cmd.c
index a2937e7..9e12588 100644
--- a/drivers/staging/rtl8188eu/core/rtw_cmd.c
+++ b/drivers/staging/rtl8188eu/core/rtw_cmd.c
@@ -28,7 +28,7 @@ No irqsave is necessary.
int rtw_init_cmd_priv(struct cmd_priv *pcmdpriv)
{
init_completion(&pcmdpriv->cmd_queue_comp);
- sema_init(&(pcmdpriv->terminate_cmdthread_sema), 0);
+ init_completion(&pcmdpriv->terminate_cmdthread_comp);
_rtw_init_queue(&(pcmdpriv->cmd_queue));
return _SUCCESS;
@@ -162,7 +162,7 @@ int rtw_cmd_thread(void *context)
allow_signal(SIGTERM);
pcmdpriv->cmdthd_running = true;
- up(&pcmdpriv->terminate_cmdthread_sema);
+ complete(&pcmdpriv->terminate_cmdthread_comp);
RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("start r871x rtw_cmd_thread !!!!\n"));
@@ -234,7 +234,7 @@ _next:
rtw_free_cmd_obj(pcmd);
}
- up(&pcmdpriv->terminate_cmdthread_sema);
+ complete(&pcmdpriv->terminate_cmdthread_comp);
complete_and_exit(NULL, 0);
diff --git a/drivers/staging/rtl8188eu/include/rtw_cmd.h b/drivers/staging/rtl8188eu/include/rtw_cmd.h
index 3532dd1..2b53f58 100644
--- a/drivers/staging/rtl8188eu/include/rtw_cmd.h
+++ b/drivers/staging/rtl8188eu/include/rtw_cmd.h
@@ -40,7 +40,7 @@ struct cmd_obj {
struct cmd_priv {
struct completion cmd_queue_comp;
- struct semaphore terminate_cmdthread_sema;
+ struct completion terminate_cmdthread_comp;
struct __queue cmd_queue;
u8 cmdthd_running;
struct adapter *padapter;
diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c
index a696d2b..c494845 100644
--- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c
+++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c
@@ -762,7 +762,7 @@ static int rtw_start_drv_threads(struct adapter *padapter)
err = PTR_ERR(padapter->cmdThread);
else
/* wait for cmd_thread to run */
- _rtw_down_sema(&padapter->cmdpriv.terminate_cmdthread_sema);
+ wait_for_completion_interruptible(&padapter->cmdpriv.terminate_cmdthread_comp);
return err;
}
@@ -774,7 +774,7 @@ void rtw_stop_drv_threads(struct adapter *padapter)
/* Below is to terminate rtw_cmd_thread & event_thread... */
complete(&padapter->cmdpriv.cmd_queue_comp);
if (padapter->cmdThread)
- _rtw_down_sema(&padapter->cmdpriv.terminate_cmdthread_sema);
+ wait_for_completion_interruptible(&padapter->cmdpriv.terminate_cmdthread_comp);
}
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 3/4] rtl8188eu: pwrctrl_priv: Replace semaphore 'lock' with mutex
2016-06-03 9:58 [PATCH 0/4] *** rtl8188eu: Replace semaphores with mutexes or completions *** Binoy Jayan
2016-06-03 9:59 ` [PATCH 1/4] irtl8188eu: Replace semaphore cmd_queue_sema with completion Binoy Jayan
2016-06-03 9:59 ` [PATCH 2/4] rtl8188eu: Replace semaphore terminate_cmdthread_sema " Binoy Jayan
@ 2016-06-03 9:59 ` Binoy Jayan
2016-06-03 9:59 ` [PATCH 4/4] rtl8188eu: Remove unused semaphores Binoy Jayan
` (3 subsequent siblings)
6 siblings, 0 replies; 17+ messages in thread
From: Binoy Jayan @ 2016-06-03 9:59 UTC (permalink / raw)
To: Greg Kroah-Hartman, Larry Finger
Cc: Jakub Sitnicki, Arnd Bergmann, driverdev-devel, linux-kernel,
Binoy Jayan
The semaphore 'lock' in pwrctrl_priv is a simple mutex, so it should
be written as one. Semaphores are going away in the future. Also, remove
the now unused wrappers _init_pwrlock, _enter_pwrlock, _exit_pwrlock
and _rtw_down_sema.
Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>
---
This patch depends on the following patch:
rtl8188eu: Replace semaphore terminate_cmdthread_sema with completion
drivers/staging/rtl8188eu/core/rtw_pwrctrl.c | 20 ++++++++++----------
drivers/staging/rtl8188eu/include/osdep_service.h | 3 +--
drivers/staging/rtl8188eu/include/rtw_event.h | 1 +
drivers/staging/rtl8188eu/include/rtw_pwrctrl.h | 17 +----------------
drivers/staging/rtl8188eu/os_dep/osdep_service.c | 7 -------
drivers/staging/rtl8188eu/os_dep/usb_intf.c | 8 ++++----
6 files changed, 17 insertions(+), 39 deletions(-)
diff --git a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c
index 59c6d8a..0b70fe7 100644
--- a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c
+++ b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c
@@ -38,7 +38,7 @@ static int rtw_hw_suspend(struct adapter *padapter)
LeaveAllPowerSaveMode(padapter);
DBG_88E("==> rtw_hw_suspend\n");
- _enter_pwrlock(&pwrpriv->lock);
+ mutex_lock(&pwrpriv->mutex_lock);
pwrpriv->bips_processing = true;
/* s1. */
if (pnetdev) {
@@ -73,7 +73,7 @@ static int rtw_hw_suspend(struct adapter *padapter)
pwrpriv->rf_pwrstate = rf_off;
pwrpriv->bips_processing = false;
- _exit_pwrlock(&pwrpriv->lock);
+ mutex_unlock(&pwrpriv->mutex_lock);
return 0;
@@ -90,12 +90,12 @@ static int rtw_hw_resume(struct adapter *padapter)
/* system resume */
DBG_88E("==> rtw_hw_resume\n");
- _enter_pwrlock(&pwrpriv->lock);
+ mutex_lock(&pwrpriv->mutex_lock);
pwrpriv->bips_processing = true;
rtw_reset_drv_sw(padapter);
if (pm_netdev_open(pnetdev, false) != 0) {
- _exit_pwrlock(&pwrpriv->lock);
+ mutex_unlock(&pwrpriv->mutex_lock);
goto error_exit;
}
@@ -113,7 +113,7 @@ static int rtw_hw_resume(struct adapter *padapter)
pwrpriv->rf_pwrstate = rf_on;
pwrpriv->bips_processing = false;
- _exit_pwrlock(&pwrpriv->lock);
+ mutex_unlock(&pwrpriv->mutex_lock);
return 0;
@@ -138,7 +138,7 @@ void ips_enter(struct adapter *padapter)
return;
}
- _enter_pwrlock(&pwrpriv->lock);
+ mutex_lock(&pwrpriv->mutex_lock);
pwrpriv->bips_processing = true;
@@ -159,7 +159,7 @@ void ips_enter(struct adapter *padapter)
}
pwrpriv->bips_processing = false;
- _exit_pwrlock(&pwrpriv->lock);
+ mutex_unlock(&pwrpriv->mutex_lock);
}
int ips_leave(struct adapter *padapter)
@@ -171,7 +171,7 @@ int ips_leave(struct adapter *padapter)
int keyid;
- _enter_pwrlock(&pwrpriv->lock);
+ mutex_lock(&pwrpriv->mutex_lock);
if ((pwrpriv->rf_pwrstate == rf_off) && (!pwrpriv->bips_processing)) {
pwrpriv->bips_processing = true;
@@ -205,7 +205,7 @@ int ips_leave(struct adapter *padapter)
pwrpriv->bpower_saving = false;
}
- _exit_pwrlock(&pwrpriv->lock);
+ mutex_unlock(&pwrpriv->mutex_lock);
return result;
}
@@ -504,7 +504,7 @@ void rtw_init_pwrctrl_priv(struct adapter *padapter)
{
struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv;
- _init_pwrlock(&pwrctrlpriv->lock);
+ mutex_init(&pwrctrlpriv->mutex_lock);
pwrctrlpriv->rf_pwrstate = rf_on;
pwrctrlpriv->ips_enter_cnts = 0;
pwrctrlpriv->ips_leave_cnts = 0;
diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h b/drivers/staging/rtl8188eu/include/osdep_service.h
index 5475956..c53c9ea 100644
--- a/drivers/staging/rtl8188eu/include/osdep_service.h
+++ b/drivers/staging/rtl8188eu/include/osdep_service.h
@@ -36,6 +36,7 @@
#include <linux/atomic.h>
#include <linux/io.h>
#include <linux/semaphore.h>
+#include <linux/mutex.h>
#include <linux/sem.h>
#include <linux/sched.h>
#include <linux/etherdevice.h>
@@ -78,8 +79,6 @@ u8 *_rtw_malloc(u32 sz);
void *rtw_malloc2d(int h, int w, int size);
-u32 _rtw_down_sema(struct semaphore *sema);
-
void _rtw_init_queue(struct __queue *pqueue);
struct rtw_netdev_priv_indicator {
diff --git a/drivers/staging/rtl8188eu/include/rtw_event.h b/drivers/staging/rtl8188eu/include/rtw_event.h
index 5c34e56..0dc63f2 100644
--- a/drivers/staging/rtl8188eu/include/rtw_event.h
+++ b/drivers/staging/rtl8188eu/include/rtw_event.h
@@ -19,6 +19,7 @@
#include <wlan_bssdef.h>
#include <linux/semaphore.h>
+#include <linux/mutex.h>
#include <linux/sem.h>
/*
diff --git a/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h b/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h
index 9680e2e..18a9e74 100644
--- a/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h
+++ b/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h
@@ -92,21 +92,6 @@ struct reportpwrstate_parm {
unsigned short rsvd;
};
-static inline void _init_pwrlock(struct semaphore *plock)
-{
- sema_init(plock, 1);
-}
-
-static inline void _enter_pwrlock(struct semaphore *plock)
-{
- _rtw_down_sema(plock);
-}
-
-static inline void _exit_pwrlock(struct semaphore *plock)
-{
- up(plock);
-}
-
#define LPS_DELAY_TIME 1*HZ /* 1 sec */
#define EXE_PWR_NONE 0x01
@@ -157,7 +142,7 @@ enum { /* for ips_mode */
};
struct pwrctrl_priv {
- struct semaphore lock;
+ struct mutex mutex_lock;
volatile u8 rpwm; /* requested power state for fw */
volatile u8 cpwm; /* fw current power state. updated when
* 1. read from HCPWM 2. driver lowers power level */
diff --git a/drivers/staging/rtl8188eu/os_dep/osdep_service.c b/drivers/staging/rtl8188eu/os_dep/osdep_service.c
index 764250b..24d1774 100644
--- a/drivers/staging/rtl8188eu/os_dep/osdep_service.c
+++ b/drivers/staging/rtl8188eu/os_dep/osdep_service.c
@@ -55,13 +55,6 @@ void *rtw_malloc2d(int h, int w, int size)
return a;
}
-u32 _rtw_down_sema(struct semaphore *sema)
-{
- if (down_interruptible(sema))
- return _FAIL;
- return _SUCCESS;
-}
-
void _rtw_init_queue(struct __queue *pqueue)
{
INIT_LIST_HEAD(&(pqueue->queue));
diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
index 11d51a3..a5ba1e4 100644
--- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
+++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
@@ -238,7 +238,7 @@ static int rtw_suspend(struct usb_interface *pusb_intf, pm_message_t message)
rtw_cancel_all_timer(padapter);
LeaveAllPowerSaveMode(padapter);
- _enter_pwrlock(&pwrpriv->lock);
+ mutex_lock(&pwrpriv->mutex_lock);
/* s1. */
if (pnetdev) {
netif_carrier_off(pnetdev);
@@ -267,7 +267,7 @@ static int rtw_suspend(struct usb_interface *pusb_intf, pm_message_t message)
rtw_free_network_queue(padapter, true);
rtw_dev_unload(padapter);
- _exit_pwrlock(&pwrpriv->lock);
+ mutex_unlock(&pwrpriv->mutex_lock);
if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY))
rtw_indicate_scan_done(padapter, 1);
@@ -298,7 +298,7 @@ static int rtw_resume_process(struct adapter *padapter)
goto exit;
}
- _enter_pwrlock(&pwrpriv->lock);
+ mutex_lock(&pwrpriv->mutex_lock);
rtw_reset_drv_sw(padapter);
pwrpriv->bkeepfwalive = false;
@@ -309,7 +309,7 @@ static int rtw_resume_process(struct adapter *padapter)
netif_device_attach(pnetdev);
netif_carrier_on(pnetdev);
- _exit_pwrlock(&pwrpriv->lock);
+ mutex_unlock(&pwrpriv->mutex_lock);
rtw_roaming(padapter, NULL);
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 4/4] rtl8188eu: Remove unused semaphores
2016-06-03 9:58 [PATCH 0/4] *** rtl8188eu: Replace semaphores with mutexes or completions *** Binoy Jayan
` (2 preceding siblings ...)
2016-06-03 9:59 ` [PATCH 3/4] rtl8188eu: pwrctrl_priv: Replace semaphore 'lock' with mutex Binoy Jayan
@ 2016-06-03 9:59 ` Binoy Jayan
2016-06-03 10:06 ` [PATCH 0/4] *** rtl8188eu: Replace semaphores with mutexes or completions *** Arnd Bergmann
` (2 subsequent siblings)
6 siblings, 0 replies; 17+ messages in thread
From: Binoy Jayan @ 2016-06-03 9:59 UTC (permalink / raw)
To: Greg Kroah-Hartman, Larry Finger
Cc: Jakub Sitnicki, Arnd Bergmann, driverdev-devel, linux-kernel,
Binoy Jayan
The semaphores xmit_sema, terminate_xmitthread_sema and tx_retevt
have no users, hence remove all references to them.
Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>
---
This patch depends on the following patch:
rtl8188eu: pwrctrl_priv: Replace semaphore 'lock' with mutex
drivers/staging/rtl8188eu/core/rtw_xmit.c | 4 ----
drivers/staging/rtl8188eu/include/osdep_service.h | 1 -
drivers/staging/rtl8188eu/include/rtw_event.h | 1 -
drivers/staging/rtl8188eu/include/rtw_xmit.h | 3 ---
4 files changed, 9 deletions(-)
diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c
index e0a5567..1e1b6d8 100644
--- a/drivers/staging/rtl8188eu/core/rtw_xmit.c
+++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c
@@ -57,8 +57,6 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
/* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */
spin_lock_init(&pxmitpriv->lock);
- sema_init(&pxmitpriv->xmit_sema, 0);
- sema_init(&pxmitpriv->terminate_xmitthread_sema, 0);
/*
Please insert all the queue initializaiton using _rtw_init_queue below
@@ -199,8 +197,6 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
pxmitpriv->txirp_cnt = 1;
- sema_init(&(pxmitpriv->tx_retevt), 0);
-
/* per AC pending irp */
pxmitpriv->beq_cnt = 0;
pxmitpriv->bkq_cnt = 0;
diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h b/drivers/staging/rtl8188eu/include/osdep_service.h
index c53c9ea..6f6a8f8 100644
--- a/drivers/staging/rtl8188eu/include/osdep_service.h
+++ b/drivers/staging/rtl8188eu/include/osdep_service.h
@@ -35,7 +35,6 @@
#include <asm/byteorder.h>
#include <linux/atomic.h>
#include <linux/io.h>
-#include <linux/semaphore.h>
#include <linux/mutex.h>
#include <linux/sem.h>
#include <linux/sched.h>
diff --git a/drivers/staging/rtl8188eu/include/rtw_event.h b/drivers/staging/rtl8188eu/include/rtw_event.h
index 0dc63f2..2a45581 100644
--- a/drivers/staging/rtl8188eu/include/rtw_event.h
+++ b/drivers/staging/rtl8188eu/include/rtw_event.h
@@ -18,7 +18,6 @@
#include <osdep_service.h>
#include <wlan_bssdef.h>
-#include <linux/semaphore.h>
#include <linux/mutex.h>
#include <linux/sem.h>
diff --git a/drivers/staging/rtl8188eu/include/rtw_xmit.h b/drivers/staging/rtl8188eu/include/rtw_xmit.h
index a0853ba..7895008 100644
--- a/drivers/staging/rtl8188eu/include/rtw_xmit.h
+++ b/drivers/staging/rtl8188eu/include/rtw_xmit.h
@@ -263,8 +263,6 @@ struct agg_pkt_info {
struct xmit_priv {
spinlock_t lock;
- struct semaphore xmit_sema;
- struct semaphore terminate_xmitthread_sema;
struct __queue be_pending;
struct __queue bk_pending;
struct __queue vi_pending;
@@ -289,7 +287,6 @@ struct xmit_priv {
u8 wmm_para_seq[4];/* sequence for wmm ac parameter strength
* from large to small. it's value is 0->vo,
* 1->vi, 2->be, 3->bk. */
- struct semaphore tx_retevt;/* all tx return event; */
u8 txirp_cnt;/* */
struct tasklet_struct xmit_tasklet;
/* per AC pending irp */
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH 0/4] *** rtl8188eu: Replace semaphores with mutexes or completions ***
2016-06-03 9:58 [PATCH 0/4] *** rtl8188eu: Replace semaphores with mutexes or completions *** Binoy Jayan
` (3 preceding siblings ...)
2016-06-03 9:59 ` [PATCH 4/4] rtl8188eu: Remove unused semaphores Binoy Jayan
@ 2016-06-03 10:06 ` Arnd Bergmann
2016-06-06 4:38 ` [PATCH v2 " Binoy Jayan
2016-06-06 5:13 ` [PATCH v3 0/4] *** staging: r8188eu: Replace semaphores with mutexes or completions *** Binoy Jayan
6 siblings, 0 replies; 17+ messages in thread
From: Arnd Bergmann @ 2016-06-03 10:06 UTC (permalink / raw)
To: Binoy Jayan
Cc: Greg Kroah-Hartman, Larry Finger, Jakub Sitnicki, driverdev-devel,
linux-kernel
On Friday, June 3, 2016 3:28:59 PM CEST Binoy Jayan wrote:
>
> These are a set of patches which removes semaphores from:
>
> drivers/staging/rtl8188eu
>
> These are part of a bigger effort to eliminate all semaphores
> from the linux kernel.
>
> They build correctly (individually and as a whole).
> NB: I have not tested this as I do not have the following hardware:
>
> "Realtek RTL8188EU Wireless LAN NIC driver"
>
>
The patches all look good to me. Patch three again could use some
information describing that it replaces an interruptible semaphore
with an uninterruptible mutex, fixing a bug in the process.
BTW, there is no need to list the dependencies in each patch
when posting a series, as the default assumption is that they
need to be applied in sequence.
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 1/4] irtl8188eu: Replace semaphore cmd_queue_sema with completion
2016-06-03 9:59 ` [PATCH 1/4] irtl8188eu: Replace semaphore cmd_queue_sema with completion Binoy Jayan
@ 2016-06-05 16:31 ` Larry Finger
0 siblings, 0 replies; 17+ messages in thread
From: Larry Finger @ 2016-06-05 16:31 UTC (permalink / raw)
To: Binoy Jayan, Greg Kroah-Hartman
Cc: Jakub Sitnicki, Arnd Bergmann, driverdev-devel, linux-kernel
On 06/03/2016 04:59 AM, Binoy Jayan wrote:
> The semaphore 'cmd_queue_sema' is used as completion,
> so convert it to struct completion.
>
> Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>
The subject for this patch has a misplaced "i" at the beginning courtesy of vi.
One other point, it is customary to start the patch subject with "staging:
rtl8188eu: ..." for drivers in staging. I also prefer using r8188eu rather than
rtl8188eu as the former is the actual name of the driver, but either will work.
I have tested all 4 of these patches with no problems, thus
Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
As you may have noted, my testing of the modified driver has resulted in some
additional fixes for various problems including a system panic caused by an
ill-advised and untested change.
Larry
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v2 0/4] *** rtl8188eu: Replace semaphores with mutexes or completions ***
2016-06-03 9:58 [PATCH 0/4] *** rtl8188eu: Replace semaphores with mutexes or completions *** Binoy Jayan
` (4 preceding siblings ...)
2016-06-03 10:06 ` [PATCH 0/4] *** rtl8188eu: Replace semaphores with mutexes or completions *** Arnd Bergmann
@ 2016-06-06 4:38 ` Binoy Jayan
2016-06-06 4:38 ` [PATCH v2 1/4] irtl8188eu: Replace semaphore cmd_queue_sema with completion Binoy Jayan
` (3 more replies)
2016-06-06 5:13 ` [PATCH v3 0/4] *** staging: r8188eu: Replace semaphores with mutexes or completions *** Binoy Jayan
6 siblings, 4 replies; 17+ messages in thread
From: Binoy Jayan @ 2016-06-06 4:38 UTC (permalink / raw)
To: Greg Kroah-Hartman, Larry Finger
Cc: Jakub Sitnicki, Arnd Bergmann, driverdev-devel, linux-kernel,
Binoy Jayan
Hi,
These are a set of patches [v2] which removes semaphores from:
drivers/staging/rtl8188eu
These are part of a bigger effort to eliminate all semaphores
from the linux kernel.
They build correctly (individually and as a whole).
NB: I have not tested this as I do not have the following hardware:
"Realtek RTL8188EU Wireless LAN NIC driver"
Incorporated changes w.r.t. review comments:
- Changed changelog in patch 3/4
Thanks,
Binoy
Binoy Jayan (4):
irtl8188eu: Replace semaphore cmd_queue_sema with completion
rtl8188eu: Replace semaphore terminate_cmdthread_sema with completion
rtl8188eu: pwrctrl_priv: Replace semaphore 'lock' with mutex
rtl8188eu: Remove unused semaphores
drivers/staging/rtl8188eu/core/rtw_cmd.c | 12 ++++++------
drivers/staging/rtl8188eu/core/rtw_pwrctrl.c | 20 ++++++++++----------
drivers/staging/rtl8188eu/core/rtw_xmit.c | 4 ----
drivers/staging/rtl8188eu/include/osdep_service.h | 4 +---
drivers/staging/rtl8188eu/include/rtw_cmd.h | 4 ++--
drivers/staging/rtl8188eu/include/rtw_event.h | 2 +-
drivers/staging/rtl8188eu/include/rtw_pwrctrl.h | 17 +----------------
drivers/staging/rtl8188eu/include/rtw_xmit.h | 3 ---
drivers/staging/rtl8188eu/os_dep/os_intfs.c | 6 +++---
drivers/staging/rtl8188eu/os_dep/osdep_service.c | 7 -------
drivers/staging/rtl8188eu/os_dep/usb_intf.c | 8 ++++----
11 files changed, 28 insertions(+), 59 deletions(-)
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v2 1/4] irtl8188eu: Replace semaphore cmd_queue_sema with completion
2016-06-06 4:38 ` [PATCH v2 " Binoy Jayan
@ 2016-06-06 4:38 ` Binoy Jayan
2016-06-06 4:38 ` [PATCH v2 2/4] rtl8188eu: Replace semaphore terminate_cmdthread_sema " Binoy Jayan
` (2 subsequent siblings)
3 siblings, 0 replies; 17+ messages in thread
From: Binoy Jayan @ 2016-06-06 4:38 UTC (permalink / raw)
To: Greg Kroah-Hartman, Larry Finger
Cc: Jakub Sitnicki, Arnd Bergmann, driverdev-devel, linux-kernel,
Binoy Jayan
The semaphore 'cmd_queue_sema' is used as completion,
so convert it to struct completion.
Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/staging/rtl8188eu/core/rtw_cmd.c | 6 +++---
drivers/staging/rtl8188eu/include/rtw_cmd.h | 2 +-
drivers/staging/rtl8188eu/os_dep/os_intfs.c | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c b/drivers/staging/rtl8188eu/core/rtw_cmd.c
index 7748523..a2937e7 100644
--- a/drivers/staging/rtl8188eu/core/rtw_cmd.c
+++ b/drivers/staging/rtl8188eu/core/rtw_cmd.c
@@ -27,7 +27,7 @@ No irqsave is necessary.
int rtw_init_cmd_priv(struct cmd_priv *pcmdpriv)
{
- sema_init(&(pcmdpriv->cmd_queue_sema), 0);
+ init_completion(&pcmdpriv->cmd_queue_comp);
sema_init(&(pcmdpriv->terminate_cmdthread_sema), 0);
_rtw_init_queue(&(pcmdpriv->cmd_queue));
@@ -122,7 +122,7 @@ u32 rtw_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj)
res = _rtw_enqueue_cmd(&pcmdpriv->cmd_queue, cmd_obj);
if (res == _SUCCESS)
- up(&pcmdpriv->cmd_queue_sema);
+ complete(&pcmdpriv->cmd_queue_comp);
exit:
@@ -167,7 +167,7 @@ int rtw_cmd_thread(void *context)
RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("start r871x rtw_cmd_thread !!!!\n"));
while (1) {
- if (_rtw_down_sema(&pcmdpriv->cmd_queue_sema) == _FAIL)
+ if (wait_for_completion_interruptible(&pcmdpriv->cmd_queue_comp))
break;
if (padapter->bDriverStopped ||
diff --git a/drivers/staging/rtl8188eu/include/rtw_cmd.h b/drivers/staging/rtl8188eu/include/rtw_cmd.h
index 08ca592..3532dd1 100644
--- a/drivers/staging/rtl8188eu/include/rtw_cmd.h
+++ b/drivers/staging/rtl8188eu/include/rtw_cmd.h
@@ -39,7 +39,7 @@ struct cmd_obj {
};
struct cmd_priv {
- struct semaphore cmd_queue_sema;
+ struct completion cmd_queue_comp;
struct semaphore terminate_cmdthread_sema;
struct __queue cmd_queue;
u8 cmdthd_running;
diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c
index ae2caff..a696d2b 100644
--- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c
+++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c
@@ -772,7 +772,7 @@ void rtw_stop_drv_threads(struct adapter *padapter)
RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_stop_drv_threads\n"));
/* Below is to terminate rtw_cmd_thread & event_thread... */
- up(&padapter->cmdpriv.cmd_queue_sema);
+ complete(&padapter->cmdpriv.cmd_queue_comp);
if (padapter->cmdThread)
_rtw_down_sema(&padapter->cmdpriv.terminate_cmdthread_sema);
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 2/4] rtl8188eu: Replace semaphore terminate_cmdthread_sema with completion
2016-06-06 4:38 ` [PATCH v2 " Binoy Jayan
2016-06-06 4:38 ` [PATCH v2 1/4] irtl8188eu: Replace semaphore cmd_queue_sema with completion Binoy Jayan
@ 2016-06-06 4:38 ` Binoy Jayan
2016-06-06 4:38 ` [PATCH v2 3/4] rtl8188eu: pwrctrl_priv: Replace semaphore 'lock' with mutex Binoy Jayan
2016-06-06 4:38 ` [PATCH v2 4/4] rtl8188eu: Remove unused semaphores Binoy Jayan
3 siblings, 0 replies; 17+ messages in thread
From: Binoy Jayan @ 2016-06-06 4:38 UTC (permalink / raw)
To: Greg Kroah-Hartman, Larry Finger
Cc: Jakub Sitnicki, Arnd Bergmann, driverdev-devel, linux-kernel,
Binoy Jayan
The semaphore 'terminate_cmdthread_sema' is used as completion,
so convert it to struct completion.
Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/staging/rtl8188eu/core/rtw_cmd.c | 6 +++---
drivers/staging/rtl8188eu/include/rtw_cmd.h | 2 +-
drivers/staging/rtl8188eu/os_dep/os_intfs.c | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c b/drivers/staging/rtl8188eu/core/rtw_cmd.c
index a2937e7..9e12588 100644
--- a/drivers/staging/rtl8188eu/core/rtw_cmd.c
+++ b/drivers/staging/rtl8188eu/core/rtw_cmd.c
@@ -28,7 +28,7 @@ No irqsave is necessary.
int rtw_init_cmd_priv(struct cmd_priv *pcmdpriv)
{
init_completion(&pcmdpriv->cmd_queue_comp);
- sema_init(&(pcmdpriv->terminate_cmdthread_sema), 0);
+ init_completion(&pcmdpriv->terminate_cmdthread_comp);
_rtw_init_queue(&(pcmdpriv->cmd_queue));
return _SUCCESS;
@@ -162,7 +162,7 @@ int rtw_cmd_thread(void *context)
allow_signal(SIGTERM);
pcmdpriv->cmdthd_running = true;
- up(&pcmdpriv->terminate_cmdthread_sema);
+ complete(&pcmdpriv->terminate_cmdthread_comp);
RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("start r871x rtw_cmd_thread !!!!\n"));
@@ -234,7 +234,7 @@ _next:
rtw_free_cmd_obj(pcmd);
}
- up(&pcmdpriv->terminate_cmdthread_sema);
+ complete(&pcmdpriv->terminate_cmdthread_comp);
complete_and_exit(NULL, 0);
diff --git a/drivers/staging/rtl8188eu/include/rtw_cmd.h b/drivers/staging/rtl8188eu/include/rtw_cmd.h
index 3532dd1..2b53f58 100644
--- a/drivers/staging/rtl8188eu/include/rtw_cmd.h
+++ b/drivers/staging/rtl8188eu/include/rtw_cmd.h
@@ -40,7 +40,7 @@ struct cmd_obj {
struct cmd_priv {
struct completion cmd_queue_comp;
- struct semaphore terminate_cmdthread_sema;
+ struct completion terminate_cmdthread_comp;
struct __queue cmd_queue;
u8 cmdthd_running;
struct adapter *padapter;
diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c
index a696d2b..c494845 100644
--- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c
+++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c
@@ -762,7 +762,7 @@ static int rtw_start_drv_threads(struct adapter *padapter)
err = PTR_ERR(padapter->cmdThread);
else
/* wait for cmd_thread to run */
- _rtw_down_sema(&padapter->cmdpriv.terminate_cmdthread_sema);
+ wait_for_completion_interruptible(&padapter->cmdpriv.terminate_cmdthread_comp);
return err;
}
@@ -774,7 +774,7 @@ void rtw_stop_drv_threads(struct adapter *padapter)
/* Below is to terminate rtw_cmd_thread & event_thread... */
complete(&padapter->cmdpriv.cmd_queue_comp);
if (padapter->cmdThread)
- _rtw_down_sema(&padapter->cmdpriv.terminate_cmdthread_sema);
+ wait_for_completion_interruptible(&padapter->cmdpriv.terminate_cmdthread_comp);
}
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 3/4] rtl8188eu: pwrctrl_priv: Replace semaphore 'lock' with mutex
2016-06-06 4:38 ` [PATCH v2 " Binoy Jayan
2016-06-06 4:38 ` [PATCH v2 1/4] irtl8188eu: Replace semaphore cmd_queue_sema with completion Binoy Jayan
2016-06-06 4:38 ` [PATCH v2 2/4] rtl8188eu: Replace semaphore terminate_cmdthread_sema " Binoy Jayan
@ 2016-06-06 4:38 ` Binoy Jayan
2016-06-06 4:38 ` [PATCH v2 4/4] rtl8188eu: Remove unused semaphores Binoy Jayan
3 siblings, 0 replies; 17+ messages in thread
From: Binoy Jayan @ 2016-06-06 4:38 UTC (permalink / raw)
To: Greg Kroah-Hartman, Larry Finger
Cc: Jakub Sitnicki, Arnd Bergmann, driverdev-devel, linux-kernel,
Binoy Jayan
The semaphore 'lock' in pwrctrl_priv is a simple mutex, so it should
be written as one. Semaphores are going away in the future.
_enter_pwrlock was using down_interruptible(), so the lock could be broken
by sending a signal. This could be a bug, because nothing checks the return
code here. Hence, using mutex_lock instead of the interruptible version.
Also, remove the now unused wrappers _init_pwrlock, _enter_pwrlock,
_exit_pwrlock and _rtw_down_sema.
Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/staging/rtl8188eu/core/rtw_pwrctrl.c | 20 ++++++++++----------
drivers/staging/rtl8188eu/include/osdep_service.h | 3 +--
drivers/staging/rtl8188eu/include/rtw_event.h | 1 +
drivers/staging/rtl8188eu/include/rtw_pwrctrl.h | 17 +----------------
drivers/staging/rtl8188eu/os_dep/osdep_service.c | 7 -------
drivers/staging/rtl8188eu/os_dep/usb_intf.c | 8 ++++----
6 files changed, 17 insertions(+), 39 deletions(-)
diff --git a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c
index 59c6d8a..0b70fe7 100644
--- a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c
+++ b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c
@@ -38,7 +38,7 @@ static int rtw_hw_suspend(struct adapter *padapter)
LeaveAllPowerSaveMode(padapter);
DBG_88E("==> rtw_hw_suspend\n");
- _enter_pwrlock(&pwrpriv->lock);
+ mutex_lock(&pwrpriv->mutex_lock);
pwrpriv->bips_processing = true;
/* s1. */
if (pnetdev) {
@@ -73,7 +73,7 @@ static int rtw_hw_suspend(struct adapter *padapter)
pwrpriv->rf_pwrstate = rf_off;
pwrpriv->bips_processing = false;
- _exit_pwrlock(&pwrpriv->lock);
+ mutex_unlock(&pwrpriv->mutex_lock);
return 0;
@@ -90,12 +90,12 @@ static int rtw_hw_resume(struct adapter *padapter)
/* system resume */
DBG_88E("==> rtw_hw_resume\n");
- _enter_pwrlock(&pwrpriv->lock);
+ mutex_lock(&pwrpriv->mutex_lock);
pwrpriv->bips_processing = true;
rtw_reset_drv_sw(padapter);
if (pm_netdev_open(pnetdev, false) != 0) {
- _exit_pwrlock(&pwrpriv->lock);
+ mutex_unlock(&pwrpriv->mutex_lock);
goto error_exit;
}
@@ -113,7 +113,7 @@ static int rtw_hw_resume(struct adapter *padapter)
pwrpriv->rf_pwrstate = rf_on;
pwrpriv->bips_processing = false;
- _exit_pwrlock(&pwrpriv->lock);
+ mutex_unlock(&pwrpriv->mutex_lock);
return 0;
@@ -138,7 +138,7 @@ void ips_enter(struct adapter *padapter)
return;
}
- _enter_pwrlock(&pwrpriv->lock);
+ mutex_lock(&pwrpriv->mutex_lock);
pwrpriv->bips_processing = true;
@@ -159,7 +159,7 @@ void ips_enter(struct adapter *padapter)
}
pwrpriv->bips_processing = false;
- _exit_pwrlock(&pwrpriv->lock);
+ mutex_unlock(&pwrpriv->mutex_lock);
}
int ips_leave(struct adapter *padapter)
@@ -171,7 +171,7 @@ int ips_leave(struct adapter *padapter)
int keyid;
- _enter_pwrlock(&pwrpriv->lock);
+ mutex_lock(&pwrpriv->mutex_lock);
if ((pwrpriv->rf_pwrstate == rf_off) && (!pwrpriv->bips_processing)) {
pwrpriv->bips_processing = true;
@@ -205,7 +205,7 @@ int ips_leave(struct adapter *padapter)
pwrpriv->bpower_saving = false;
}
- _exit_pwrlock(&pwrpriv->lock);
+ mutex_unlock(&pwrpriv->mutex_lock);
return result;
}
@@ -504,7 +504,7 @@ void rtw_init_pwrctrl_priv(struct adapter *padapter)
{
struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv;
- _init_pwrlock(&pwrctrlpriv->lock);
+ mutex_init(&pwrctrlpriv->mutex_lock);
pwrctrlpriv->rf_pwrstate = rf_on;
pwrctrlpriv->ips_enter_cnts = 0;
pwrctrlpriv->ips_leave_cnts = 0;
diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h b/drivers/staging/rtl8188eu/include/osdep_service.h
index 5475956..c53c9ea 100644
--- a/drivers/staging/rtl8188eu/include/osdep_service.h
+++ b/drivers/staging/rtl8188eu/include/osdep_service.h
@@ -36,6 +36,7 @@
#include <linux/atomic.h>
#include <linux/io.h>
#include <linux/semaphore.h>
+#include <linux/mutex.h>
#include <linux/sem.h>
#include <linux/sched.h>
#include <linux/etherdevice.h>
@@ -78,8 +79,6 @@ u8 *_rtw_malloc(u32 sz);
void *rtw_malloc2d(int h, int w, int size);
-u32 _rtw_down_sema(struct semaphore *sema);
-
void _rtw_init_queue(struct __queue *pqueue);
struct rtw_netdev_priv_indicator {
diff --git a/drivers/staging/rtl8188eu/include/rtw_event.h b/drivers/staging/rtl8188eu/include/rtw_event.h
index 5c34e56..0dc63f2 100644
--- a/drivers/staging/rtl8188eu/include/rtw_event.h
+++ b/drivers/staging/rtl8188eu/include/rtw_event.h
@@ -19,6 +19,7 @@
#include <wlan_bssdef.h>
#include <linux/semaphore.h>
+#include <linux/mutex.h>
#include <linux/sem.h>
/*
diff --git a/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h b/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h
index 9680e2e..18a9e74 100644
--- a/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h
+++ b/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h
@@ -92,21 +92,6 @@ struct reportpwrstate_parm {
unsigned short rsvd;
};
-static inline void _init_pwrlock(struct semaphore *plock)
-{
- sema_init(plock, 1);
-}
-
-static inline void _enter_pwrlock(struct semaphore *plock)
-{
- _rtw_down_sema(plock);
-}
-
-static inline void _exit_pwrlock(struct semaphore *plock)
-{
- up(plock);
-}
-
#define LPS_DELAY_TIME 1*HZ /* 1 sec */
#define EXE_PWR_NONE 0x01
@@ -157,7 +142,7 @@ enum { /* for ips_mode */
};
struct pwrctrl_priv {
- struct semaphore lock;
+ struct mutex mutex_lock;
volatile u8 rpwm; /* requested power state for fw */
volatile u8 cpwm; /* fw current power state. updated when
* 1. read from HCPWM 2. driver lowers power level */
diff --git a/drivers/staging/rtl8188eu/os_dep/osdep_service.c b/drivers/staging/rtl8188eu/os_dep/osdep_service.c
index 764250b..24d1774 100644
--- a/drivers/staging/rtl8188eu/os_dep/osdep_service.c
+++ b/drivers/staging/rtl8188eu/os_dep/osdep_service.c
@@ -55,13 +55,6 @@ void *rtw_malloc2d(int h, int w, int size)
return a;
}
-u32 _rtw_down_sema(struct semaphore *sema)
-{
- if (down_interruptible(sema))
- return _FAIL;
- return _SUCCESS;
-}
-
void _rtw_init_queue(struct __queue *pqueue)
{
INIT_LIST_HEAD(&(pqueue->queue));
diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
index 11d51a3..a5ba1e4 100644
--- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
+++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
@@ -238,7 +238,7 @@ static int rtw_suspend(struct usb_interface *pusb_intf, pm_message_t message)
rtw_cancel_all_timer(padapter);
LeaveAllPowerSaveMode(padapter);
- _enter_pwrlock(&pwrpriv->lock);
+ mutex_lock(&pwrpriv->mutex_lock);
/* s1. */
if (pnetdev) {
netif_carrier_off(pnetdev);
@@ -267,7 +267,7 @@ static int rtw_suspend(struct usb_interface *pusb_intf, pm_message_t message)
rtw_free_network_queue(padapter, true);
rtw_dev_unload(padapter);
- _exit_pwrlock(&pwrpriv->lock);
+ mutex_unlock(&pwrpriv->mutex_lock);
if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY))
rtw_indicate_scan_done(padapter, 1);
@@ -298,7 +298,7 @@ static int rtw_resume_process(struct adapter *padapter)
goto exit;
}
- _enter_pwrlock(&pwrpriv->lock);
+ mutex_lock(&pwrpriv->mutex_lock);
rtw_reset_drv_sw(padapter);
pwrpriv->bkeepfwalive = false;
@@ -309,7 +309,7 @@ static int rtw_resume_process(struct adapter *padapter)
netif_device_attach(pnetdev);
netif_carrier_on(pnetdev);
- _exit_pwrlock(&pwrpriv->lock);
+ mutex_unlock(&pwrpriv->mutex_lock);
rtw_roaming(padapter, NULL);
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 4/4] rtl8188eu: Remove unused semaphores
2016-06-06 4:38 ` [PATCH v2 " Binoy Jayan
` (2 preceding siblings ...)
2016-06-06 4:38 ` [PATCH v2 3/4] rtl8188eu: pwrctrl_priv: Replace semaphore 'lock' with mutex Binoy Jayan
@ 2016-06-06 4:38 ` Binoy Jayan
3 siblings, 0 replies; 17+ messages in thread
From: Binoy Jayan @ 2016-06-06 4:38 UTC (permalink / raw)
To: Greg Kroah-Hartman, Larry Finger
Cc: Jakub Sitnicki, Arnd Bergmann, driverdev-devel, linux-kernel,
Binoy Jayan
The semaphores xmit_sema, terminate_xmitthread_sema and tx_retevt
have no users, hence remove all references to them.
Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/staging/rtl8188eu/core/rtw_xmit.c | 4 ----
drivers/staging/rtl8188eu/include/osdep_service.h | 1 -
drivers/staging/rtl8188eu/include/rtw_event.h | 1 -
drivers/staging/rtl8188eu/include/rtw_xmit.h | 3 ---
4 files changed, 9 deletions(-)
diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c
index e0a5567..1e1b6d8 100644
--- a/drivers/staging/rtl8188eu/core/rtw_xmit.c
+++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c
@@ -57,8 +57,6 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
/* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */
spin_lock_init(&pxmitpriv->lock);
- sema_init(&pxmitpriv->xmit_sema, 0);
- sema_init(&pxmitpriv->terminate_xmitthread_sema, 0);
/*
Please insert all the queue initializaiton using _rtw_init_queue below
@@ -199,8 +197,6 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
pxmitpriv->txirp_cnt = 1;
- sema_init(&(pxmitpriv->tx_retevt), 0);
-
/* per AC pending irp */
pxmitpriv->beq_cnt = 0;
pxmitpriv->bkq_cnt = 0;
diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h b/drivers/staging/rtl8188eu/include/osdep_service.h
index c53c9ea..6f6a8f8 100644
--- a/drivers/staging/rtl8188eu/include/osdep_service.h
+++ b/drivers/staging/rtl8188eu/include/osdep_service.h
@@ -35,7 +35,6 @@
#include <asm/byteorder.h>
#include <linux/atomic.h>
#include <linux/io.h>
-#include <linux/semaphore.h>
#include <linux/mutex.h>
#include <linux/sem.h>
#include <linux/sched.h>
diff --git a/drivers/staging/rtl8188eu/include/rtw_event.h b/drivers/staging/rtl8188eu/include/rtw_event.h
index 0dc63f2..2a45581 100644
--- a/drivers/staging/rtl8188eu/include/rtw_event.h
+++ b/drivers/staging/rtl8188eu/include/rtw_event.h
@@ -18,7 +18,6 @@
#include <osdep_service.h>
#include <wlan_bssdef.h>
-#include <linux/semaphore.h>
#include <linux/mutex.h>
#include <linux/sem.h>
diff --git a/drivers/staging/rtl8188eu/include/rtw_xmit.h b/drivers/staging/rtl8188eu/include/rtw_xmit.h
index a0853ba..7895008 100644
--- a/drivers/staging/rtl8188eu/include/rtw_xmit.h
+++ b/drivers/staging/rtl8188eu/include/rtw_xmit.h
@@ -263,8 +263,6 @@ struct agg_pkt_info {
struct xmit_priv {
spinlock_t lock;
- struct semaphore xmit_sema;
- struct semaphore terminate_xmitthread_sema;
struct __queue be_pending;
struct __queue bk_pending;
struct __queue vi_pending;
@@ -289,7 +287,6 @@ struct xmit_priv {
u8 wmm_para_seq[4];/* sequence for wmm ac parameter strength
* from large to small. it's value is 0->vo,
* 1->vi, 2->be, 3->bk. */
- struct semaphore tx_retevt;/* all tx return event; */
u8 txirp_cnt;/* */
struct tasklet_struct xmit_tasklet;
/* per AC pending irp */
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v3 0/4] *** staging: r8188eu: Replace semaphores with mutexes or completions ***
2016-06-03 9:58 [PATCH 0/4] *** rtl8188eu: Replace semaphores with mutexes or completions *** Binoy Jayan
` (5 preceding siblings ...)
2016-06-06 4:38 ` [PATCH v2 " Binoy Jayan
@ 2016-06-06 5:13 ` Binoy Jayan
2016-06-06 5:13 ` [PATCH v3 1/4] staging: r8188eu: Replace semaphore cmd_queue_sema with completion Binoy Jayan
` (3 more replies)
6 siblings, 4 replies; 17+ messages in thread
From: Binoy Jayan @ 2016-06-06 5:13 UTC (permalink / raw)
To: Greg Kroah-Hartman, Larry Finger
Cc: Jakub Sitnicki, Arnd Bergmann, driverdev-devel, linux-kernel,
Binoy Jayan
Hi,
These are a set of patches [v3] which removes semaphores from:
drivers/staging/rtl8188eu
These are part of a bigger effort to eliminate all semaphores
from the linux kernel.
They build correctly (individually and as a whole).
NB: I have not tested this as I do not have the following hardware:
"Realtek RTL8188EU Wireless LAN NIC driver"
Incorporated changes w.r.t. review comments
- Changed changelog in patch 3/4
- Changed subject line to have driver name r8188eu
- Removed misplaced 'i' in subject of patch 1/4
Thanks,
Binoy
Binoy Jayan (4):
staging: r8188eu: Replace semaphore cmd_queue_sema with completion
staging: r8188eu: Replace semaphore terminate_cmdthread_sema with
completion
staging: r8188eu: pwrctrl_priv: Replace semaphore 'lock' with mutex
staging: r8188eu: Remove unused semaphores
drivers/staging/rtl8188eu/core/rtw_cmd.c | 12 ++++++------
drivers/staging/rtl8188eu/core/rtw_pwrctrl.c | 20 ++++++++++----------
drivers/staging/rtl8188eu/core/rtw_xmit.c | 4 ----
drivers/staging/rtl8188eu/include/osdep_service.h | 4 +---
drivers/staging/rtl8188eu/include/rtw_cmd.h | 4 ++--
drivers/staging/rtl8188eu/include/rtw_event.h | 2 +-
drivers/staging/rtl8188eu/include/rtw_pwrctrl.h | 17 +----------------
drivers/staging/rtl8188eu/include/rtw_xmit.h | 3 ---
drivers/staging/rtl8188eu/os_dep/os_intfs.c | 6 +++---
drivers/staging/rtl8188eu/os_dep/osdep_service.c | 7 -------
drivers/staging/rtl8188eu/os_dep/usb_intf.c | 8 ++++----
11 files changed, 28 insertions(+), 59 deletions(-)
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v3 1/4] staging: r8188eu: Replace semaphore cmd_queue_sema with completion
2016-06-06 5:13 ` [PATCH v3 0/4] *** staging: r8188eu: Replace semaphores with mutexes or completions *** Binoy Jayan
@ 2016-06-06 5:13 ` Binoy Jayan
2016-06-06 5:13 ` [PATCH v3 2/4] staging: r8188eu: Replace semaphore terminate_cmdthread_sema " Binoy Jayan
` (2 subsequent siblings)
3 siblings, 0 replies; 17+ messages in thread
From: Binoy Jayan @ 2016-06-06 5:13 UTC (permalink / raw)
To: Greg Kroah-Hartman, Larry Finger
Cc: Jakub Sitnicki, Arnd Bergmann, driverdev-devel, linux-kernel,
Binoy Jayan
The semaphore 'cmd_queue_sema' is used as completion,
so convert it to struct completion.
Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
---
drivers/staging/rtl8188eu/core/rtw_cmd.c | 6 +++---
drivers/staging/rtl8188eu/include/rtw_cmd.h | 2 +-
drivers/staging/rtl8188eu/os_dep/os_intfs.c | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c b/drivers/staging/rtl8188eu/core/rtw_cmd.c
index 7748523..a2937e7 100644
--- a/drivers/staging/rtl8188eu/core/rtw_cmd.c
+++ b/drivers/staging/rtl8188eu/core/rtw_cmd.c
@@ -27,7 +27,7 @@ No irqsave is necessary.
int rtw_init_cmd_priv(struct cmd_priv *pcmdpriv)
{
- sema_init(&(pcmdpriv->cmd_queue_sema), 0);
+ init_completion(&pcmdpriv->cmd_queue_comp);
sema_init(&(pcmdpriv->terminate_cmdthread_sema), 0);
_rtw_init_queue(&(pcmdpriv->cmd_queue));
@@ -122,7 +122,7 @@ u32 rtw_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj)
res = _rtw_enqueue_cmd(&pcmdpriv->cmd_queue, cmd_obj);
if (res == _SUCCESS)
- up(&pcmdpriv->cmd_queue_sema);
+ complete(&pcmdpriv->cmd_queue_comp);
exit:
@@ -167,7 +167,7 @@ int rtw_cmd_thread(void *context)
RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("start r871x rtw_cmd_thread !!!!\n"));
while (1) {
- if (_rtw_down_sema(&pcmdpriv->cmd_queue_sema) == _FAIL)
+ if (wait_for_completion_interruptible(&pcmdpriv->cmd_queue_comp))
break;
if (padapter->bDriverStopped ||
diff --git a/drivers/staging/rtl8188eu/include/rtw_cmd.h b/drivers/staging/rtl8188eu/include/rtw_cmd.h
index 08ca592..3532dd1 100644
--- a/drivers/staging/rtl8188eu/include/rtw_cmd.h
+++ b/drivers/staging/rtl8188eu/include/rtw_cmd.h
@@ -39,7 +39,7 @@ struct cmd_obj {
};
struct cmd_priv {
- struct semaphore cmd_queue_sema;
+ struct completion cmd_queue_comp;
struct semaphore terminate_cmdthread_sema;
struct __queue cmd_queue;
u8 cmdthd_running;
diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c
index ae2caff..a696d2b 100644
--- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c
+++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c
@@ -772,7 +772,7 @@ void rtw_stop_drv_threads(struct adapter *padapter)
RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_stop_drv_threads\n"));
/* Below is to terminate rtw_cmd_thread & event_thread... */
- up(&padapter->cmdpriv.cmd_queue_sema);
+ complete(&padapter->cmdpriv.cmd_queue_comp);
if (padapter->cmdThread)
_rtw_down_sema(&padapter->cmdpriv.terminate_cmdthread_sema);
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v3 2/4] staging: r8188eu: Replace semaphore terminate_cmdthread_sema with completion
2016-06-06 5:13 ` [PATCH v3 0/4] *** staging: r8188eu: Replace semaphores with mutexes or completions *** Binoy Jayan
2016-06-06 5:13 ` [PATCH v3 1/4] staging: r8188eu: Replace semaphore cmd_queue_sema with completion Binoy Jayan
@ 2016-06-06 5:13 ` Binoy Jayan
2016-06-06 5:13 ` [PATCH v3 3/4] staging: r8188eu: pwrctrl_priv: Replace semaphore 'lock' with mutex Binoy Jayan
2016-06-06 5:13 ` [PATCH v3 4/4] staging: r8188eu: Remove unused semaphores Binoy Jayan
3 siblings, 0 replies; 17+ messages in thread
From: Binoy Jayan @ 2016-06-06 5:13 UTC (permalink / raw)
To: Greg Kroah-Hartman, Larry Finger
Cc: Jakub Sitnicki, Arnd Bergmann, driverdev-devel, linux-kernel,
Binoy Jayan
The semaphore 'terminate_cmdthread_sema' is used as completion,
so convert it to struct completion.
Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
---
drivers/staging/rtl8188eu/core/rtw_cmd.c | 6 +++---
drivers/staging/rtl8188eu/include/rtw_cmd.h | 2 +-
drivers/staging/rtl8188eu/os_dep/os_intfs.c | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c b/drivers/staging/rtl8188eu/core/rtw_cmd.c
index a2937e7..9e12588 100644
--- a/drivers/staging/rtl8188eu/core/rtw_cmd.c
+++ b/drivers/staging/rtl8188eu/core/rtw_cmd.c
@@ -28,7 +28,7 @@ No irqsave is necessary.
int rtw_init_cmd_priv(struct cmd_priv *pcmdpriv)
{
init_completion(&pcmdpriv->cmd_queue_comp);
- sema_init(&(pcmdpriv->terminate_cmdthread_sema), 0);
+ init_completion(&pcmdpriv->terminate_cmdthread_comp);
_rtw_init_queue(&(pcmdpriv->cmd_queue));
return _SUCCESS;
@@ -162,7 +162,7 @@ int rtw_cmd_thread(void *context)
allow_signal(SIGTERM);
pcmdpriv->cmdthd_running = true;
- up(&pcmdpriv->terminate_cmdthread_sema);
+ complete(&pcmdpriv->terminate_cmdthread_comp);
RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("start r871x rtw_cmd_thread !!!!\n"));
@@ -234,7 +234,7 @@ _next:
rtw_free_cmd_obj(pcmd);
}
- up(&pcmdpriv->terminate_cmdthread_sema);
+ complete(&pcmdpriv->terminate_cmdthread_comp);
complete_and_exit(NULL, 0);
diff --git a/drivers/staging/rtl8188eu/include/rtw_cmd.h b/drivers/staging/rtl8188eu/include/rtw_cmd.h
index 3532dd1..2b53f58 100644
--- a/drivers/staging/rtl8188eu/include/rtw_cmd.h
+++ b/drivers/staging/rtl8188eu/include/rtw_cmd.h
@@ -40,7 +40,7 @@ struct cmd_obj {
struct cmd_priv {
struct completion cmd_queue_comp;
- struct semaphore terminate_cmdthread_sema;
+ struct completion terminate_cmdthread_comp;
struct __queue cmd_queue;
u8 cmdthd_running;
struct adapter *padapter;
diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c
index a696d2b..c494845 100644
--- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c
+++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c
@@ -762,7 +762,7 @@ static int rtw_start_drv_threads(struct adapter *padapter)
err = PTR_ERR(padapter->cmdThread);
else
/* wait for cmd_thread to run */
- _rtw_down_sema(&padapter->cmdpriv.terminate_cmdthread_sema);
+ wait_for_completion_interruptible(&padapter->cmdpriv.terminate_cmdthread_comp);
return err;
}
@@ -774,7 +774,7 @@ void rtw_stop_drv_threads(struct adapter *padapter)
/* Below is to terminate rtw_cmd_thread & event_thread... */
complete(&padapter->cmdpriv.cmd_queue_comp);
if (padapter->cmdThread)
- _rtw_down_sema(&padapter->cmdpriv.terminate_cmdthread_sema);
+ wait_for_completion_interruptible(&padapter->cmdpriv.terminate_cmdthread_comp);
}
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v3 3/4] staging: r8188eu: pwrctrl_priv: Replace semaphore 'lock' with mutex
2016-06-06 5:13 ` [PATCH v3 0/4] *** staging: r8188eu: Replace semaphores with mutexes or completions *** Binoy Jayan
2016-06-06 5:13 ` [PATCH v3 1/4] staging: r8188eu: Replace semaphore cmd_queue_sema with completion Binoy Jayan
2016-06-06 5:13 ` [PATCH v3 2/4] staging: r8188eu: Replace semaphore terminate_cmdthread_sema " Binoy Jayan
@ 2016-06-06 5:13 ` Binoy Jayan
2016-06-06 5:13 ` [PATCH v3 4/4] staging: r8188eu: Remove unused semaphores Binoy Jayan
3 siblings, 0 replies; 17+ messages in thread
From: Binoy Jayan @ 2016-06-06 5:13 UTC (permalink / raw)
To: Greg Kroah-Hartman, Larry Finger
Cc: Jakub Sitnicki, Arnd Bergmann, driverdev-devel, linux-kernel,
Binoy Jayan
The semaphore 'lock' in pwrctrl_priv is a simple mutex, so it should
be written as one. Semaphores are going away in the future.
_enter_pwrlock was using down_interruptible(), so the lock could be broken
by sending a signal. This could be a bug, because nothing checks the return
code here. Hence, using mutex_lock instead of the interruptible version.
Also, remove the now unused wrappers _init_pwrlock, _enter_pwrlock,
_exit_pwrlock and _rtw_down_sema.
Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
---
drivers/staging/rtl8188eu/core/rtw_pwrctrl.c | 20 ++++++++++----------
drivers/staging/rtl8188eu/include/osdep_service.h | 3 +--
drivers/staging/rtl8188eu/include/rtw_event.h | 1 +
drivers/staging/rtl8188eu/include/rtw_pwrctrl.h | 17 +----------------
drivers/staging/rtl8188eu/os_dep/osdep_service.c | 7 -------
drivers/staging/rtl8188eu/os_dep/usb_intf.c | 8 ++++----
6 files changed, 17 insertions(+), 39 deletions(-)
diff --git a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c
index 59c6d8a..0b70fe7 100644
--- a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c
+++ b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c
@@ -38,7 +38,7 @@ static int rtw_hw_suspend(struct adapter *padapter)
LeaveAllPowerSaveMode(padapter);
DBG_88E("==> rtw_hw_suspend\n");
- _enter_pwrlock(&pwrpriv->lock);
+ mutex_lock(&pwrpriv->mutex_lock);
pwrpriv->bips_processing = true;
/* s1. */
if (pnetdev) {
@@ -73,7 +73,7 @@ static int rtw_hw_suspend(struct adapter *padapter)
pwrpriv->rf_pwrstate = rf_off;
pwrpriv->bips_processing = false;
- _exit_pwrlock(&pwrpriv->lock);
+ mutex_unlock(&pwrpriv->mutex_lock);
return 0;
@@ -90,12 +90,12 @@ static int rtw_hw_resume(struct adapter *padapter)
/* system resume */
DBG_88E("==> rtw_hw_resume\n");
- _enter_pwrlock(&pwrpriv->lock);
+ mutex_lock(&pwrpriv->mutex_lock);
pwrpriv->bips_processing = true;
rtw_reset_drv_sw(padapter);
if (pm_netdev_open(pnetdev, false) != 0) {
- _exit_pwrlock(&pwrpriv->lock);
+ mutex_unlock(&pwrpriv->mutex_lock);
goto error_exit;
}
@@ -113,7 +113,7 @@ static int rtw_hw_resume(struct adapter *padapter)
pwrpriv->rf_pwrstate = rf_on;
pwrpriv->bips_processing = false;
- _exit_pwrlock(&pwrpriv->lock);
+ mutex_unlock(&pwrpriv->mutex_lock);
return 0;
@@ -138,7 +138,7 @@ void ips_enter(struct adapter *padapter)
return;
}
- _enter_pwrlock(&pwrpriv->lock);
+ mutex_lock(&pwrpriv->mutex_lock);
pwrpriv->bips_processing = true;
@@ -159,7 +159,7 @@ void ips_enter(struct adapter *padapter)
}
pwrpriv->bips_processing = false;
- _exit_pwrlock(&pwrpriv->lock);
+ mutex_unlock(&pwrpriv->mutex_lock);
}
int ips_leave(struct adapter *padapter)
@@ -171,7 +171,7 @@ int ips_leave(struct adapter *padapter)
int keyid;
- _enter_pwrlock(&pwrpriv->lock);
+ mutex_lock(&pwrpriv->mutex_lock);
if ((pwrpriv->rf_pwrstate == rf_off) && (!pwrpriv->bips_processing)) {
pwrpriv->bips_processing = true;
@@ -205,7 +205,7 @@ int ips_leave(struct adapter *padapter)
pwrpriv->bpower_saving = false;
}
- _exit_pwrlock(&pwrpriv->lock);
+ mutex_unlock(&pwrpriv->mutex_lock);
return result;
}
@@ -504,7 +504,7 @@ void rtw_init_pwrctrl_priv(struct adapter *padapter)
{
struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv;
- _init_pwrlock(&pwrctrlpriv->lock);
+ mutex_init(&pwrctrlpriv->mutex_lock);
pwrctrlpriv->rf_pwrstate = rf_on;
pwrctrlpriv->ips_enter_cnts = 0;
pwrctrlpriv->ips_leave_cnts = 0;
diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h b/drivers/staging/rtl8188eu/include/osdep_service.h
index 5475956..c53c9ea 100644
--- a/drivers/staging/rtl8188eu/include/osdep_service.h
+++ b/drivers/staging/rtl8188eu/include/osdep_service.h
@@ -36,6 +36,7 @@
#include <linux/atomic.h>
#include <linux/io.h>
#include <linux/semaphore.h>
+#include <linux/mutex.h>
#include <linux/sem.h>
#include <linux/sched.h>
#include <linux/etherdevice.h>
@@ -78,8 +79,6 @@ u8 *_rtw_malloc(u32 sz);
void *rtw_malloc2d(int h, int w, int size);
-u32 _rtw_down_sema(struct semaphore *sema);
-
void _rtw_init_queue(struct __queue *pqueue);
struct rtw_netdev_priv_indicator {
diff --git a/drivers/staging/rtl8188eu/include/rtw_event.h b/drivers/staging/rtl8188eu/include/rtw_event.h
index 5c34e56..0dc63f2 100644
--- a/drivers/staging/rtl8188eu/include/rtw_event.h
+++ b/drivers/staging/rtl8188eu/include/rtw_event.h
@@ -19,6 +19,7 @@
#include <wlan_bssdef.h>
#include <linux/semaphore.h>
+#include <linux/mutex.h>
#include <linux/sem.h>
/*
diff --git a/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h b/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h
index 9680e2e..18a9e74 100644
--- a/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h
+++ b/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h
@@ -92,21 +92,6 @@ struct reportpwrstate_parm {
unsigned short rsvd;
};
-static inline void _init_pwrlock(struct semaphore *plock)
-{
- sema_init(plock, 1);
-}
-
-static inline void _enter_pwrlock(struct semaphore *plock)
-{
- _rtw_down_sema(plock);
-}
-
-static inline void _exit_pwrlock(struct semaphore *plock)
-{
- up(plock);
-}
-
#define LPS_DELAY_TIME 1*HZ /* 1 sec */
#define EXE_PWR_NONE 0x01
@@ -157,7 +142,7 @@ enum { /* for ips_mode */
};
struct pwrctrl_priv {
- struct semaphore lock;
+ struct mutex mutex_lock;
volatile u8 rpwm; /* requested power state for fw */
volatile u8 cpwm; /* fw current power state. updated when
* 1. read from HCPWM 2. driver lowers power level */
diff --git a/drivers/staging/rtl8188eu/os_dep/osdep_service.c b/drivers/staging/rtl8188eu/os_dep/osdep_service.c
index 764250b..24d1774 100644
--- a/drivers/staging/rtl8188eu/os_dep/osdep_service.c
+++ b/drivers/staging/rtl8188eu/os_dep/osdep_service.c
@@ -55,13 +55,6 @@ void *rtw_malloc2d(int h, int w, int size)
return a;
}
-u32 _rtw_down_sema(struct semaphore *sema)
-{
- if (down_interruptible(sema))
- return _FAIL;
- return _SUCCESS;
-}
-
void _rtw_init_queue(struct __queue *pqueue)
{
INIT_LIST_HEAD(&(pqueue->queue));
diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
index 11d51a3..a5ba1e4 100644
--- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
+++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
@@ -238,7 +238,7 @@ static int rtw_suspend(struct usb_interface *pusb_intf, pm_message_t message)
rtw_cancel_all_timer(padapter);
LeaveAllPowerSaveMode(padapter);
- _enter_pwrlock(&pwrpriv->lock);
+ mutex_lock(&pwrpriv->mutex_lock);
/* s1. */
if (pnetdev) {
netif_carrier_off(pnetdev);
@@ -267,7 +267,7 @@ static int rtw_suspend(struct usb_interface *pusb_intf, pm_message_t message)
rtw_free_network_queue(padapter, true);
rtw_dev_unload(padapter);
- _exit_pwrlock(&pwrpriv->lock);
+ mutex_unlock(&pwrpriv->mutex_lock);
if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY))
rtw_indicate_scan_done(padapter, 1);
@@ -298,7 +298,7 @@ static int rtw_resume_process(struct adapter *padapter)
goto exit;
}
- _enter_pwrlock(&pwrpriv->lock);
+ mutex_lock(&pwrpriv->mutex_lock);
rtw_reset_drv_sw(padapter);
pwrpriv->bkeepfwalive = false;
@@ -309,7 +309,7 @@ static int rtw_resume_process(struct adapter *padapter)
netif_device_attach(pnetdev);
netif_carrier_on(pnetdev);
- _exit_pwrlock(&pwrpriv->lock);
+ mutex_unlock(&pwrpriv->mutex_lock);
rtw_roaming(padapter, NULL);
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v3 4/4] staging: r8188eu: Remove unused semaphores
2016-06-06 5:13 ` [PATCH v3 0/4] *** staging: r8188eu: Replace semaphores with mutexes or completions *** Binoy Jayan
` (2 preceding siblings ...)
2016-06-06 5:13 ` [PATCH v3 3/4] staging: r8188eu: pwrctrl_priv: Replace semaphore 'lock' with mutex Binoy Jayan
@ 2016-06-06 5:13 ` Binoy Jayan
3 siblings, 0 replies; 17+ messages in thread
From: Binoy Jayan @ 2016-06-06 5:13 UTC (permalink / raw)
To: Greg Kroah-Hartman, Larry Finger
Cc: Jakub Sitnicki, Arnd Bergmann, driverdev-devel, linux-kernel,
Binoy Jayan
The semaphores xmit_sema, terminate_xmitthread_sema and tx_retevt
have no users, hence remove all references to them.
Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
---
drivers/staging/rtl8188eu/core/rtw_xmit.c | 4 ----
drivers/staging/rtl8188eu/include/osdep_service.h | 1 -
drivers/staging/rtl8188eu/include/rtw_event.h | 1 -
drivers/staging/rtl8188eu/include/rtw_xmit.h | 3 ---
4 files changed, 9 deletions(-)
diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c
index e0a5567..1e1b6d8 100644
--- a/drivers/staging/rtl8188eu/core/rtw_xmit.c
+++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c
@@ -57,8 +57,6 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
/* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */
spin_lock_init(&pxmitpriv->lock);
- sema_init(&pxmitpriv->xmit_sema, 0);
- sema_init(&pxmitpriv->terminate_xmitthread_sema, 0);
/*
Please insert all the queue initializaiton using _rtw_init_queue below
@@ -199,8 +197,6 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
pxmitpriv->txirp_cnt = 1;
- sema_init(&(pxmitpriv->tx_retevt), 0);
-
/* per AC pending irp */
pxmitpriv->beq_cnt = 0;
pxmitpriv->bkq_cnt = 0;
diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h b/drivers/staging/rtl8188eu/include/osdep_service.h
index c53c9ea..6f6a8f8 100644
--- a/drivers/staging/rtl8188eu/include/osdep_service.h
+++ b/drivers/staging/rtl8188eu/include/osdep_service.h
@@ -35,7 +35,6 @@
#include <asm/byteorder.h>
#include <linux/atomic.h>
#include <linux/io.h>
-#include <linux/semaphore.h>
#include <linux/mutex.h>
#include <linux/sem.h>
#include <linux/sched.h>
diff --git a/drivers/staging/rtl8188eu/include/rtw_event.h b/drivers/staging/rtl8188eu/include/rtw_event.h
index 0dc63f2..2a45581 100644
--- a/drivers/staging/rtl8188eu/include/rtw_event.h
+++ b/drivers/staging/rtl8188eu/include/rtw_event.h
@@ -18,7 +18,6 @@
#include <osdep_service.h>
#include <wlan_bssdef.h>
-#include <linux/semaphore.h>
#include <linux/mutex.h>
#include <linux/sem.h>
diff --git a/drivers/staging/rtl8188eu/include/rtw_xmit.h b/drivers/staging/rtl8188eu/include/rtw_xmit.h
index a0853ba..7895008 100644
--- a/drivers/staging/rtl8188eu/include/rtw_xmit.h
+++ b/drivers/staging/rtl8188eu/include/rtw_xmit.h
@@ -263,8 +263,6 @@ struct agg_pkt_info {
struct xmit_priv {
spinlock_t lock;
- struct semaphore xmit_sema;
- struct semaphore terminate_xmitthread_sema;
struct __queue be_pending;
struct __queue bk_pending;
struct __queue vi_pending;
@@ -289,7 +287,6 @@ struct xmit_priv {
u8 wmm_para_seq[4];/* sequence for wmm ac parameter strength
* from large to small. it's value is 0->vo,
* 1->vi, 2->be, 3->bk. */
- struct semaphore tx_retevt;/* all tx return event; */
u8 txirp_cnt;/* */
struct tasklet_struct xmit_tasklet;
/* per AC pending irp */
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply related [flat|nested] 17+ messages in thread
end of thread, other threads:[~2016-06-06 5:14 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-03 9:58 [PATCH 0/4] *** rtl8188eu: Replace semaphores with mutexes or completions *** Binoy Jayan
2016-06-03 9:59 ` [PATCH 1/4] irtl8188eu: Replace semaphore cmd_queue_sema with completion Binoy Jayan
2016-06-05 16:31 ` Larry Finger
2016-06-03 9:59 ` [PATCH 2/4] rtl8188eu: Replace semaphore terminate_cmdthread_sema " Binoy Jayan
2016-06-03 9:59 ` [PATCH 3/4] rtl8188eu: pwrctrl_priv: Replace semaphore 'lock' with mutex Binoy Jayan
2016-06-03 9:59 ` [PATCH 4/4] rtl8188eu: Remove unused semaphores Binoy Jayan
2016-06-03 10:06 ` [PATCH 0/4] *** rtl8188eu: Replace semaphores with mutexes or completions *** Arnd Bergmann
2016-06-06 4:38 ` [PATCH v2 " Binoy Jayan
2016-06-06 4:38 ` [PATCH v2 1/4] irtl8188eu: Replace semaphore cmd_queue_sema with completion Binoy Jayan
2016-06-06 4:38 ` [PATCH v2 2/4] rtl8188eu: Replace semaphore terminate_cmdthread_sema " Binoy Jayan
2016-06-06 4:38 ` [PATCH v2 3/4] rtl8188eu: pwrctrl_priv: Replace semaphore 'lock' with mutex Binoy Jayan
2016-06-06 4:38 ` [PATCH v2 4/4] rtl8188eu: Remove unused semaphores Binoy Jayan
2016-06-06 5:13 ` [PATCH v3 0/4] *** staging: r8188eu: Replace semaphores with mutexes or completions *** Binoy Jayan
2016-06-06 5:13 ` [PATCH v3 1/4] staging: r8188eu: Replace semaphore cmd_queue_sema with completion Binoy Jayan
2016-06-06 5:13 ` [PATCH v3 2/4] staging: r8188eu: Replace semaphore terminate_cmdthread_sema " Binoy Jayan
2016-06-06 5:13 ` [PATCH v3 3/4] staging: r8188eu: pwrctrl_priv: Replace semaphore 'lock' with mutex Binoy Jayan
2016-06-06 5:13 ` [PATCH v3 4/4] staging: r8188eu: Remove unused semaphores Binoy Jayan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox