From acef017b76885729478b61920ef292a4480971f3 Mon Sep 17 00:00:00 2001 From: Anuj Khera Date: Mon, 15 Jul 2024 16:02:14 +0530 Subject: [PATCH] cnss2: Add support to check if IPA and WLAN share common dma pool Add support to check if IPA and WLAN share a common dma pool and based on that take descision to map the rx buffers or not in IPA use case scenarios Change-Id: I5d684db1cffc9f04b962cf7bdf0305b7d5e1df23 CRs-Fixed: 3878739 --- cnss2/main.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++ cnss2/main.h | 1 + inc/cnss2.h | 1 + 3 files changed, 56 insertions(+) diff --git a/cnss2/main.c b/cnss2/main.c index 93b4aacb2d..361c967c4b 100644 --- a/cnss2/main.c +++ b/cnss2/main.c @@ -700,6 +700,60 @@ bool cnss_audio_is_direct_link_supported(struct device *dev) } EXPORT_SYMBOL(cnss_audio_is_direct_link_supported); +/** + * cnss_ipa_wlan_shared_smmu_supported: Check whether shared SMMU context bank + * can be used between IPA and WLAN. + * @dev: Device + * + * Return: TRUE if supported, FALSE on failure or if not supported + */ +bool cnss_ipa_wlan_shared_smmu_supported(struct device *dev) +{ + struct cnss_plat_data *plat_priv = cnss_bus_dev_to_plat_priv(dev); + struct device_node *ipa_wlan_smmu_node; + struct device_node *cnss_iommu_group_node; + struct device_node *ipa_iommu_group_node; + + if (!plat_priv) { + cnss_pr_err("plat_priv not available for IPA Shared CB cap\n"); + return false; + } + + ipa_wlan_smmu_node = of_find_compatible_node(NULL, NULL, + "qcom,ipa-smmu-wlan-cb"); + if (!ipa_wlan_smmu_node) { + cnss_pr_err("ipa-smmu-wlan-cb not enabled"); + return false; + } + + ipa_iommu_group_node = of_parse_phandle(ipa_wlan_smmu_node, + "qcom,iommu-group", 0); + of_node_put(ipa_wlan_smmu_node); + + if (!ipa_iommu_group_node) { + cnss_pr_err("Unable to get ipa iommu group phandle"); + return false; + } + of_node_put(ipa_iommu_group_node); + + cnss_iommu_group_node = of_parse_phandle(dev->of_node, + "qcom,iommu-group", 0); + if (!cnss_iommu_group_node) { + cnss_pr_err("Unable to get cnss iommu group phandle"); + return false; + } + of_node_put(cnss_iommu_group_node); + + if (cnss_iommu_group_node == ipa_iommu_group_node) { + plat_priv->ipa_shared_cb_enable = true; + cnss_pr_info("CNSS and IPA share IOMMU group"); + } else { + cnss_pr_info("CNSS and IPA do not share IOMMU group"); + } + + return plat_priv->ipa_shared_cb_enable; +} +EXPORT_SYMBOL(cnss_ipa_wlan_shared_smmu_supported); void cnss_request_pm_qos(struct device *dev, u32 qos_val) { diff --git a/cnss2/main.h b/cnss2/main.h index d19ae66117..b8573cd775 100644 --- a/cnss2/main.h +++ b/cnss2/main.h @@ -649,6 +649,7 @@ struct cnss_plat_data { bool no_bwscale; bool sleep_clk; struct wlchip_serial_id_v01 serial_id; + bool ipa_shared_cb_enable; }; #if IS_ENABLED(CONFIG_ARCH_QCOM) diff --git a/inc/cnss2.h b/inc/cnss2.h index d1d2535f80..5066fc79ab 100644 --- a/inc/cnss2.h +++ b/inc/cnss2.h @@ -452,6 +452,7 @@ extern int cnss_send_buffer_to_afcmem(struct device *dev, const uint8_t *afcdb, extern int cnss_reset_afcmem(struct device *dev, uint8_t slotid); extern bool cnss_get_fw_cap(struct device *dev, enum cnss_fw_caps fw_cap); extern bool cnss_audio_is_direct_link_supported(struct device *dev); +extern bool cnss_ipa_wlan_shared_smmu_supported(struct device *dev); extern int cnss_set_wfc_mode(struct device *dev, struct cnss_wfc_cfg cfg); extern int cnss_thermal_cdev_register(struct device *dev, unsigned long max_state,