qcacmn: Fix WMI cmd send issue in case of 100% cpu utilization

WMI can queue the packets in both process and tasklet context. Before
queuing the packet H-TC will increase TxProcessCount. Only one core
can increase it and proceed for queuing the packets to HIF. At 100%
cpu utilization due to locking and unlocking the H-TC TX lock, one
core is holding TXProcessCount(and went to tasklet context and stuck
there) and other core is not able to queue the packets to HIF. Which
is creating virtual CE stuck case. Fixed the issue by acquing the
H-TC tx lock before the while loop which queus the packets
in H-TC queue

Change-Id: I435be9fa34b5ae86c6edb6ee29426a9134e5b6f2
CRs-Fixed: 1083038
diff --git a/htc/htc_send.c b/htc/htc_send.c
index d6b8794..10874c6 100644
--- a/htc/htc_send.c
+++ b/htc/htc_send.c
@@ -615,14 +615,20 @@
 						     (pPacket), QDF_DMA_TO_DEVICE);
 			}
 		}
-		LOCK_HTC_TX(target);
+
+		if (pEndpoint->service_id != WMI_CONTROL_SVC) {
+			LOCK_HTC_TX(target);
+		}
 		/* store in look up queue to match completions */
 		HTC_PACKET_ENQUEUE(&pEndpoint->TxLookupQueue, pPacket);
 		INC_HTC_EP_STAT(pEndpoint, TxIssued, 1);
 		pEndpoint->ul_outstanding_cnt++;
-		UNLOCK_HTC_TX(target);
+		if (pEndpoint->service_id != WMI_CONTROL_SVC) {
+			UNLOCK_HTC_TX(target);
+			hif_send_complete_check(target->hif_dev,
+					pEndpoint->UL_PipeID, false);
+		}
 
-		hif_send_complete_check(target->hif_dev, pEndpoint->UL_PipeID, false);
 		status = hif_send_head(target->hif_dev,
 				       pEndpoint->UL_PipeID, pEndpoint->Id,
 				       HTC_HDR_LENGTH + pPacket->ActualLength,
@@ -645,7 +651,9 @@
 						("hif_send Failed status:%d \n",
 						 status));
 			}
-			LOCK_HTC_TX(target);
+			if (pEndpoint->service_id != WMI_CONTROL_SVC) {
+				LOCK_HTC_TX(target);
+			}
 			target->ce_send_cnt--;
 			pEndpoint->ul_outstanding_cnt--;
 			HTC_PACKET_REMOVE(&pEndpoint->TxLookupQueue, pPacket);
@@ -654,7 +662,9 @@
 					pPacket->PktInfo.AsTx.CreditsUsed;
 			/* put it back into the callers queue */
 			HTC_PACKET_ENQUEUE_TO_HEAD(pPktQueue, pPacket);
-			UNLOCK_HTC_TX(target);
+			if (pEndpoint->service_id != WMI_CONTROL_SVC) {
+				UNLOCK_HTC_TX(target);
+			}
 			break;
 		}
 
@@ -1135,7 +1145,9 @@
 	 * transmit resources */
 	while (true) {
 
-		if (HTC_PACKET_QUEUE_DEPTH(&pEndpoint->TxQueue) == 0) {
+		if ((HTC_PACKET_QUEUE_DEPTH(&pEndpoint->TxQueue) == 0) ||
+			((!tx_resources) &&
+			(pEndpoint->service_id == WMI_CONTROL_SVC))) {
 			break;
 		}
 
@@ -1181,7 +1193,9 @@
 			break;
 		}
 
-		UNLOCK_HTC_TX(target);
+		if (pEndpoint->service_id != WMI_CONTROL_SVC) {
+			UNLOCK_HTC_TX(target);
+		}
 
 		/* send what we can */
 		result = htc_issue_packets(target, pEndpoint, &sendQueue);
@@ -1206,7 +1220,9 @@
 							  pEndpoint->UL_PipeID);
 		}
 
-		LOCK_HTC_TX(target);
+		if (pEndpoint->service_id != WMI_CONTROL_SVC) {
+			LOCK_HTC_TX(target);
+		}
 
 	}
 
@@ -1882,7 +1898,10 @@
 		/* note: when using TX credit flow, the re-checking of queues happens
 		* when credits flow back from the target.
 		* in the non-TX credit case, we recheck after the packet completes */
-		htc_try_send(target, pEndpoint, NULL);
+		if ((qdf_atomic_read(&pEndpoint->TxProcessCount) == 0) ||
+				(pEndpoint->service_id != WMI_CONTROL_SVC)) {
+			htc_try_send(target, pEndpoint, NULL);
+		}
 	}
 
 	return QDF_STATUS_SUCCESS;