From ceed67eebfe7c42a9bd30f939a3f5843345a45a3 Mon Sep 17 00:00:00 2001 From: Dustin Brown Date: Fri, 26 May 2017 11:57:31 -0700 Subject: [PATCH] qcacld-3.0: Hold wake lock for connection attempt Hold a short wake lock when a connection attempt is made to help ensure the device does not power collapse in the middle. Change-Id: Ia9e20df5481340224fa4c272b58152eec27790a9 CRs-Fixed: 2053126 --- core/hdd/inc/wlan_hdd_power.h | 3 +++ core/hdd/src/wlan_hdd_cfg80211.c | 3 +++ core/hdd/src/wlan_hdd_main.c | 2 ++ core/hdd/src/wlan_hdd_power.c | 6 +++--- core/hdd/src/wlan_hdd_scan.c | 5 +++-- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/core/hdd/inc/wlan_hdd_power.h b/core/hdd/inc/wlan_hdd_power.h index 754c906cd393..3dfc0eefdc65 100644 --- a/core/hdd/inc/wlan_hdd_power.h +++ b/core/hdd/inc/wlan_hdd_power.h @@ -40,6 +40,9 @@ #define HDD_MAX_CMP_PER_PACKET_FILTER 5 +#define HDD_WAKELOCK_TIMEOUT_CONNECT 1000 +#define HDD_WAKELOCK_TIMEOUT_RESUME 1000 + /** * enum pkt_filter_protocol_layer - packet filter protocol layer * @HDD_FILTER_PROTO_TYPE_INVALID: Invalid initial value diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c index bdb5c00b96b2..b0bdcfc7d842 100644 --- a/core/hdd/src/wlan_hdd_cfg80211.c +++ b/core/hdd/src/wlan_hdd_cfg80211.c @@ -13929,6 +13929,8 @@ static int wlan_hdd_cfg80211_connect_start(hdd_adapter_t *pAdapter, qdf_runtime_pm_prevent_suspend(pAdapter->connect_rpm_ctx. connect); + hdd_prevent_suspend_timeout(HDD_WAKELOCK_TIMEOUT_CONNECT, + WIFI_POWER_EVENT_WAKELOCK_CONNECT); qdf_status = sme_roam_connect(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, pRoamProfile, &roamId); @@ -13946,6 +13948,7 @@ static int wlan_hdd_cfg80211_connect_start(hdd_adapter_t *pAdapter, eConnectionState_NotConnected); qdf_runtime_pm_allow_suspend(pAdapter->connect_rpm_ctx. connect); + hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); } /* Reset connect_in_progress */ diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index 58cb8ea6150a..ea1b2a525d2b 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -4542,6 +4542,7 @@ void hdd_connect_result(struct net_device *dev, const u8 *bssid, status, gfp, connect_timeout, timeout_reason); qdf_runtime_pm_allow_suspend(padapter->connect_rpm_ctx.connect); + hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); } #else void hdd_connect_result(struct net_device *dev, const u8 *bssid, @@ -4556,6 +4557,7 @@ void hdd_connect_result(struct net_device *dev, const u8 *bssid, cfg80211_connect_result(dev, bssid, req_ie, req_ie_len, resp_ie, resp_ie_len, status, gfp); qdf_runtime_pm_allow_suspend(padapter->connect_rpm_ctx.connect); + hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); } #endif diff --git a/core/hdd/src/wlan_hdd_power.c b/core/hdd/src/wlan_hdd_power.c index 1fa3be58d497..27fcddefcc07 100644 --- a/core/hdd/src/wlan_hdd_power.c +++ b/core/hdd/src/wlan_hdd_power.c @@ -87,7 +87,6 @@ #else #define HDD_SSR_BRING_UP_TIME 30000 #endif -#define HDD_WAKE_LOCK_RESUME_DURATION 1000 /* Type declarations */ @@ -1706,7 +1705,7 @@ static int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy) * process the connect request to AP */ hdd_prevent_suspend_timeout( - HDD_WAKE_LOCK_RESUME_DURATION, + HDD_WAKELOCK_TIMEOUT_RESUME, WIFI_POWER_EVENT_WAKELOCK_RESUME_WLAN); cfg80211_sched_scan_results(pHddCtx->wiphy); } @@ -1994,7 +1993,8 @@ static void hdd_start_dhcp_ind(hdd_adapter_t *adapter) hdd_debug("DHCP start indicated through power save"); qdf_runtime_pm_prevent_suspend(adapter->connect_rpm_ctx.connect); - hdd_prevent_suspend_timeout(1000, WIFI_POWER_EVENT_WAKELOCK_DHCP); + hdd_prevent_suspend_timeout(HDD_WAKELOCK_TIMEOUT_CONNECT, + WIFI_POWER_EVENT_WAKELOCK_DHCP); sme_dhcp_start_ind(hdd_ctx->hHal, adapter->device_mode, adapter->macAddressCurrent.bytes, adapter->sessionId); diff --git a/core/hdd/src/wlan_hdd_scan.c b/core/hdd/src/wlan_hdd_scan.c index f3dc47399ef4..1bdef9282b80 100644 --- a/core/hdd/src/wlan_hdd_scan.c +++ b/core/hdd/src/wlan_hdd_scan.c @@ -44,6 +44,7 @@ #include "wlan_hdd_trace.h" #include "wlan_hdd_scan.h" #include "wlan_policy_mgr_api.h" +#include "wlan_hdd_power.h" #include "wma_api.h" #include "cds_utils.h" @@ -1304,8 +1305,8 @@ allow_suspend: * app's is suspending and not ableto process the connect * request to AP */ - hdd_prevent_suspend_timeout(1000, - WIFI_POWER_EVENT_WAKELOCK_SCAN); + hdd_prevent_suspend_timeout(HDD_WAKELOCK_TIMEOUT_CONNECT, + WIFI_POWER_EVENT_WAKELOCK_SCAN); } else { /* Release the spin lock */ qdf_spin_unlock(&hddctx->hdd_scan_req_q_lock);