From e37820ebd2fa30636f5d5f0a32771928cf6400c0 Mon Sep 17 00:00:00 2001 From: Rajeev Kumar Date: Thu, 14 Apr 2016 17:30:56 -0700 Subject: [PATCH] qcacmn: Fix WMI command stuck issue There is race condition in HTCTrySend() where it is clearing TxProcessCount after releasing target lock which is resulting it in WMI command stuck as other thread check TxProcessCount and returns after putting command in queue. Fix above race condition by unlocking target lock after clearing TxProcessCount. Change-Id: I80d69bf583d3eb3c9800c69d7917921aa959f866 CRs-Fixed: 991142 --- htc/htc_send.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htc/htc_send.c b/htc/htc_send.c index 4563b4a86f74..149fb500cfc7 100644 --- a/htc/htc_send.c +++ b/htc/htc_send.c @@ -1042,8 +1042,7 @@ static HTC_SEND_QUEUE_RESULT htc_try_send(HTC_TARGET *target, } /* increment tx processing count on entry */ - qdf_atomic_inc(&pEndpoint->TxProcessCount); - if (qdf_atomic_read(&pEndpoint->TxProcessCount) > 1) { + if (qdf_atomic_inc_return(&pEndpoint->TxProcessCount) > 1) { /* another thread or task is draining the TX queues on this endpoint * that thread will reset the tx processing count when the queue is drained */ qdf_atomic_dec(&pEndpoint->TxProcessCount); @@ -1122,10 +1121,11 @@ static HTC_SEND_QUEUE_RESULT htc_try_send(HTC_TARGET *target, } - UNLOCK_HTC_TX(target); /* done with this endpoint, we can clear the count */ qdf_atomic_init(&pEndpoint->TxProcessCount); + UNLOCK_HTC_TX(target); + AR_DEBUG_PRINTF(ATH_DEBUG_SEND, ("-htc_try_send: \n")); return HTC_SEND_QUEUE_OK;