Browse Source

qcacld-3.0: Use new API pld_smmu_get_domain

Use new API pld_smmu_get_domain in place of
pld_smmu_get_mapping, which is to be deprecated.

Change-Id: I7a083cd3c0deecdbf774b57121866cd72fc157dc
Crs-Fixed: 2464850
Rakshith Suresh Patkar 6 years ago
parent
commit
65bdb19143
1 changed files with 58 additions and 0 deletions
  1. 58 0
      core/cds/src/cds_api.c

+ 58 - 0
core/cds/src/cds_api.c

@@ -2740,6 +2740,54 @@ void cds_incr_arp_stats_tx_tgt_acked(void)
 }
 
 #ifdef ENABLE_SMMU_S1_TRANSLATION
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0))
+QDF_STATUS cds_smmu_mem_map_setup(qdf_device_t osdev, bool ipa_present)
+{
+	struct iommu_domain *domain;
+	bool ipa_smmu_enabled;
+	bool wlan_smmu_enabled;
+
+	domain = pld_smmu_get_domain(osdev->dev);
+	if (domain) {
+		int attr = 0;
+		int errno = iommu_domain_get_attr(domain,
+						  DOMAIN_ATTR_S1_BYPASS, &attr);
+
+		wlan_smmu_enabled = !errno && !attr;
+	} else {
+		cds_info("No SMMU mapping present");
+		wlan_smmu_enabled = false;
+	}
+
+	if (!wlan_smmu_enabled) {
+		osdev->smmu_s1_enabled = false;
+		goto exit_with_success;
+	}
+
+	if (!ipa_present) {
+		osdev->smmu_s1_enabled = true;
+		goto exit_with_success;
+	}
+
+	ipa_smmu_enabled = qdf_get_ipa_smmu_enabled();
+
+	osdev->smmu_s1_enabled = ipa_smmu_enabled && wlan_smmu_enabled;
+	if (ipa_smmu_enabled != wlan_smmu_enabled) {
+		cds_err("SMMU mismatch; IPA:%s, WLAN:%s",
+			ipa_smmu_enabled ? "enabled" : "disabled",
+			wlan_smmu_enabled ? "enabled" : "disabled");
+		return QDF_STATUS_E_FAILURE;
+	}
+
+exit_with_success:
+	osdev->domain = domain;
+
+	cds_info("SMMU S1 %s", osdev->smmu_s1_enabled ? "enabled" : "disabled");
+
+	return QDF_STATUS_SUCCESS;
+}
+
+#else
 QDF_STATUS cds_smmu_mem_map_setup(qdf_device_t osdev, bool ipa_present)
 {
 	struct dma_iommu_mapping *mapping;
@@ -2785,6 +2833,7 @@ exit_with_success:
 
 	return QDF_STATUS_SUCCESS;
 }
+#endif
 
 #ifdef IPA_OFFLOAD
 int cds_smmu_map_unmap(bool map, uint32_t num_buf, qdf_mem_info_t *buf_arr)
@@ -2798,6 +2847,14 @@ int cds_smmu_map_unmap(bool map, uint32_t num_buf, qdf_mem_info_t *buf_arr)
 }
 #endif
 
+#else
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0))
+QDF_STATUS cds_smmu_mem_map_setup(qdf_device_t osdev, bool ipa_present)
+{
+	osdev->smmu_s1_enabled = false;
+	osdev->domain = NULL;
+	return QDF_STATUS_SUCCESS;
+}
 #else
 QDF_STATUS cds_smmu_mem_map_setup(qdf_device_t osdev, bool ipa_present)
 {
@@ -2805,6 +2862,7 @@ QDF_STATUS cds_smmu_mem_map_setup(qdf_device_t osdev, bool ipa_present)
 	osdev->iommu_mapping = NULL;
 	return QDF_STATUS_SUCCESS;
 }
+#endif
 
 int cds_smmu_map_unmap(bool map, uint32_t num_buf, qdf_mem_info_t *buf_arr)
 {