From 5c463f983f9f5129970f4f80865cf1254779a626 Mon Sep 17 00:00:00 2001 From: Naman Padhiar Date: Fri, 20 Aug 2021 13:54:04 +0530 Subject: [PATCH] icnss2: Properly handle SOC_WAKE req stuck in QMI SOC_WAKE_REQ can stuck in QMI layer for more than 500ms, this will be considered as SOC_WAKE_REQ failure by host driver and it will send SOC_WAKE_REL. Properly handle SOC_WAKE_REL based on SOC_WAKE_REQ status and accordingly update reference count. Change-Id: Ib4a549bceb98be071e7a570a663276d2c7bea389 Signed-off-by: Naman Padhiar --- drivers/soc/qcom/icnss2/main.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/soc/qcom/icnss2/main.c b/drivers/soc/qcom/icnss2/main.c index 36f35f59c11d..b022ec250052 100644 --- a/drivers/soc/qcom/icnss2/main.c +++ b/drivers/soc/qcom/icnss2/main.c @@ -1108,16 +1108,13 @@ static int icnss_event_soc_wake_request(struct icnss_priv *priv, void *data) static int icnss_event_soc_wake_release(struct icnss_priv *priv, void *data) { int ret = 0; - int count = 0; if (!priv) return -ENODEV; - count = atomic_dec_return(&priv->soc_wake_ref_count); - - if (count) { + if (atomic_dec_if_positive(&priv->soc_wake_ref_count)) { icnss_pr_dbg("Wake release not called. Ref count: %d", - count); + priv->soc_wake_ref_count); return 0; } @@ -2793,7 +2790,8 @@ int icnss_force_wake_release(struct device *dev) icnss_pr_dbg("Calling SOC Wake response"); - if (icnss_atomic_dec_if_greater_one(&priv->soc_wake_ref_count)) { + if (atomic_read(&priv->soc_wake_ref_count) && + icnss_atomic_dec_if_greater_one(&priv->soc_wake_ref_count)) { icnss_pr_dbg("SOC previous release pending, Ref count: %d", atomic_read(&priv->soc_wake_ref_count)); return 0;