diff options
author | Victor Hsu <hsuvictor@google.com> | 2022-08-04 08:12:01 +0000 |
---|---|---|
committer | Victor Hsu <hsuvictor@google.com> | 2022-08-04 08:12:01 +0000 |
commit | bd3486a94ae494c7a25ecf9bceabcec613505909 (patch) | |
tree | 037873a073cbd027c26b4628fdc71b35144bf88a | |
parent | b3bbdb9cf83a472565ede2ae636367f448d79b54 (diff) | |
download | cnss2-bd3486a94ae494c7a25ecf9bceabcec613505909.tar.gz |
cnss: Control L1SS during runtime suspend/resume
Integrate PCIe RC L1SS functions into cnss
suspend/resume flows.
Bug: 240370036
Signed-off-by: Victor Hsu <hsuvictor@google.com>
Change-Id: I220725414108642bc2b2f2a2d90d2dbf84f5dd6b
-rw-r--r-- | cnss2/pci.c | 18 | ||||
-rw-r--r-- | cnss2/pci_platform_google.c | 92 |
2 files changed, 48 insertions, 62 deletions
diff --git a/cnss2/pci.c b/cnss2/pci.c index c908c57..e4dd4b7 100644 --- a/cnss2/pci.c +++ b/cnss2/pci.c @@ -560,8 +560,6 @@ static struct cnss_print_optimize print_optimize; #if IS_ENABLED(CONFIG_WCN_GOOGLE) extern void crash_info_handler(u8 *info); -extern int exynos_pci_prevent_l1(struct device *dev); -extern void exynos_pci_allow_l1(struct device *dev); #endif //CONFIG_WCN_GOOGLE #if IS_ENABLED(CONFIG_MHI_BUS_MISC) @@ -1692,7 +1690,13 @@ retry_mhi_suspend: ret = cnss_mhi_pm_fast_resume(pci_priv, true); cnss_pci_allow_l1(&pci_priv->pci_dev->dev); } else { +#if IS_ENABLED(CONFIG_WCN_GOOGLE) + cnss_pci_prevent_l1(&pci_priv->pci_dev->dev); +#endif ret = mhi_pm_resume(pci_priv->mhi_ctrl); +#if IS_ENABLED(CONFIG_WCN_GOOGLE) + cnss_pci_allow_l1(&pci_priv->pci_dev->dev); +#endif } mutex_unlock(&pci_priv->mhi_ctrl->pm_mutex); break; @@ -3127,10 +3131,6 @@ static int cnss_pci_suspend(struct device *dev) } } -#if IS_ENABLED(CONFIG_WCN_GOOGLE) - exynos_pci_prevent_l1(dev); -#endif - set_bit(CNSS_IN_SUSPEND_RESUME, &plat_priv->driver_state); ret = cnss_pci_suspend_driver(pci_priv); @@ -3154,9 +3154,6 @@ resume_driver: clear_flag: pci_priv->drv_connected_last = 0; clear_bit(CNSS_IN_SUSPEND_RESUME, &plat_priv->driver_state); -#if IS_ENABLED(CONFIG_WCN_GOOGLE) - exynos_pci_allow_l1(dev); -#endif out: return ret; } @@ -3191,9 +3188,6 @@ static int cnss_pci_resume(struct device *dev) pci_priv->drv_connected_last = 0; clear_bit(CNSS_IN_SUSPEND_RESUME, &plat_priv->driver_state); -#if IS_ENABLED(CONFIG_WCN_GOOGLE) - exynos_pci_allow_l1(dev); -#endif out: return ret; diff --git a/cnss2/pci_platform_google.c b/cnss2/pci_platform_google.c index 4267991..1effec6 100644 --- a/cnss2/pci_platform_google.c +++ b/cnss2/pci_platform_google.c @@ -151,13 +151,53 @@ int cnss_set_pci_link(struct cnss_pci_data *pci_priv, bool link_up) int cnss_pci_prevent_l1(struct device *dev) { - return 0; + struct pci_dev *pci_dev = to_pci_dev(dev); + struct cnss_pci_data *pci_priv = cnss_get_pci_priv(pci_dev); + int ret; + + if (!pci_priv) { + cnss_pr_err("pci_priv is NULL\n"); + return -ENODEV; + } + + if (pci_priv->pci_link_state == PCI_LINK_DOWN) { + cnss_pr_err("PCIe link is in suspend state\n"); + return -EIO; + } + + if (pci_priv->pci_link_down_ind) { + cnss_pr_err("PCIe link is down\n"); + return -EIO; + } + + ret = exynos_pcie_rc_l1ss_ctrl(0, PCIE_L1SS_CTRL_WIFI, pci_priv->plat_priv->rc_num); + cnss_pr_dbg("disable PCIe rc L1ss, ret=%d\n", ret); + return ret; } EXPORT_SYMBOL(cnss_pci_prevent_l1); void cnss_pci_allow_l1(struct device *dev) { - return; + struct pci_dev *pci_dev = to_pci_dev(dev); + struct cnss_pci_data *pci_priv = cnss_get_pci_priv(pci_dev); + + if (!pci_priv) { + cnss_pr_err("pci_priv is NULL\n"); + return; + } + + if (pci_priv->pci_link_state == PCI_LINK_DOWN) { + cnss_pr_dbg("PCIe link is in suspend state\n"); + return; + } + + if (pci_priv->pci_link_down_ind) { + cnss_pr_err("PCIe link is down\n"); + return; + } + + cnss_pr_dbg("enable PCIe rc L1ss\n"); + exynos_pcie_rc_l1ss_ctrl(1, PCIE_L1SS_CTRL_WIFI, pci_priv->plat_priv->rc_num); } EXPORT_SYMBOL(cnss_pci_allow_l1); @@ -269,51 +309,3 @@ void crash_info_handler(u8 *info) strncpy(crash_info, info, string_len); crash_info[string_len] = '\0'; } - -int exynos_pci_prevent_l1(struct device *dev) -{ - struct pci_dev *pci_dev = to_pci_dev(dev); - struct cnss_pci_data *pci_priv = cnss_get_pci_priv(pci_dev); - int ret; - - if (!pci_priv) { - cnss_pr_err("pci_priv is NULL\n"); - return -ENODEV; - } - - if (pci_priv->pci_link_state == PCI_LINK_DOWN) { - cnss_pr_err("PCIe link is in suspend state\n"); - return -EIO; - } - - if (pci_priv->pci_link_down_ind) { - cnss_pr_err("PCIe link is down\n"); - return -EIO; - } - - ret = exynos_pcie_rc_l1ss_ctrl(0, PCIE_L1SS_CTRL_WIFI, pci_priv->plat_priv->rc_num); - return ret; -} - -void exynos_pci_allow_l1(struct device *dev) -{ - struct pci_dev *pci_dev = to_pci_dev(dev); - struct cnss_pci_data *pci_priv = cnss_get_pci_priv(pci_dev); - - if (!pci_priv) { - cnss_pr_err("pci_priv is NULL\n"); - return; - } - - if (pci_priv->pci_link_state == PCI_LINK_DOWN) { - cnss_pr_dbg("PCIe link is in suspend state\n"); - return; - } - - if (pci_priv->pci_link_down_ind) { - cnss_pr_err("PCIe link is down\n"); - return; - } - - exynos_pcie_rc_l1ss_ctrl(1, PCIE_L1SS_CTRL_WIFI, pci_priv->plat_priv->rc_num); -} |