From 692cc05e93cf1823122dfa7267faae60f23804d7 Mon Sep 17 00:00:00 2001 From: Houston Hoffman Date: Tue, 10 Nov 2015 18:42:47 -0800 Subject: [PATCH] qcacld-3.0: Log runtime suspend resume occurances Keep track of how many times supesend resume succeeds and fails also mark last busy on a failed runtime suspend or a successful runtime resume. Change-Id: I04df805429e3a9ce91bc3d7f27bfd598396257c9 CRs-Fixed: 935300 --- core/hdd/src/wlan_hdd_driver_ops.c | 8 +++- core/hif/inc/hif.h | 7 ++++ core/hif/src/pcie/if_pci.c | 61 ++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 1 deletion(-) diff --git a/core/hdd/src/wlan_hdd_driver_ops.c b/core/hdd/src/wlan_hdd_driver_ops.c index dc9d1ea26a..ada556907c 100644 --- a/core/hdd/src/wlan_hdd_driver_ops.c +++ b/core/hdd/src/wlan_hdd_driver_ops.c @@ -541,11 +541,14 @@ static int __wlan_hdd_runtime_suspend(void) void *hdd_ctx = cds_get_context(CDF_MODULE_ID_HDD); int status = wlan_hdd_validate_context(hdd_ctx); - if (0 != status) + if (0 != status) { + hif_log_runtime_suspend_failure(); return status; + } if (!hif_can_suspend_link()) { hdd_err("Runtime PM not supported for link up suspend"); + hif_log_runtime_suspend_failure(); return -EINVAL; } @@ -567,6 +570,7 @@ static int __wlan_hdd_runtime_suspend(void) goto resume_hif; hif_runtime_pm_set_state_suspended(); + hif_log_runtime_suspend_success(); return status; resume_hif: @@ -576,6 +580,7 @@ resume_wma: resume_htc: CDF_BUG(!htc_runtime_resume()); set_state: + hif_log_runtime_suspend_failure(); hif_runtime_pm_set_state_on(); return status; } @@ -615,6 +620,7 @@ static int __wlan_hdd_runtime_resume(void) CDF_BUG(!hif_runtime_resume()); CDF_BUG(!wma_runtime_resume()); CDF_BUG(!htc_runtime_resume()); + hif_log_runtime_resume_success(); hif_runtime_pm_set_state_on(); return 0; } diff --git a/core/hif/inc/hif.h b/core/hif/inc/hif.h index 40950c31f0..ec210a9123 100644 --- a/core/hif/inc/hif.h +++ b/core/hif/inc/hif.h @@ -694,6 +694,13 @@ bool hif_can_suspend_link(void); void hif_runtime_pm_set_state_inprogress(void); void hif_runtime_pm_set_state_on(void); void hif_runtime_pm_set_state_suspended(void); + +#ifdef FEATURE_RUNTIME_PM +void hif_log_runtime_suspend_success(void); +void hif_log_runtime_suspend_failure(void); +void hif_log_runtime_resume_success(void); +#endif + int dump_ce_register(struct ol_softc *scn); int ol_copy_ramdump(struct ol_softc *scn); void hif_pktlogmod_exit(void *hif_ctx); diff --git a/core/hif/src/pcie/if_pci.c b/core/hif/src/pcie/if_pci.c index a70811e7e0..af05003a80 100644 --- a/core/hif/src/pcie/if_pci.c +++ b/core/hif/src/pcie/if_pci.c @@ -1883,6 +1883,67 @@ void hif_runtime_pm_set_state_suspended(void) __hif_runtime_pm_set_state(HIF_PM_RUNTIME_STATE_SUSPENDED); } + +#ifdef FEATURE_RUNTIME_PM +static inline struct hif_pci_softc *get_sc(void) +{ + struct ol_softc *scn = cds_get_context(CDF_MODULE_ID_HIF); + + if (NULL == scn) { + HIF_ERROR("%s: Could not disable ASPM scn is null", + __func__); + return NULL; + } + + return scn->hif_sc; +} + +/** + * hif_log_runtime_suspend_success() - log a successful runtime suspend + */ +void hif_log_runtime_suspend_success(void) +{ + struct hif_pci_softc *sc = get_sc(); + if (sc == NULL) + return; + + sc->pm_stats.suspended++; + sc->pm_stats.suspend_jiffies = jiffies; +} + +/** + * hif_log_runtime_suspend_failure() - log a failed runtime suspend + * + * log a failed runtime suspend + * mark last busy to prevent immediate runtime suspend + */ +void hif_log_runtime_suspend_failure(void) +{ + struct hif_pci_softc *sc = get_sc(); + if (sc == NULL) + return; + + sc->pm_stats.suspend_err++; + hif_pm_runtime_mark_last_busy(sc->dev); +} + +/** + * hif_log_runtime_resume_success() - log a successful runtime resume + * + * log a successfull runtime resume + * mark last busy to prevent immediate runtime suspend + */ +void hif_log_runtime_resume_success(void) +{ + struct hif_pci_softc *sc = get_sc(); + if (sc == NULL) + return; + + sc->pm_stats.resumed++; + hif_pm_runtime_mark_last_busy(sc->dev); +} +#endif + /** * hif_runtime_suspend() - do the bus suspend part of a runtime suspend *