From 2fcec840ce8ed551e45064e3f01d869ae4486d55 Mon Sep 17 00:00:00 2001 From: gaurank kathpalia Date: Mon, 5 Aug 2019 17:22:27 +0530 Subject: [PATCH] qcacld-3.0: Take a wakelock till CSA complete Currently the driver sends the CSA IEs in the beacon every beacon interval, and updates the CSA IE count in every beacon. If the wlan gets suspended in between the updation of CSA IEs, the CSA is delayed till the next resume, which could lead to STA kickout event, if there is delay between the CSA period, and the channel switch time. Fix is to take a wakelock till CSA is completed in order to avoid the STA kickout. Change-Id: Iff03476433c755cbddc7568ffbd24ddb81fd1c90 CRs-Fixed: 2504039 --- core/mac/src/pe/include/lim_session.h | 4 ++++ core/mac/src/pe/lim/lim_process_sme_req_messages.c | 7 +++++++ core/mac/src/pe/lim/lim_send_sme_rsp_messages.c | 3 +++ core/mac/src/pe/lim/lim_session.c | 5 +++++ core/mac/src/pe/lim/lim_utils.h | 1 + 5 files changed, 20 insertions(+) diff --git a/core/mac/src/pe/include/lim_session.h b/core/mac/src/pe/include/lim_session.h index 1530d9b227b2..c68218630a81 100644 --- a/core/mac/src/pe/include/lim_session.h +++ b/core/mac/src/pe/include/lim_session.h @@ -132,6 +132,8 @@ struct obss_detection_cfg { * @vdev: the actual vdev for which this entry is applicable * @connected_akm: AKM of current connection * @is_adaptive_11R_connection: flag to check if we are connecting + * @ap_ecsa_wakelock: wakelock to complete CSA operation. + * @ap_ecsa_runtime_lock: runtime lock to complete SAP CSA operation. * to Adaptive 11R network */ struct pe_session { @@ -492,6 +494,8 @@ struct pe_session { qdf_mc_timer_t protection_fields_reset_timer; /* timer to decrement CSA/ECSA count */ qdf_mc_timer_t ap_ecsa_timer; + qdf_wake_lock_t ap_ecsa_wakelock; + qdf_runtime_lock_t ap_ecsa_runtime_lock; struct mac_context *mac_ctx; /* * variable to store state of various protection struct like diff --git a/core/mac/src/pe/lim/lim_process_sme_req_messages.c b/core/mac/src/pe/lim/lim_process_sme_req_messages.c index f6cd60489bb0..a4086845e25b 100644 --- a/core/mac/src/pe/lim/lim_process_sme_req_messages.c +++ b/core/mac/src/pe/lim/lim_process_sme_req_messages.c @@ -5719,6 +5719,13 @@ static void lim_process_sme_dfs_csa_ie_request(struct mac_context *mac_ctx, wider_bw_ch_switch->newCenterChanFreq0 = dfs_csa_ie_req->ch_params.center_freq_seg0; skip_vht: + + /* Take a wakelock for CSA for 5 seconds and release in vdev start */ + + qdf_wake_lock_timeout_acquire(&session_entry->ap_ecsa_wakelock, + MAX_WAKELOCK_FOR_CSA); + qdf_runtime_pm_prevent_suspend(&session_entry->ap_ecsa_runtime_lock); + /* Send CSA IE request from here */ lim_send_dfs_chan_sw_ie_update(mac_ctx, session_entry); diff --git a/core/mac/src/pe/lim/lim_send_sme_rsp_messages.c b/core/mac/src/pe/lim/lim_send_sme_rsp_messages.c index 064def093637..76f8de048442 100644 --- a/core/mac/src/pe/lim/lim_send_sme_rsp_messages.c +++ b/core/mac/src/pe/lim/lim_send_sme_rsp_messages.c @@ -1937,6 +1937,9 @@ lim_send_sme_ap_channel_switch_resp(struct mac_context *mac, enum phy_ch_width ch_width; uint8_t ch_center_freq_seg1; + qdf_runtime_pm_allow_suspend(&pe_session->ap_ecsa_runtime_lock); + qdf_wake_lock_release(&pe_session->ap_ecsa_wakelock, 0); + pSmeSwithChnlParams = qdf_mem_malloc(sizeof(tSwitchChannelParams)); if (!pSmeSwithChnlParams) return; diff --git a/core/mac/src/pe/lim/lim_session.c b/core/mac/src/pe/lim/lim_session.c index 25d9a3da7b4a..31e5feca63ea 100644 --- a/core/mac/src/pe/lim/lim_session.c +++ b/core/mac/src/pe/lim/lim_session.c @@ -664,6 +664,9 @@ struct pe_session *pe_create_session(struct mac_context *mac, else session_ptr->is_obss_reset_timer_initialized = true; + qdf_wake_lock_create(&session_ptr->ap_ecsa_wakelock, + "ap_ecsa_wakelock"); + qdf_runtime_lock_init(&session_ptr->ap_ecsa_runtime_lock); status = qdf_mc_timer_init(&session_ptr->ap_ecsa_timer, QDF_TIMER_TYPE_WAKE_APPS, lim_process_ap_ecsa_timeout, @@ -873,6 +876,8 @@ void pe_delete_session(struct mac_context *mac_ctx, struct pe_session *session) } if (LIM_IS_AP_ROLE(session)) { + qdf_runtime_lock_deinit(&session->ap_ecsa_runtime_lock); + qdf_wake_lock_destroy(&session->ap_ecsa_wakelock); qdf_mc_timer_stop(&session->protection_fields_reset_timer); qdf_mc_timer_destroy(&session->protection_fields_reset_timer); session->dfsIncludeChanSwIe = 0; diff --git a/core/mac/src/pe/lim/lim_utils.h b/core/mac/src/pe/lim/lim_utils.h index c31748e31df7..77bc75e3fa0d 100644 --- a/core/mac/src/pe/lim/lim_utils.h +++ b/core/mac/src/pe/lim/lim_utils.h @@ -102,6 +102,7 @@ typedef enum { #define OBSS_DETECTION_IS_HT_20MHZ(_m) ((_m) & OBSS_DETECTION_HT_20MHZ_BIT_MASK) #define MAX_WAIT_FOR_BCN_TX_COMPLETE 4000 +#define MAX_WAKELOCK_FOR_CSA 5000 #ifdef WLAN_FEATURE_11W typedef union uPmfSaQueryTimerId {