Browse Source

qcacld-3.0: add cdp ops for IPA Tx buf smmu_unmapping

Add cdp ops for IPA Tx buf SMMU-S1 unmapping and
call unmap from ipa_uc_ol_deinit if IPA uc_loaded,
also assert if mapping/unmapping failed.

Change-Id: I79f293fcf5d6f02e3a01d6c8ff829f4ca87e76e8
CRs-Fixed: 2788811
Vevek Venkatesan 4 years ago
parent
commit
bbcf12c70d

+ 5 - 1
components/ipa/core/src/wlan_ipa_core.c

@@ -617,8 +617,10 @@ static void wlan_ipa_pm_flush(void *data)
 
 int wlan_ipa_uc_smmu_map(bool map, uint32_t num_buf, qdf_mem_info_t *buf_arr)
 {
-	if (!ipa_is_ready())
+	if (!ipa_is_ready()) {
+		ipa_info("IPA is not READY");
 		return 0;
+	}
 
 	if (!num_buf) {
 		ipa_info("No buffers to map/unmap");
@@ -3698,6 +3700,8 @@ QDF_STATUS wlan_ipa_uc_ol_deinit(struct wlan_ipa_priv *ipa_ctx)
 	wlan_ipa_uc_disable_pipes(ipa_ctx, true);
 
 	if (true == ipa_ctx->uc_loaded) {
+		cdp_ipa_tx_buf_smmu_unmapping(ipa_ctx->dp_soc,
+					      ipa_ctx->dp_pdev_id);
 		status = cdp_ipa_cleanup(ipa_ctx->dp_soc,
 					 ipa_ctx->dp_pdev_id,
 					 ipa_ctx->tx_pipe_handle,

+ 0 - 48
core/dp/htt/htt_tx.c

@@ -1206,39 +1206,15 @@ out:
 static void htt_tx_buf_pool_free(struct htt_pdev_t *pdev)
 {
 	uint16_t idx;
-	qdf_mem_info_t *mem_map_table = NULL, *mem_info = NULL;
-	uint32_t num_unmapped = 0;
-
-	if (qdf_mem_smmu_s1_enabled(pdev->osdev)) {
-		mem_map_table = qdf_mem_map_table_alloc(
-					pdev->ipa_uc_tx_rsc.alloc_tx_buf_cnt);
-		if (!mem_map_table) {
-			qdf_print("Failed to allocate memory");
-			return;
-		}
-		mem_info = mem_map_table;
-	}
 
 	for (idx = 0; idx < pdev->ipa_uc_tx_rsc.alloc_tx_buf_cnt; idx++) {
 		if (pdev->ipa_uc_tx_rsc.tx_buf_pool_strg[idx]) {
-			if (qdf_mem_smmu_s1_enabled(pdev->osdev)) {
-				*mem_info = pdev->ipa_uc_tx_rsc.
-					      tx_buf_pool_strg[idx]->mem_info;
-				mem_info++;
-				num_unmapped++;
-			}
 			qdf_mem_shared_mem_free(pdev->osdev,
 						pdev->ipa_uc_tx_rsc.
 							tx_buf_pool_strg[idx]);
 			pdev->ipa_uc_tx_rsc.tx_buf_pool_strg[idx] = NULL;
 		}
 	}
-
-	if (qdf_mem_smmu_s1_enabled(pdev->osdev)) {
-		if (num_unmapped)
-			cds_smmu_map_unmap(false, num_unmapped, mem_map_table);
-		qdf_mem_free(mem_map_table);
-	}
 }
 #else
 static int htt_tx_ipa_get_limit_tx_buf_count(unsigned int uc_tx_buf_cnt)
@@ -1336,39 +1312,15 @@ pwr2:
 static void htt_tx_buf_pool_free(struct htt_pdev_t *pdev)
 {
 	uint16_t idx;
-	qdf_mem_info_t *mem_map_table = NULL, *mem_info = NULL;
-	uint32_t num_unmapped = 0;
-
-	if (qdf_mem_smmu_s1_enabled(pdev->osdev)) {
-		mem_map_table = qdf_mem_map_table_alloc(
-					pdev->ipa_uc_tx_rsc.alloc_tx_buf_cnt);
-		if (!mem_map_table) {
-			qdf_print("Failed to allocate memory");
-			return;
-		}
-		mem_info = mem_map_table;
-	}
 
 	for (idx = 0; idx < pdev->ipa_uc_tx_rsc.alloc_tx_buf_cnt; idx++) {
 		if (pdev->ipa_uc_tx_rsc.tx_buf_pool_strg[idx]) {
-			if (qdf_mem_smmu_s1_enabled(pdev->osdev)) {
-				*mem_info = pdev->ipa_uc_tx_rsc.
-					      tx_buf_pool_strg[idx]->mem_info;
-				mem_info++;
-				num_unmapped++;
-			}
 			qdf_mem_shared_mem_free(pdev->osdev,
 						pdev->ipa_uc_tx_rsc.
 							tx_buf_pool_strg[idx]);
 			pdev->ipa_uc_tx_rsc.tx_buf_pool_strg[idx] = NULL;
 		}
 	}
-
-	if (qdf_mem_smmu_s1_enabled(pdev->osdev)) {
-		if (num_unmapped)
-			cds_smmu_map_unmap(false, num_unmapped, mem_map_table);
-		qdf_mem_free(mem_map_table);
-	}
 }
 #endif
 

+ 2 - 1
core/dp/txrx/ol_txrx.c

@@ -6185,7 +6185,8 @@ static struct cdp_ipa_ops ol_ops_ipa = {
 	.ipa_uc_get_share_stats = ol_txrx_ipa_uc_get_share_stats,
 	.ipa_uc_set_quota = ol_txrx_ipa_uc_set_quota,
 #endif
-	.ipa_tx_buf_smmu_mapping = ol_txrx_ipa_tx_buf_smmu_mapping
+	.ipa_tx_buf_smmu_mapping = ol_txrx_ipa_tx_buf_smmu_mapping,
+	.ipa_tx_buf_smmu_unmapping = ol_txrx_ipa_tx_buf_smmu_unmapping
 };
 #endif
 

+ 56 - 27
core/dp/txrx/ol_txrx_ipa.c

@@ -280,60 +280,89 @@ QDF_STATUS ol_txrx_ipa_disable_autonomy(struct cdp_soc_t *soc_hdl,
 	return QDF_STATUS_SUCCESS;
 }
 
-static QDF_STATUS __ol_txrx_ipa_tx_buf_smmu_mapping(
-	struct ol_txrx_soc_t  *soc,
-	struct ol_txrx_pdev_t *pdev,
-	bool create)
+static QDF_STATUS __ol_txrx_ipa_tx_buf_smmu_mapping(struct ol_txrx_pdev_t *pdev,
+						    bool create)
 {
 	uint32_t index;
+	uint32_t unmap_cnt = 0;
+	uint32_t tx_buffer_cnt;
 	QDF_STATUS ret = QDF_STATUS_SUCCESS;
 	struct htt_pdev_t *htt_pdev = pdev->htt_pdev;
-	uint32_t tx_buffer_cnt = htt_pdev->ipa_uc_tx_rsc.alloc_tx_buf_cnt;
 	qdf_mem_info_t *mem_map_table = NULL, *mem_info = NULL;
 
+	if (!htt_pdev) {
+		ol_txrx_err("htt_pdev is NULL");
+		return QDF_STATUS_E_FAILURE;
+	}
+
 	if (qdf_mem_smmu_s1_enabled(htt_pdev->osdev)) {
-		mem_map_table = qdf_mem_map_table_alloc(tx_buffer_cnt);
-		if (!mem_map_table) {
-			QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
-				  "Failed to allocate memory");
-			return QDF_STATUS_E_FAILURE;
-		}
-		mem_info = mem_map_table;
+		ol_txrx_info("SMMU-S1 mapping is disabled");
+		return QDF_STATUS_SUCCESS;
+	}
+
+	tx_buffer_cnt = htt_pdev->ipa_uc_tx_rsc.alloc_tx_buf_cnt;
+	mem_map_table = qdf_mem_map_table_alloc(tx_buffer_cnt);
+	if (!mem_map_table) {
+		ol_txrx_err("Failed to allocate memory");
+		return QDF_STATUS_E_FAILURE;
 	}
+	mem_info = mem_map_table;
 
 	for (index = 0; index < tx_buffer_cnt; index++) {
-		*mem_info = htt_pdev->ipa_uc_tx_rsc.tx_buf_pool_strg[
-						index]->mem_info;
-		if (!mem_info)
-			continue;
-		ret = cds_smmu_map_unmap(true, 1, mem_info);
-		mem_info++;
+		if (htt_pdev->ipa_uc_tx_rsc.tx_buf_pool_strg[index]) {
+			*mem_info = htt_pdev->ipa_uc_tx_rsc.
+					tx_buf_pool_strg[index]->mem_info;
+			mem_info++;
+			unmap_cnt++;
+		}
 	}
-	if (qdf_mem_smmu_s1_enabled(htt_pdev->osdev))
-		qdf_mem_free(mem_map_table);
+
+	ret = cds_smmu_map_unmap(create, unmap_cnt, mem_map_table);
+	qdf_assert_always(!ret);
+	qdf_mem_free(mem_map_table);
 
 	return ret;
 }
 
-QDF_STATUS ol_txrx_ipa_tx_buf_smmu_mapping(
-	struct cdp_soc_t *soc_hdl, uint8_t pdev_id)
+QDF_STATUS ol_txrx_ipa_tx_buf_smmu_mapping(struct cdp_soc_t *soc_hdl,
+					   uint8_t pdev_id)
 {
 	QDF_STATUS ret;
 	struct ol_txrx_soc_t *soc = cdp_soc_t_to_ol_txrx_soc_t(soc_hdl);
 	ol_txrx_pdev_handle pdev = ol_txrx_get_pdev_from_pdev_id(soc, pdev_id);
 
 	if (!pdev) {
-		QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
-			  "invalid instance");
+		ol_txrx_err("invalid instance");
 		return QDF_STATUS_E_FAILURE;
 	}
 
 	if (!qdf_mem_smmu_s1_enabled(pdev->htt_pdev->osdev)) {
-		QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_DEBUG,
-			  "SMMU S1 disabled");
+		ol_txrx_err("SMMU S1 disabled");
 		return QDF_STATUS_SUCCESS;
 	}
-	ret = __ol_txrx_ipa_tx_buf_smmu_mapping(soc, pdev, true);
+	ret = __ol_txrx_ipa_tx_buf_smmu_mapping(pdev, true);
+
+	return ret;
+}
+
+QDF_STATUS ol_txrx_ipa_tx_buf_smmu_unmapping(struct cdp_soc_t *soc_hdl,
+					     uint8_t pdev_id)
+{
+	QDF_STATUS ret;
+	struct ol_txrx_soc_t *soc = cdp_soc_t_to_ol_txrx_soc_t(soc_hdl);
+	ol_txrx_pdev_handle pdev = ol_txrx_get_pdev_from_pdev_id(soc, pdev_id);
+
+	if (!pdev) {
+		ol_txrx_err("invalid instance");
+		return QDF_STATUS_E_FAILURE;
+	}
+
+	if (!qdf_mem_smmu_s1_enabled(pdev->htt_pdev->osdev)) {
+		ol_txrx_err("SMMU S1 disabled");
+		return QDF_STATUS_SUCCESS;
+	}
+	ret = __ol_txrx_ipa_tx_buf_smmu_mapping(pdev, false);
+
 	return ret;
 }
 

+ 17 - 6
core/dp/txrx/ol_txrx_ipa.h

@@ -211,15 +211,26 @@ QDF_STATUS ol_txrx_ipa_disable_autonomy(struct cdp_soc_t *soc_hdl,
 					uint8_t pdev_id);
 
 /**
- * ol_txrx_ipa_tx_buf_smmu_mapping() Create SMMU mappings for IPA
- * allocated TX buffers
- * @soc_hdl - handle to the soc
- * @pdev_id - pdev id number, to get the handle
+ * ol_txrx_ipa_tx_buf_smmu_mapping() - Create SMMU mappings for IPA
+ *				       allocated TX buffers
+ * @soc_hdl: handle to the soc
+ * @pdev_id: pdev id number, to get the handle
  *
  * Return: QDF_STATUS
  */
-QDF_STATUS ol_txrx_ipa_tx_buf_smmu_mapping(
-	struct cdp_soc_t *soc_hdl, uint8_t pdev_id);
+QDF_STATUS ol_txrx_ipa_tx_buf_smmu_mapping(struct cdp_soc_t *soc_hdl,
+					   uint8_t pdev_id);
+
+/**
+ * ol_txrx_ipa_tx_buf_smmu_unmapping() - Release SMMU mappings for IPA
+ *					 allocated TX buffers
+ * @soc_hdl: handle to the soc
+ * @pdev_id: pdev id number, to get the handle
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS ol_txrx_ipa_tx_buf_smmu_unmapping(struct cdp_soc_t *soc_hdl,
+					     uint8_t pdev_id);
 
 #ifdef CONFIG_IPA_WDI_UNIFIED_API
 /**