diff --git a/core/hdd/inc/wlan_hdd_main.h b/core/hdd/inc/wlan_hdd_main.h index e3ff6165781e..c0df974aadf8 100644 --- a/core/hdd/inc/wlan_hdd_main.h +++ b/core/hdd/inc/wlan_hdd_main.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2012-2021 The Linux Foundation. All rights reserved. - * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -1152,6 +1152,7 @@ struct hdd_chan_change_params { * @user: user context to prevent/allow runtime pm * @is_user_wakelock_acquired: boolean to check if user wakelock status * @monitor_mode: monitor mode context to prevent/allow runtime pm + * @stats: stats context to prevent/allow runtime pm * * Runtime PM control for underlying activities */ @@ -1161,6 +1162,7 @@ struct hdd_runtime_pm_context { qdf_runtime_lock_t user; bool is_user_wakelock_acquired; qdf_runtime_lock_t monitor_mode; + qdf_runtime_lock_t stats; }; /* diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index 692fca6f8892..b11865e4bd82 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2012-2021 The Linux Foundation. All rights reserved. - * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -1437,6 +1437,7 @@ static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) qdf_runtime_lock_init(&ctx->connect); qdf_runtime_lock_init(&ctx->user); qdf_runtime_lock_init(&ctx->monitor_mode); + qdf_runtime_lock_init(&ctx->stats); ctx->is_user_wakelock_acquired = false; @@ -1456,6 +1457,7 @@ static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) if (ctx->is_user_wakelock_acquired) qdf_runtime_pm_allow_suspend(&ctx->user); + qdf_runtime_lock_deinit(&ctx->stats); qdf_runtime_lock_deinit(&ctx->monitor_mode); qdf_runtime_lock_deinit(&ctx->user); qdf_runtime_lock_deinit(&ctx->connect); diff --git a/core/hdd/src/wlan_hdd_stats.c b/core/hdd/src/wlan_hdd_stats.c index 8c495ff61814..2679dfd7e622 100644 --- a/core/hdd/src/wlan_hdd_stats.c +++ b/core/hdd/src/wlan_hdd_stats.c @@ -2010,6 +2010,8 @@ static int wlan_hdd_send_ll_stats_req(struct hdd_adapter *adapter, return -ENOMEM; } + qdf_runtime_pm_prevent_suspend(&hdd_ctx->runtime_context.stats); + cookie = osif_request_cookie(request); priv = osif_request_priv(request); @@ -2056,6 +2058,8 @@ exit: hdd_exit(); osif_request_put(request); + qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.stats); + return ret; } @@ -6853,16 +6857,23 @@ int wlan_hdd_get_station_stats(struct hdd_adapter *adapter) int ret = 0; struct stats_event *stats; struct wlan_objmgr_vdev *vdev; + struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); if (!get_station_fw_request_needed) { hdd_debug("return cached get_station stats"); return 0; } + ret = wlan_hdd_validate_context(hdd_ctx); + if (ret) + return ret; + vdev = hdd_objmgr_get_vdev(adapter); if (!vdev) return -EINVAL; + qdf_runtime_pm_prevent_suspend(&hdd_ctx->runtime_context.stats); + stats = wlan_cfg80211_mc_cp_stats_get_station_stats(vdev, &ret); if (ret || !stats) { wlan_cfg80211_mc_cp_stats_free_stats_event(stats); @@ -6875,6 +6886,8 @@ int wlan_hdd_get_station_stats(struct hdd_adapter *adapter) wlan_cfg80211_mc_cp_stats_free_stats_event(stats); out: + qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.stats); + hdd_objmgr_put_vdev(vdev); return ret; }