mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-11 15:11:48 -04:00
icnss2: Avoid race between soc wake release threads
Avoid race condition between soc wake release from queue context and host driver context. Change-Id: I6e20a9a8781f65447e89160ff4e362a04ec4ec5c Signed-off-by: Naman Padhiar <npadhiar@codeaurora.org>
This commit is contained in:
parent
6151ff0c6a
commit
599bec2e07
1 changed files with 17 additions and 6 deletions
|
|
@ -986,6 +986,19 @@ static int icnss_qdss_trace_save_hdlr(struct icnss_priv *priv,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static inline int icnss_atomic_dec_if_greater_one(atomic_t *v)
|
||||
{
|
||||
int dec, c = atomic_read(v);
|
||||
|
||||
do {
|
||||
dec = c - 1;
|
||||
if (unlikely(dec < 1))
|
||||
break;
|
||||
} while (!atomic_try_cmpxchg(v, &c, dec));
|
||||
|
||||
return dec;
|
||||
}
|
||||
|
||||
static int icnss_event_soc_wake_request(struct icnss_priv *priv, void *data)
|
||||
{
|
||||
int ret = 0;
|
||||
|
|
@ -2365,7 +2378,6 @@ EXPORT_SYMBOL(icnss_force_wake_request);
|
|||
int icnss_force_wake_release(struct device *dev)
|
||||
{
|
||||
struct icnss_priv *priv = dev_get_drvdata(dev);
|
||||
int count = 0;
|
||||
|
||||
if (!dev)
|
||||
return -ENODEV;
|
||||
|
|
@ -2375,15 +2387,14 @@ int icnss_force_wake_release(struct device *dev)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (atomic_read(&priv->soc_wake_ref_count) > 1) {
|
||||
count = atomic_dec_return(&priv->soc_wake_ref_count);
|
||||
icnss_pr_dbg("Calling SOC Wake response");
|
||||
|
||||
if (icnss_atomic_dec_if_greater_one(&priv->soc_wake_ref_count)) {
|
||||
icnss_pr_dbg("SOC previous release pending, Ref count: %d",
|
||||
count);
|
||||
atomic_read(&priv->soc_wake_ref_count));
|
||||
return 0;
|
||||
}
|
||||
|
||||
icnss_pr_dbg("Calling SOC Wake response");
|
||||
|
||||
icnss_soc_wake_event_post(priv, ICNSS_SOC_WAKE_RELEASE_EVENT,
|
||||
0, NULL);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue