Răsfoiți Sursa

qcacld-3.0: Add support to get IPA SMMU status

Add support to get IPA SMMU status

Change-Id: I0e476b465bcaa2c5e8ae58c0783265e78ebc8181
CRs-Fixed: 2176317
Himanshu Agarwal 7 ani în urmă
părinte
comite
a89ce24bd4
3 a modificat fișierele cu 52 adăugiri și 18 ștergeri
  1. 2 2
      core/cds/inc/cds_api.h
  2. 33 9
      core/cds/src/cds_api.c
  3. 17 7
      core/hdd/src/wlan_hdd_driver_ops.c

+ 2 - 2
core/cds/inc/cds_api.h

@@ -602,9 +602,9 @@ void cds_incr_arp_stats_tx_tgt_acked(void);
  * This API checks if SMMU S1 translation is enabled in
  * platform driver or not and sets it accordingly in driver.
  *
- * Return: none
+ * Return: QDF_STATUS
  */
-void cds_smmu_mem_map_setup(qdf_device_t osdev);
+QDF_STATUS cds_smmu_mem_map_setup(qdf_device_t osdev);
 
 /**
  * cds_smmu_map_unmap() - Map / Unmap DMA buffer to IPA UC

+ 33 - 9
core/cds/src/cds_api.c

@@ -2845,21 +2845,44 @@ void cds_incr_arp_stats_tx_tgt_acked(void)
 }
 
 #ifdef ENABLE_SMMU_S1_TRANSLATION
-void cds_smmu_mem_map_setup(qdf_device_t osdev)
+QDF_STATUS cds_smmu_mem_map_setup(qdf_device_t osdev)
 {
 	int attr = 0;
+	bool ipa_smmu_enable;
 	struct dma_iommu_mapping *mapping = pld_smmu_get_mapping(osdev->dev);
 
 	osdev->smmu_s1_enabled = false;
-	if (!mapping) {
-		cds_info("No SMMU mapping present");
-		return;
+
+	ipa_smmu_enable = qdf_get_ipa_smmu_enabled();
+	if (ipa_smmu_enable)
+		cds_info("SMMU enabled from IPA side");
+	else
+		cds_info("SMMU not enabled from IPA side");
+
+	if (mapping && ((iommu_domain_get_attr(mapping->domain,
+			 DOMAIN_ATTR_S1_BYPASS, &attr) == 0) &&
+			 !attr)) {
+		cds_info("SMMU enabled from WLAN side");
+		if (ipa_smmu_enable) {
+			cds_info("SMMU enabled from both IPA and WLAN side");
+			osdev->smmu_s1_enabled = true;
+			return QDF_STATUS_SUCCESS;
+		} else {
+			cds_err("SMMU mismatch: IPA: disable, WLAN: enable");
+			return QDF_STATUS_E_FAILURE;
+		}
+	} else {
+		cds_info("No SMMU mapping present or SMMU disabled from WLAN side");
+		if (ipa_smmu_enable) {
+			cds_err("SMMU mismatch: IPA: enable, WLAN: disable");
+			return QDF_STATUS_E_FAILURE;
+		} else {
+			cds_info("SMMU diabled from both IPA and WLAN side");
+			return QDF_STATUS_SUCCESS;
+		}
 	}
 
-	if ((iommu_domain_get_attr(mapping->domain,
-				   DOMAIN_ATTR_S1_BYPASS, &attr) == 0) &&
-				   !attr)
-		osdev->smmu_s1_enabled = true;
+	return QDF_STATUS_SUCCESS;
 }
 
 #ifdef IPA_OFFLOAD
@@ -2875,9 +2898,10 @@ int cds_smmu_map_unmap(bool map, uint32_t num_buf, qdf_mem_info_t *buf_arr)
 #endif
 
 #else
-void cds_smmu_mem_map_setup(qdf_device_t osdev)
+QDF_STATUS cds_smmu_mem_map_setup(qdf_device_t osdev)
 {
 	osdev->smmu_s1_enabled = false;
+	return QDF_STATUS_SUCCESS;
 }
 
 int cds_smmu_map_unmap(bool map, uint32_t num_buf, qdf_mem_info_t *buf_arr)

+ 17 - 7
core/hdd/src/wlan_hdd_driver_ops.c

@@ -305,24 +305,30 @@ void hdd_hif_close(struct hdd_context *hdd_ctx, void *hif_ctx)
  * @bus_type: Underlying bus type
  * @bid: Bus id passed by platform driver
  *
- * Return: void
+ * Return: 0 - success, < 0 - failure
  */
-static void hdd_init_qdf_ctx(struct device *dev, void *bdev,
-			     enum qdf_bus_type bus_type,
-			     const struct hif_bus_id *bid)
+static int hdd_init_qdf_ctx(struct device *dev, void *bdev,
+			    enum qdf_bus_type bus_type,
+			    const struct hif_bus_id *bid)
 {
 	qdf_device_t qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
 
 	if (!qdf_dev) {
 		hdd_err("Invalid QDF device");
-		return;
+		return -EINVAL;
 	}
 
 	qdf_dev->dev = dev;
 	qdf_dev->drv_hdl = bdev;
 	qdf_dev->bus_type = bus_type;
 	qdf_dev->bid = bid;
-	cds_smmu_mem_map_setup(qdf_dev);
+	if (cds_smmu_mem_map_setup(qdf_dev) !=
+		QDF_STATUS_SUCCESS) {
+		hdd_err("cds_smmu_mem_map_setup() failed");
+		return -EFAULT;
+	}
+
+	return 0;
 }
 
 /**
@@ -390,7 +396,10 @@ static int wlan_hdd_probe(struct device *dev, void *bdev,
 	else
 		cds_set_load_in_progress(true);
 
-	hdd_init_qdf_ctx(dev, bdev, bus_type, (const struct hif_bus_id *)bid);
+	ret = hdd_init_qdf_ctx(dev, bdev, bus_type,
+			       (const struct hif_bus_id *)bid);
+	if (ret < 0)
+		goto err_init_qdf_ctx;
 
 	if (reinit) {
 		ret = hdd_wlan_re_init();
@@ -437,6 +446,7 @@ err_hdd_deinit:
 	} else
 		cds_set_load_in_progress(false);
 
+err_init_qdf_ctx:
 	hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_DRIVER_INIT);
 	hdd_remove_pm_qos(dev);