From 74ae456ff0103089ab85ded901ab3318a25ba879 Mon Sep 17 00:00:00 2001 From: Lincoln Tran Date: Thu, 4 Mar 2021 11:14:35 -0800 Subject: [PATCH] qcacld-3.0: Fix regulatory update event If set country fails, disable the flag stating the update is in progress. Otherwise, all subsequent requests will end up waiting for the full timeout period. Change-Id: Id35f49b65d5b641d9a0093204dadecc1792ee529 CRs-fixed: 2892388 --- core/hdd/src/wlan_hdd_cfg80211.c | 16 ++++++++++++++++ core/hdd/src/wlan_hdd_hostapd.c | 8 ++++++++ core/hdd/src/wlan_hdd_regulatory.c | 12 ++++++++++-- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c index 56b4c5f1fdda..1eba2c5b683a 100644 --- a/core/hdd/src/wlan_hdd_cfg80211.c +++ b/core/hdd/src/wlan_hdd_cfg80211.c @@ -3057,6 +3057,14 @@ static int __wlan_hdd_cfg80211_do_acs(struct wiphy *wiphy, hdd_debug("waiting for channel list to update"); qdf_wait_for_event_completion(&hdd_ctx->regulatory_update_event, CHANNEL_LIST_UPDATE_TIMEOUT); + /* In case of set country failure in FW, response never comes + * so wait the full timeout, then set in_progress to false. + * If the response comes back, in_progress will already be set + * to false anyways. + */ + qdf_mutex_acquire(&hdd_ctx->regulatory_status_lock); + hdd_ctx->is_regulatory_update_in_progress = false; + qdf_mutex_release(&hdd_ctx->regulatory_status_lock); } else { qdf_mutex_release(&hdd_ctx->regulatory_status_lock); } @@ -20735,6 +20743,14 @@ static int __wlan_hdd_cfg80211_connect(struct wiphy *wiphy, hdd_debug("waiting for channel list to update"); qdf_wait_for_event_completion(&hdd_ctx->regulatory_update_event, CHANNEL_LIST_UPDATE_TIMEOUT); + /* In case of set country failure in FW, response never comes + * so wait the full timeout, then set in_progress to false. + * If the response comes back, in_progress will already be set + * to false anyways. + */ + qdf_mutex_acquire(&hdd_ctx->regulatory_status_lock); + hdd_ctx->is_regulatory_update_in_progress = false; + qdf_mutex_release(&hdd_ctx->regulatory_status_lock); } else { qdf_mutex_release(&hdd_ctx->regulatory_status_lock); } diff --git a/core/hdd/src/wlan_hdd_hostapd.c b/core/hdd/src/wlan_hdd_hostapd.c index e2c0381af63d..ce71305fb029 100644 --- a/core/hdd/src/wlan_hdd_hostapd.c +++ b/core/hdd/src/wlan_hdd_hostapd.c @@ -6486,6 +6486,14 @@ static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy, hdd_debug("waiting for channel list to update"); qdf_wait_for_event_completion(&hdd_ctx->regulatory_update_event, CHANNEL_LIST_UPDATE_TIMEOUT); + /* In case of set country failure in FW, response never comes + * so wait the full timeout, then set in_progress to false. + * If the response comes back, in_progress will already be set + * to false anyways. + */ + qdf_mutex_acquire(&hdd_ctx->regulatory_status_lock); + hdd_ctx->is_regulatory_update_in_progress = false; + qdf_mutex_release(&hdd_ctx->regulatory_status_lock); } else { qdf_mutex_release(&hdd_ctx->regulatory_status_lock); } diff --git a/core/hdd/src/wlan_hdd_regulatory.c b/core/hdd/src/wlan_hdd_regulatory.c index bf16251d309c..0e3e977f2b3f 100644 --- a/core/hdd/src/wlan_hdd_regulatory.c +++ b/core/hdd/src/wlan_hdd_regulatory.c @@ -757,8 +757,12 @@ int hdd_reg_set_country(struct hdd_context *hdd_ctx, char *country_code) qdf_mutex_release(&hdd_ctx->regulatory_status_lock); status = ucfg_reg_set_country(hdd_ctx->pdev, cc); - if (QDF_IS_STATUS_ERROR(status)) + if (QDF_IS_STATUS_ERROR(status)) { hdd_err("Failed to set country"); + qdf_mutex_acquire(&hdd_ctx->regulatory_status_lock); + hdd_ctx->is_regulatory_update_in_progress = false; + qdf_mutex_release(&hdd_ctx->regulatory_status_lock); + } return qdf_status_to_os_return(status); } @@ -931,8 +935,12 @@ void hdd_reg_notifier(struct wiphy *wiphy, break; } - if (QDF_IS_STATUS_ERROR(status)) + if (QDF_IS_STATUS_ERROR(status)) { hdd_err("Failed to set country"); + qdf_mutex_acquire(&hdd_ctx->regulatory_status_lock); + hdd_ctx->is_regulatory_update_in_progress = false; + qdf_mutex_release(&hdd_ctx->regulatory_status_lock); + } } #else void hdd_reg_notifier(struct wiphy *wiphy,