From e3c95fdc045859a28ef628b792df898aa40ea71f Mon Sep 17 00:00:00 2001 From: Yue Ma Date: Fri, 27 Mar 2020 15:14:21 -0700 Subject: [PATCH] qcacmn: Enhance runtime PM enablement check Currently HIF runtime PM APIs will check runtime PM enablement using pm_runtime_enabled() by checking for disable_depth which can be changed at any time. This may cause usage count imbalance since the HIF API may skip calling the corresponding runtime PM framework API to increase or decrease usage count. Enhance runtime PM enablement check so that it will always honor WLAN ini config first. Change-Id: I4b2863ef7fa0dcd6fd61b776e6cb0ab109ffb3ec CRs-fixed: 2647986 --- hif/src/pcie/if_pci.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/hif/src/pcie/if_pci.c b/hif/src/pcie/if_pci.c index 7cc79e1c3f7f..ab8b5ada6906 100644 --- a/hif/src/pcie/if_pci.c +++ b/hif/src/pcie/if_pci.c @@ -891,6 +891,16 @@ end: } #ifdef FEATURE_RUNTIME_PM +static bool hif_pci_pm_runtime_enabled(struct hif_pci_softc *sc) +{ + struct hif_softc *scn = HIF_GET_SOFTC(sc); + + if (scn->hif_config.enable_runtime_pm) + return true; + + return pm_runtime_enabled(sc->dev); +} + static const char *hif_pm_runtime_state_to_string(uint32_t state) { switch (state) { @@ -1307,7 +1317,7 @@ int hif_pm_runtime_sync_resume(struct hif_opaque_softc *hif_ctx) if (!sc) return -EINVAL; - if (!pm_runtime_enabled(sc->dev)) + if (!hif_pci_pm_runtime_enabled(sc)) return 0; pm_state = qdf_atomic_read(&sc->pm_state); @@ -3977,7 +3987,7 @@ int hif_pm_runtime_get_sync(struct hif_opaque_softc *hif_ctx) if (!sc) return -EINVAL; - if (!pm_runtime_enabled(sc->dev)) + if (!hif_pci_pm_runtime_enabled(sc)) return 0; pm_state = qdf_atomic_read(&sc->pm_state); @@ -4024,7 +4034,7 @@ int hif_pm_runtime_put_sync_suspend(struct hif_opaque_softc *hif_ctx) if (!sc) return -EINVAL; - if (!pm_runtime_enabled(sc->dev)) + if (!hif_pci_pm_runtime_enabled(sc)) return 0; usage_count = atomic_read(&sc->dev->power.usage_count); @@ -4053,7 +4063,7 @@ int hif_pm_runtime_request_resume(struct hif_opaque_softc *hif_ctx) if (!sc) return -EINVAL; - if (!pm_runtime_enabled(sc->dev)) + if (!hif_pci_pm_runtime_enabled(sc)) return 0; pm_state = qdf_atomic_read(&sc->pm_state); @@ -4088,7 +4098,7 @@ void hif_pm_runtime_get_noresume(struct hif_opaque_softc *hif_ctx) if (!sc) return; - if (!pm_runtime_enabled(sc->dev)) + if (!hif_pci_pm_runtime_enabled(sc)) return; HIF_PM_STATS_RUNTIME_GET_RECORD(sc); @@ -4120,7 +4130,7 @@ int hif_pm_runtime_get(struct hif_opaque_softc *hif_ctx) return -EFAULT; } - if (!pm_runtime_enabled(sc->dev)) + if (!hif_pci_pm_runtime_enabled(sc)) return 0; pm_state = qdf_atomic_read(&sc->pm_state); @@ -4188,7 +4198,7 @@ int hif_pm_runtime_put(struct hif_opaque_softc *hif_ctx) return -EFAULT; } - if (!pm_runtime_enabled(sc->dev)) + if (!hif_pci_pm_runtime_enabled(sc)) return 0; usage_count = atomic_read(&sc->dev->power.usage_count); @@ -4234,7 +4244,7 @@ int hif_pm_runtime_put_noidle(struct hif_opaque_softc *hif_ctx) if (!sc) return -EINVAL; - if (!pm_runtime_enabled(sc->dev)) + if (!hif_pci_pm_runtime_enabled(sc)) return 0; usage_count = atomic_read(&sc->dev->power.usage_count);