diff --git a/core/cds/src/cds_api.c b/core/cds/src/cds_api.c index 2ab8040db2..121350217a 100644 --- a/core/cds/src/cds_api.c +++ b/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) {