qcacmn: Add timeout for BMI message exchange

qcacld-2.0 to qcacmn propagation

Currently there is no timeout for BMI message exchange.
If HW interface is stuck, kernel thread for driver loading
will be blocked.

Change-Id: Ia7039f2939cf39af605a8ebec3278c5e1685bfbe
CRs-Fixed: 2228298
diff --git a/hif/src/ce/ce_bmi.c b/hif/src/ce/ce_bmi.c
index 368ba74..49004bd 100644
--- a/hif/src/ce/ce_bmi.c
+++ b/hif/src/ce/ce_bmi.c
@@ -115,6 +115,9 @@
 }
 #endif
 
+/* Timeout for BMI message exchange */
+#define HIF_EXCHANGE_BMI_MSG_TIMEOUT 6000
+
 QDF_STATUS hif_exchange_bmi_msg(struct hif_opaque_softc *hif_ctx,
 				qdf_dma_addr_t bmi_cmd_da,
 				qdf_dma_addr_t bmi_rsp_da,
@@ -216,9 +219,13 @@
 	/* Always just wait for BMI request here if
 	 * BMI_RSP_POLLING is defined
 	 */
-	while (qdf_semaphore_acquire
-		       (&transaction->bmi_transaction_sem)) {
-		/*need some break out condition(time out?) */
+	if (qdf_semaphore_acquire_timeout
+		       (&transaction->bmi_transaction_sem,
+			HIF_EXCHANGE_BMI_MSG_TIMEOUT)) {
+		HIF_ERROR("%s: Fatal error, BMI transaction timeout. Please check the HW interface!!",
+			  __func__);
+		qdf_mem_free(transaction);
+		return QDF_STATUS_E_TIMEOUT;
 	}
 
 	if (bmi_response) {