qcacmn: Access initial ipa tx doorbell after enable pipes

Currently host writes to TX doorbell register after ipa connect
pipes to indicate number of free TX buffers. In case when IPA
clocks are off and host tries to access the register will leads
to invalid access. So access the tx doorbell register after ipa
enable pipes which makes sure IPA clocks are always on.

Change-Id: If11fdc9c408ebf7f22eef6a020b507bc39ee6a8e
CRs-Fixed: 2599029
diff --git a/dp/wifi3.0/dp_ipa.c b/dp/wifi3.0/dp_ipa.c
index c3f4fa3..92dcb35 100644
--- a/dp/wifi3.0/dp_ipa.c
+++ b/dp/wifi3.0/dp_ipa.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -702,8 +702,6 @@
 		(void *)ipa_res->tx_comp_doorbell_paddr,
 		(void *)ipa_res->tx_comp_doorbell_vaddr);
 
-	hal_srng_dst_init_hp(wbm_srng, ipa_res->tx_comp_doorbell_vaddr);
-
 	/*
 	 * For RX, REO module on Napier/Hastings does reordering on incoming
 	 * Ethernet packets and writes one or more descriptors to REO2IPA Rx
@@ -1233,6 +1231,8 @@
 	ipa_res->rx_ready_doorbell_paddr =
 		QDF_IPA_WDI_CONN_OUT_PARAMS_RX_UC_DB_PA(&pipe_out);
 
+	soc->ipa_first_tx_db_access = true;
+
 	return QDF_STATUS_SUCCESS;
 }
 
@@ -1445,6 +1445,8 @@
 	ipa_res->rx_ready_doorbell_paddr =
 		QDF_IPA_WDI_CONN_OUT_PARAMS_RX_UC_DB_PA(&pipe_out);
 
+	soc->ipa_first_tx_db_access = true;
+
 	QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_DEBUG,
 		  "%s: Tx: %s=%pK, %s=%d, %s=%pK, %s=%pK, %s=%d, %s=%pK, %s=%d, %s=%pK",
 		  __func__,
@@ -1604,6 +1606,9 @@
 	struct dp_soc *soc = cdp_soc_t_to_dp_soc(soc_hdl);
 	struct dp_pdev *pdev =
 		dp_get_pdev_from_soc_pdev_id_wifi3(soc, pdev_id);
+	struct hal_srng *wbm_srng = (struct hal_srng *)
+			soc->tx_comp_ring[IPA_TX_COMP_RING_IDX].hal_srng;
+	struct dp_ipa_resources *ipa_res;
 	QDF_STATUS result;
 
 	if (!pdev) {
@@ -1611,6 +1616,8 @@
 		return QDF_STATUS_E_FAILURE;
 	}
 
+	ipa_res = &pdev->ipa_resource;
+
 	qdf_atomic_set(&soc->ipa_pipes_enabled, 1);
 	dp_ipa_handle_rx_buf_pool_smmu_mapping(soc, pdev, true);
 
@@ -1624,6 +1631,11 @@
 		return QDF_STATUS_E_FAILURE;
 	}
 
+	if (soc->ipa_first_tx_db_access) {
+		hal_srng_dst_init_hp(wbm_srng, ipa_res->tx_comp_doorbell_vaddr);
+		soc->ipa_first_tx_db_access = false;
+	}
+
 	return QDF_STATUS_SUCCESS;
 }
 
diff --git a/dp/wifi3.0/dp_types.h b/dp/wifi3.0/dp_types.h
index 441d484..51f5970 100644
--- a/dp/wifi3.0/dp_types.h
+++ b/dp/wifi3.0/dp_types.h
@@ -1190,6 +1190,7 @@
 	} ipa_uc_rx_rsc;
 
 	qdf_atomic_t ipa_pipes_enabled;
+	bool ipa_first_tx_db_access;
 #endif
 
 #ifdef WLAN_FEATURE_STATS_EXT