diff options
| author | Jingxiang Ge <jge@codeaurora.org> | 2018-01-22 16:21:24 +0800 |
|---|---|---|
| committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2018-01-22 01:31:58 -0800 |
| commit | 452bf9f57334aa016e3cab40f0edd727cc3ca683 (patch) | |
| tree | 50aa9f7c9c5495027626253769ca9e80f3f6cb86 | |
| parent | 6fff8ef66cdd26f66b1deeeb8403587b66bad427 (diff) | |
qcacld-3.0: Fix memleak for pm runtime suspend lock
For wlan0/p2p0, connect_rpm_ctx is deinit in
hdd_cleanup_adapter.
In two cases, memleak will be detected.
1 if stop modules is triggered from __hdd_stop
turn on/off wifi, wait iface_change_wait_time
2 if stop modules is triggered from wlan_hdd_startup
when booting wifi, stay idle, wait iface_change_wait_time
As hdd_cleanup_adapter is only happens when rmmod, so it
doesn't satisfy LONU memleak detection.
Move connect_rpm_ctx from adapter to hdd_context, and
init/deinit following with module start/stop.
Change-Id: Iaa1934594d5ffcf3b90dd2ad41bba4eb62f71119
CRs-Fixed: 2169828
| -rw-r--r-- | core/hdd/inc/wlan_hdd_main.h | 10 | ||||
| -rw-r--r-- | core/hdd/src/wlan_hdd_cfg80211.c | 8 | ||||
| -rw-r--r-- | core/hdd/src/wlan_hdd_main.c | 105 | ||||
| -rw-r--r-- | core/hdd/src/wlan_hdd_power.c | 6 |
4 files changed, 52 insertions, 77 deletions
diff --git a/core/hdd/inc/wlan_hdd_main.h b/core/hdd/inc/wlan_hdd_main.h index 5b4d045134fd..74351bf9f763 100644 --- a/core/hdd/inc/wlan_hdd_main.h +++ b/core/hdd/inc/wlan_hdd_main.h @@ -1246,15 +1246,6 @@ struct hdd_runtime_pm_context { qdf_runtime_lock_t scan; qdf_runtime_lock_t roc; qdf_runtime_lock_t dfs; -}; - -/** - * struct hdd_connect_pm_context - Runtime PM connect context per adapter - * @connect: Runtime Connect Context - * - * Structure to hold runtime pm connect context for each adapter. - */ -struct hdd_connect_pm_context { qdf_runtime_lock_t connect; }; @@ -1537,7 +1528,6 @@ struct hdd_adapter_s { * channel needs to be moved from the existing 2.4GHz channel. */ uint8_t pre_cac_chan; - struct hdd_connect_pm_context connect_rpm_ctx; struct power_stats_response *chip_power_stats; /* rcpi information */ diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c index 315df60b87f5..02495279f517 100644 --- a/core/hdd/src/wlan_hdd_cfg80211.c +++ b/core/hdd/src/wlan_hdd_cfg80211.c @@ -16731,8 +16731,8 @@ static int wlan_hdd_cfg80211_connect_start(hdd_adapter_t *pAdapter, hdd_conn_set_connection_state(pAdapter, eConnectionState_Connecting); - qdf_runtime_pm_prevent_suspend(&pAdapter->connect_rpm_ctx. - connect); + qdf_runtime_pm_prevent_suspend( + &pHddCtx->runtime_context.connect); hdd_prevent_suspend_timeout(HDD_WAKELOCK_TIMEOUT_CONNECT, WIFI_POWER_EVENT_WAKELOCK_CONNECT); @@ -16750,8 +16750,8 @@ static int wlan_hdd_cfg80211_connect_start(hdd_adapter_t *pAdapter, /* change back to NotAssociated */ hdd_conn_set_connection_state(pAdapter, eConnectionState_NotConnected); - qdf_runtime_pm_allow_suspend(&pAdapter->connect_rpm_ctx. - connect); + qdf_runtime_pm_allow_suspend( + &pHddCtx->runtime_context.connect); hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); } diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index 092f47256356..e6c27a8f58bd 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -885,6 +885,43 @@ QDF_STATUS hdd_set_ibss_power_save_params(hdd_adapter_t *adapter) return QDF_STATUS_SUCCESS; } +#ifdef FEATURE_RUNTIME_PM +/** + * hdd_runtime_suspend_context_init() - API to initialize HDD Runtime Contexts + * @hdd_ctx: HDD context + * + * Return: None + */ +static void hdd_runtime_suspend_context_init(hdd_context_t *hdd_ctx) +{ + struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; + + qdf_runtime_lock_init(&ctx->scan); + qdf_runtime_lock_init(&ctx->roc); + qdf_runtime_lock_init(&ctx->dfs); + qdf_runtime_lock_init(&ctx->connect); +} + +/** + * hdd_runtime_suspend_context_deinit() - API to deinit HDD runtime context + * @hdd_ctx: HDD Context + * + * Return: None + */ +static void hdd_runtime_suspend_context_deinit(hdd_context_t *hdd_ctx) +{ + struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; + + qdf_runtime_lock_deinit(&ctx->scan); + qdf_runtime_lock_deinit(&ctx->roc); + qdf_runtime_lock_deinit(&ctx->dfs); + qdf_runtime_lock_deinit(&ctx->connect); +} +#else /* FEATURE_RUNTIME_PM */ +static void hdd_runtime_suspend_context_init(hdd_context_t *hdd_ctx) {} +static void hdd_runtime_suspend_context_deinit(hdd_context_t *hdd_ctx) {} +#endif /* FEATURE_RUNTIME_PM */ + #define INTF_MACADDR_MASK 0x7 void hdd_update_macaddr(hdd_context_t *hdd_ctx, @@ -2140,6 +2177,8 @@ int hdd_wlan_start_modules(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter, goto deinit_config; } + hdd_runtime_suspend_context_init(hdd_ctx); + hdd_ctx->hHal = cds_get_context(QDF_MODULE_ID_SME); if (NULL == hdd_ctx->hHal) { hdd_err("HAL context is null"); @@ -2909,58 +2948,6 @@ void hdd_set_station_ops(struct net_device *pWlanDev) pWlanDev->netdev_ops = &wlan_drv_ops; } -#ifdef FEATURE_RUNTIME_PM -/** - * hdd_runtime_suspend_context_init() - API to initialize HDD Runtime Contexts - * @hdd_ctx: HDD context - * - * Return: None - */ -static void hdd_runtime_suspend_context_init(hdd_context_t *hdd_ctx) -{ - struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; - - qdf_runtime_lock_init(&ctx->scan); - qdf_runtime_lock_init(&ctx->roc); - qdf_runtime_lock_init(&ctx->dfs); -} - -/** - * hdd_runtime_suspend_context_deinit() - API to deinit HDD runtime context - * @hdd_ctx: HDD Context - * - * Return: None - */ -static void hdd_runtime_suspend_context_deinit(hdd_context_t *hdd_ctx) -{ - struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; - - qdf_runtime_lock_deinit(&ctx->scan); - qdf_runtime_lock_deinit(&ctx->roc); - qdf_runtime_lock_deinit(&ctx->dfs); -} - -static void hdd_adapter_runtime_suspend_init(hdd_adapter_t *adapter) -{ - struct hdd_connect_pm_context *ctx = &adapter->connect_rpm_ctx; - - qdf_runtime_lock_init(&ctx->connect); -} - -static void hdd_adapter_runtime_suspend_denit(hdd_adapter_t *adapter) -{ - struct hdd_connect_pm_context *ctx = &adapter->connect_rpm_ctx; - - qdf_runtime_lock_deinit(&ctx->connect); - ctx->connect = NULL; -} -#else /* FEATURE_RUNTIME_PM */ -static void hdd_runtime_suspend_context_init(hdd_context_t *hdd_ctx) {} -static void hdd_runtime_suspend_context_deinit(hdd_context_t *hdd_ctx) {} -static inline void hdd_adapter_runtime_suspend_init(hdd_adapter_t *adapter) {} -static inline void hdd_adapter_runtime_suspend_denit(hdd_adapter_t *adapter) {} -#endif /* FEATURE_RUNTIME_PM */ - /** * hdd_adapter_init_action_frame_random_mac() - Initialze attributes needed for * randomization of SA in management action frames @@ -3086,7 +3073,6 @@ static hdd_adapter_t *hdd_alloc_station_adapter(hdd_context_t *hdd_ctx, /* set pWlanDev's parent to underlying device */ SET_NETDEV_DEV(pWlanDev, hdd_ctx->parent_dev); hdd_wmm_init(adapter); - hdd_adapter_runtime_suspend_init(adapter); spin_lock_init(&adapter->pause_map_lock); adapter->start_time = adapter->last_time = qdf_system_ticks(); } @@ -3515,8 +3501,6 @@ static void hdd_cleanup_adapter(hdd_context_t *hdd_ctx, hdd_adapter_t *adapter, hdd_debugfs_exit(adapter); - hdd_adapter_runtime_suspend_denit(adapter); - /* * The adapter is marked as closed. When hdd_wlan_exit() call returns, * the driver is almost closed and cannot handle either control @@ -5240,6 +5224,7 @@ void hdd_connect_result(struct net_device *dev, const u8 *bssid, { hdd_adapter_t *padapter = (hdd_adapter_t *) netdev_priv(dev); struct cfg80211_bss *bss = NULL; + hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(padapter); if (WLAN_STATUS_SUCCESS == status) { struct ieee80211_channel *chan; @@ -5267,7 +5252,7 @@ void hdd_connect_result(struct net_device *dev, const u8 *bssid, req_ie_len, resp_ie, resp_ie_len, status, gfp, connect_timeout, timeout_reason); } - qdf_runtime_pm_allow_suspend(&padapter->connect_rpm_ctx.connect); + qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.connect); hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); } #else @@ -5279,10 +5264,11 @@ void hdd_connect_result(struct net_device *dev, const u8 *bssid, tSirResultCodes timeout_reason) { hdd_adapter_t *padapter = (hdd_adapter_t *) netdev_priv(dev); + hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(padapter); 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); + qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.connect); hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); } #endif @@ -6257,7 +6243,6 @@ static void hdd_wlan_exit(hdd_context_t *hdd_ctx) hdd_green_ap_deinit(hdd_ctx); hdd_request_manager_deinit(); - hdd_runtime_suspend_context_deinit(hdd_ctx); hdd_close_all_adapters(hdd_ctx, false); hdd_ipa_cleanup(hdd_ctx); @@ -10328,6 +10313,8 @@ int hdd_wlan_stop_modules(hdd_context_t *hdd_ctx, bool ftm_mode) QDF_ASSERT(0); } + hdd_runtime_suspend_context_deinit(hdd_ctx); + qdf_status = cds_close(hdd_ctx->pcds_context); if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { hdd_warn("Failed to stop CDS: %d", qdf_status); @@ -10649,8 +10636,6 @@ int hdd_wlan_startup(struct device *dev) if (QDF_IS_STATUS_ERROR(status)) goto err_close_adapters; - hdd_runtime_suspend_context_init(hdd_ctx); - if (hdd_ctx->config->fIsImpsEnabled) hdd_set_idle_ps_config(hdd_ctx, true); else diff --git a/core/hdd/src/wlan_hdd_power.c b/core/hdd/src/wlan_hdd_power.c index 5538529c758f..4677bbd36484 100644 --- a/core/hdd/src/wlan_hdd_power.c +++ b/core/hdd/src/wlan_hdd_power.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -2161,7 +2161,7 @@ static void hdd_stop_dhcp_ind(hdd_adapter_t *adapter) adapter->macAddressCurrent.bytes, adapter->sessionId); hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_DHCP); - qdf_runtime_pm_allow_suspend(&adapter->connect_rpm_ctx.connect); + qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.connect); } /** @@ -2178,7 +2178,7 @@ static void hdd_start_dhcp_ind(hdd_adapter_t *adapter) hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter); hdd_debug("DHCP start indicated through power save"); - qdf_runtime_pm_prevent_suspend(&adapter->connect_rpm_ctx.connect); + qdf_runtime_pm_prevent_suspend(&hdd_ctx->runtime_context.connect); hdd_prevent_suspend_timeout(HDD_WAKELOCK_TIMEOUT_CONNECT, WIFI_POWER_EVENT_WAKELOCK_DHCP); sme_dhcp_start_ind(hdd_ctx->hHal, adapter->device_mode, |
