From 0dffbe08451fa31fb1c8e06532c50838533fec77 Mon Sep 17 00:00:00 2001 From: Rajeev Kumar Date: Wed, 15 Apr 2020 12:55:13 -0700 Subject: [PATCH] qcacmn: Add validation assert for runtime pm get/put out of sync As part of HIF runtime PM close add assert to make sure no runtime PM user has missed any put which may lead to runtime PM getting disabled at runtime. This assert ensures all runtime PM users have get and put in sync. Change-Id: I6663be013e85b8a262ccc0f60c8bd9c59bac25ef CRs-Fixed: 2665231 --- hif/src/pcie/if_pci.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/hif/src/pcie/if_pci.c b/hif/src/pcie/if_pci.c index ffde3df33722..11b202a8fe16 100644 --- a/hif/src/pcie/if_pci.c +++ b/hif/src/pcie/if_pci.c @@ -39,6 +39,7 @@ #include #include "qdf_status.h" #include "qdf_atomic.h" +#include "qdf_platform.h" #include "pld_common.h" #include "mp_dev.h" #include "hif_debug.h" @@ -1273,6 +1274,25 @@ static void hif_pm_runtime_open(struct hif_pci_softc *sc) INIT_LIST_HEAD(&sc->prevent_suspend_list); } +static void hif_check_for_get_put_out_of_sync(struct hif_pci_softc *sc) +{ + int32_t i; + int32_t get_count, put_count; + + if (qdf_is_fw_down()) + return; + + for (i = 0; i < RTPM_ID_MAX; i++) { + get_count = qdf_atomic_read(&sc->pm_stats.runtime_get_dbgid[i]); + put_count = qdf_atomic_read(&sc->pm_stats.runtime_put_dbgid[i]); + if (get_count != put_count) { + QDF_DEBUG_PANIC("%s get-put out of sync. get %d put %d", + rtpm_string_from_dbgid(i), + get_count, put_count); + } + } +} + /** * hif_pm_runtime_sanitize_on_exit(): sanitize the pm usage count and state * @sc: pci context @@ -1289,6 +1309,8 @@ static void hif_pm_runtime_sanitize_on_exit(struct hif_pci_softc *sc) { struct hif_pm_runtime_lock *ctx, *tmp; + hif_check_for_get_put_out_of_sync(sc); + if (atomic_read(&sc->dev->power.usage_count) != 2) hif_pci_runtime_pm_warn(sc, "Driver Module Closing"); else