From 85d542301d066784f62ec485699a50375e1325ef Mon Sep 17 00:00:00 2001 From: Bapiraju Alla Date: Mon, 23 Nov 2020 13:44:21 +0530 Subject: [PATCH] qcacld-3.0: Add debug infra to detect reference leaks for dev_hold Currently there is no debug infra to detect the API that caused the reference leak for dev_hold. So, It very hard to debug/fix the reference leak issues. To address this, add debug_infra for dev_hold and dev_put calls in the driver. This change also fixes the few reference leaks with hdd_for_each_adapter_dev_held_safe. Change-Id: Icf1adf53c3bd11c715111494bac958c541ef87ea CRs-Fixed: 2825558 --- core/hdd/inc/wlan_hdd_main.h | 156 +++++-- core/hdd/src/wlan_hdd_assoc.c | 19 +- core/hdd/src/wlan_hdd_cfg80211.c | 25 +- core/hdd/src/wlan_hdd_hang_event.c | 15 +- core/hdd/src/wlan_hdd_hostapd.c | 19 +- core/hdd/src/wlan_hdd_ioctl.c | 13 +- core/hdd/src/wlan_hdd_ipa.c | 15 +- core/hdd/src/wlan_hdd_main.c | 484 +++++++++++++++------ core/hdd/src/wlan_hdd_nan_datapath.c | 39 +- core/hdd/src/wlan_hdd_oemdata.c | 8 +- core/hdd/src/wlan_hdd_periodic_sta_stats.c | 12 +- core/hdd/src/wlan_hdd_power.c | 60 ++- core/hdd/src/wlan_hdd_regulatory.c | 12 +- core/hdd/src/wlan_hdd_stats.c | 21 +- 14 files changed, 631 insertions(+), 267 deletions(-) diff --git a/core/hdd/inc/wlan_hdd_main.h b/core/hdd/inc/wlan_hdd_main.h index d6e634915d12..ac3fa3c46475 100644 --- a/core/hdd/inc/wlan_hdd_main.h +++ b/core/hdd/inc/wlan_hdd_main.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2021 The Linux Foundation. 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 @@ -439,6 +439,79 @@ enum hdd_auth_key_mgmt { HDD_AUTH_KEY_MGMT_CCKM = BIT(2) }; +/** + * wlan_net_dev_ref_dbgid - Debug IDs to detect net device reference leaks + */ +/* + * New value added to the enum must also be reflected in function + * net_dev_ref_debug_string_from_id() + */ +typedef enum { + NET_DEV_HOLD_ID_RESERVED = 0, + NET_DEV_HOLD_GET_STA_CONNECTION_IN_PROGRESS = 1, + NET_DEV_HOLD_CHECK_DFS_CHANNEL_FOR_ADAPTER = 2, + NET_DEV_HOLD_GET_SAP_OPERATING_BAND = 3, + NET_DEV_HOLD_RECOVERY_NOTIFIER_CALL = 4, + NET_DEV_HOLD_IS_ANY_STA_CONNECTING = 5, + NET_DEV_HOLD_SAP_DESTROY_CTX_ALL = 6, + NET_DEV_HOLD_DRV_CMD_MAX_TX_POWER = 7, + NET_DEV_HOLD_IPA_SET_TX_FLOW_INFO = 8, + NET_DEV_HOLD_SET_RPS_CPU_MASK = 9, + NET_DEV_HOLD_DFS_INDICATE_RADAR = 10, + NET_DEV_HOLD_MAX_STA_INTERFACE_UP_COUNT_REACHED = 11, + NET_DEV_HOLD_IS_CHAN_SWITCH_IN_PROGRESS = 12, + NET_DEV_HOLD_STA_DESTROY_CTX_ALL = 13, + NET_DEV_HOLD_CHECK_FOR_EXISTING_MACADDR = 14, + NET_DEV_HOLD_DEINIT_ALL_ADAPTERS = 15, + NET_DEV_HOLD_STOP_ALL_ADAPTERS = 16, + NET_DEV_HOLD_RESET_ALL_ADAPTERS = 17, + NET_DEV_HOLD_IS_ANY_INTERFACE_OPEN = 18, + NET_DEV_HOLD_START_ALL_ADAPTERS = 19, + NET_DEV_HOLD_GET_ADAPTER_BY_RAND_MACADDR = 20, + NET_DEV_HOLD_GET_ADAPTER_BY_MACADDR = 21, + NET_DEV_HOLD_GET_ADAPTER_BY_VDEV = 22, + NET_DEV_HOLD_ADAPTER_GET_BY_REFERENCE = 23, + NET_DEV_HOLD_GET_ADAPTER_BY_IFACE_NAME = 24, + NET_DEV_HOLD_GET_ADAPTER = 25, + NET_DEV_HOLD_GET_OPERATING_CHAN_FREQ = 26, + NET_DEV_HOLD_UNREGISTER_WEXT_ALL_ADAPTERS = 27, + NET_DEV_HOLD_ABORT_MAC_SCAN_ALL_ADAPTERS = 28, + NET_DEV_HOLD_ABORT_SCHED_SCAN_ALL_ADAPTERS = 29, + NET_DEV_HOLD_GET_FIRST_VALID_ADAPTER = 30, + NET_DEV_HOLD_CLEAR_RPS_CPU_MASK = 31, + NET_DEV_HOLD_BUS_BW_WORK_HANDLER = 32, + NET_DEV_HOLD_DISPLAY_NETIF_QUEUE_HISTORY_COMPACT = 33, + NET_DEV_HOLD_DISPLAY_NETIF_QUEUE_HISTORY = 34, + NET_DEV_HOLD_CLEAR_NETIF_QUEUE_HISTORY = 35, + NET_DEV_HOLD_UNSAFE_CHANNEL_RESTART_SAP = 36, + NET_DEV_HOLD_INDICATE_MGMT_FRAME = 37, + NET_DEV_HOLD_STATE_INFO_DUMP = 38, + NET_DEV_HOLD_DISABLE_ROAMING = 39, + NET_DEV_HOLD_ENABLE_ROAMING = 40, + NET_DEV_HOLD_AUTO_SHUTDOWN_ENABLE = 41, + NET_DEV_HOLD_GET_CON_SAP_ADAPTER = 42, + NET_DEV_HOLD_IS_ANY_ADAPTER_CONNECTED = 43, + NET_DEV_HOLD_IS_ROAMING_IN_PROGRESS = 44, + NET_DEV_HOLD_DEL_P2P_INTERFACE = 45, + NET_DEV_HOLD_IS_NDP_ALLOWED = 46, + NET_DEV_HOLD_NDI_OPEN = 47, + NET_DEV_HOLD_SEND_OEM_REG_RSP_NLINK_MSG = 48, + NET_DEV_HOLD_PERIODIC_STA_STATS_DISPLAY = 49, + NET_DEV_HOLD_SUSPEND_WLAN = 50, + NET_DEV_HOLD_RESUME_WLAN = 51, + NET_DEV_HOLD_SSR_RESTART_SAP = 52, + NET_DEV_HOLD_SEND_DEFAULT_SCAN_IES = 53, + NET_DEV_HOLD_CFG80211_SUSPEND_WLAN = 54, + NET_DEV_HOLD_COUNTRY_CHANGE_UPDATE_STA = 55, + NET_DEV_HOLD_COUNTRY_CHANGE_UPDATE_SAP = 56, + NET_DEV_HOLD_CACHE_STATION_STATS_CB = 57, + NET_DEV_HOLD_DISPLAY_TXRX_STATS = 58, + NET_DEV_HOLD_GET_MODE_SPECIFIC_IF_COUNT = 59, + + /* Keep it at the end */ + NET_DEV_HOLD_ID_MAX +} wlan_net_dev_ref_dbgid; + /** * struct hdd_tx_rx_histogram - structure to keep track of tx and rx packets * received over 100ms intervals @@ -1445,6 +1518,7 @@ struct hdd_adapter { /* Flag to indicate whether it is a pre cac adapter or not */ bool is_pre_cac_adapter; bool delete_in_progress; + uint8_t net_dev_hold_ref_count[NET_DEV_HOLD_ID_MAX]; }; #define WLAN_HDD_GET_STATION_CTX_PTR(adapter) (&(adapter)->session.station) @@ -2368,16 +2442,24 @@ QDF_STATUS hdd_adapter_iterate(hdd_adapter_iterate_cb cb, void *context); /** - * __hdd_take_ref_and_fetch_front_adapter - Helper macro to lock, fetch front - * adapter, take ref and unlock. - * @hdd_ctx: the global HDD context - * @adapter: an hdd_adapter pointer to use as a cursor + * hdd_adapter_dev_hold_debug - Debug API to call dev_hold + * @adapter: hdd_adapter pointer + * @dbgid: Debug ID corresponding to API that is requesting the dev_hold + * + * Return: none */ -#define __hdd_take_ref_and_fetch_front_adapter(hdd_ctx, adapter) \ - qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock), \ - hdd_get_front_adapter_no_lock(hdd_ctx, &adapter), \ - (adapter) ? dev_hold(adapter->dev) : (false), \ - qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock) +void hdd_adapter_dev_hold_debug(struct hdd_adapter *adapter, + wlan_net_dev_ref_dbgid dbgid); + +/** + * hdd_adapter_dev_put_debug - Debug API to call dev_put + * @adapter: hdd_adapter pointer + * @dbgid: Debug ID corresponding to API that is requesting the dev_put + * + * Return: none + */ +void hdd_adapter_dev_put_debug(struct hdd_adapter *adapter, + wlan_net_dev_ref_dbgid dbgid); /** * __hdd_take_ref_and_fetch_front_adapter_safe - Helper macro to lock, fetch @@ -2385,26 +2467,16 @@ QDF_STATUS hdd_adapter_iterate(hdd_adapter_iterate_cb cb, * @hdd_ctx: the global HDD context * @adapter: an hdd_adapter pointer to use as a cursor * @next_adapter: hdd_adapter pointer to next adapter + * @dbgid: debug ID to detect reference leaks */ #define __hdd_take_ref_and_fetch_front_adapter_safe(hdd_ctx, adapter, \ - next_adapter) \ + next_adapter, dbgid) \ qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock), \ hdd_get_front_adapter_no_lock(hdd_ctx, &adapter), \ - (adapter) ? dev_hold(adapter->dev) : (false), \ + (adapter) ? hdd_adapter_dev_hold_debug(adapter, dbgid) : (false), \ hdd_get_next_adapter_no_lock(hdd_ctx, adapter, &next_adapter), \ - (next_adapter) ? dev_hold(next_adapter->dev) : (false), \ - qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock) - -/** - * __hdd_take_ref_and_fetch_next_adapter - Helper macro to lock, fetch next - * adapter, take ref and unlock. - * @hdd_ctx: the global HDD context - * @adapter: an hdd_adapter pointer to use as a cursor - */ -#define __hdd_take_ref_and_fetch_next_adapter(hdd_ctx, adapter) \ - qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock), \ - hdd_get_next_adapter_no_lock(hdd_ctx, adapter, &adapter), \ - (adapter) ? dev_hold(adapter->dev) : (false), \ + (next_adapter) ? hdd_adapter_dev_hold_debug(next_adapter, dbgid) : \ + (false), \ qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock) /** @@ -2413,13 +2485,15 @@ QDF_STATUS hdd_adapter_iterate(hdd_adapter_iterate_cb cb, * @hdd_ctx: the global HDD context * @adapter: hdd_adapter pointer to use as a cursor * @next_adapter: hdd_adapter pointer to next adapter + * @dbgid: debug ID to detect reference leaks */ #define __hdd_take_ref_and_fetch_next_adapter_safe(hdd_ctx, adapter, \ - next_adapter) \ + next_adapter, dbgid) \ qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock), \ adapter = next_adapter, \ hdd_get_next_adapter_no_lock(hdd_ctx, adapter, &next_adapter), \ - (next_adapter) ? dev_hold(next_adapter->dev) : (false), \ + (next_adapter) ? hdd_adapter_dev_hold_debug(next_adapter, dbgid) : \ + (false), \ qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock) /** @@ -2443,25 +2517,27 @@ QDF_STATUS hdd_adapter_iterate(hdd_adapter_iterate_cb cb, * inside the loop body then the dev_hold has been invoked. * * ***** NOTE ***** - * Before the end of each iteration, dev_put(adapter->dev) must be - * called. Not calling this will keep hold of a reference, thus preventing - * unregister of the netdevice. If the loop is terminated in between with - * return/goto/break statements, dev_put(next_adapter->dev) must be done - * along with dev_put(adapter->dev) before termination of the loop. + * Before the end of each iteration, hdd_adapter_dev_put_debug(adapter, dbgid) + * must be called. Not calling this will keep hold of a reference, thus + * preventing unregister of the netdevice. If the loop is terminated in + * between with return/goto/break statements, + * hdd_adapter_dev_put_debug(next_adapter, dbgid) must be done along with + * hdd_adapter_dev_put_debug(adapter, dbgid) before termination of the loop. * * Usage example: - * hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { - * - * - * dev_put(adapter->dev) - * } + * hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, dbgid) { + * + * + * hdd_adapter_dev_put_debug(adapter, dbgid) + * } */ -#define hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) \ +#define hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, \ + dbgid) \ for (__hdd_take_ref_and_fetch_front_adapter_safe(hdd_ctx, adapter, \ - next_adapter); \ + next_adapter, dbgid); \ __hdd_is_adapter_valid(adapter); \ __hdd_take_ref_and_fetch_next_adapter_safe(hdd_ctx, adapter, \ - next_adapter)) + next_adapter, dbgid)) /** * wlan_hdd_get_adapter_by_vdev_id_from_objmgr() - Fetch adapter from objmgr diff --git a/core/hdd/src/wlan_hdd_assoc.c b/core/hdd/src/wlan_hdd_assoc.c index a29943e74c26..f19f610cf97b 100644 --- a/core/hdd/src/wlan_hdd_assoc.c +++ b/core/hdd/src/wlan_hdd_assoc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2021 The Linux Foundation. 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 @@ -408,13 +408,16 @@ struct hdd_adapter *hdd_get_sta_connection_in_progress( { struct hdd_adapter *adapter = NULL, *next_adapter = NULL; struct hdd_station_ctx *hdd_sta_ctx; + wlan_net_dev_ref_dbgid dbgid = + NET_DEV_HOLD_GET_STA_CONNECTION_IN_PROGRESS; if (!hdd_ctx) { hdd_err("HDD context is NULL"); return NULL; } - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); if ((QDF_STA_MODE == adapter->device_mode) || (QDF_P2P_CLIENT_MODE == adapter->device_mode) || @@ -423,9 +426,10 @@ struct hdd_adapter *hdd_get_sta_connection_in_progress( hdd_sta_ctx->conn_info.conn_state) { hdd_debug("vdev_id %d: Connection is in progress", adapter->vdev_id); - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); if (next_adapter) - dev_put(next_adapter->dev); + hdd_adapter_dev_put_debug(next_adapter, + dbgid); return adapter; } else if ((eConnectionState_Associated == hdd_sta_ctx->conn_info.conn_state) && @@ -434,13 +438,14 @@ struct hdd_adapter *hdd_get_sta_connection_in_progress( adapter->vdev_id)) { hdd_debug("vdev_id %d: Key exchange is in progress", adapter->vdev_id); - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); if (next_adapter) - dev_put(next_adapter->dev); + hdd_adapter_dev_put_debug(next_adapter, + dbgid); return adapter; } } - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } return NULL; } diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c index c92f38370ebd..43e8160e17d0 100644 --- a/core/hdd/src/wlan_hdd_cfg80211.c +++ b/core/hdd/src/wlan_hdd_cfg80211.c @@ -5765,8 +5765,11 @@ static bool wlan_hdd_check_dfs_channel_for_adapter(struct hdd_context *hdd_ctx, struct hdd_adapter *adapter, *next_adapter = NULL; struct hdd_ap_ctx *ap_ctx; struct hdd_station_ctx *sta_ctx; + wlan_net_dev_ref_dbgid dbgid = + NET_DEV_HOLD_CHECK_DFS_CHANNEL_FOR_ADAPTER; - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { if ((device_mode == adapter->device_mode) && (device_mode == QDF_SAP_MODE)) { ap_ctx = @@ -5783,9 +5786,10 @@ static bool wlan_hdd_check_dfs_channel_for_adapter(struct hdd_context *hdd_ctx, hdd_ctx->pdev, ap_ctx->operating_chan_freq)) { hdd_err("SAP running on DFS channel"); - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); if (next_adapter) - dev_put(next_adapter->dev); + hdd_adapter_dev_put_debug(next_adapter, + dbgid); return true; } } @@ -5804,13 +5808,14 @@ static bool wlan_hdd_check_dfs_channel_for_adapter(struct hdd_context *hdd_ctx, hdd_ctx->pdev, sta_ctx->conn_info.chan_freq))) { hdd_err("client connected on DFS channel"); - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); if (next_adapter) - dev_put(next_adapter->dev); + hdd_adapter_dev_put_debug(next_adapter, + dbgid); return true; } } - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } return false; @@ -11965,10 +11970,12 @@ uint8_t hdd_get_sap_operating_band(struct hdd_context *hdd_ctx) struct hdd_adapter *adapter, *next_adapter = NULL; uint32_t operating_chan_freq; uint8_t sap_operating_band = 0; + wlan_net_dev_ref_dbgid dbgid = NET_DEV_HOLD_GET_SAP_OPERATING_BAND; - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { if (adapter->device_mode != QDF_SAP_MODE) { - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); continue; } @@ -11981,7 +11988,7 @@ uint8_t hdd_get_sap_operating_band(struct hdd_context *hdd_ctx) else sap_operating_band = BAND_ALL; - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } return sap_operating_band; diff --git a/core/hdd/src/wlan_hdd_hang_event.c b/core/hdd/src/wlan_hdd_hang_event.c index 93e2f715e3f0..4302180762f8 100644 --- a/core/hdd/src/wlan_hdd_hang_event.c +++ b/core/hdd/src/wlan_hdd_hang_event.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2021, The Linux Foundation. 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 above @@ -50,6 +50,7 @@ static int wlan_hdd_recovery_notifier_call(struct notifier_block *block, struct wlan_objmgr_vdev *vdev; struct hdd_hang_event_fixed_param *cmd; struct hdd_scan_fixed_param *cmd_scan; + wlan_net_dev_ref_dbgid dbgid = NET_DEV_HOLD_RECOVERY_NOTIFIER_CALL; if (!data) return NOTIFY_STOP_MASK; @@ -76,10 +77,11 @@ static int wlan_hdd_recovery_notifier_call(struct notifier_block *block, hdd_hang_data->offset += total_len; } - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { vdev = hdd_objmgr_get_vdev(adapter); if (!vdev) { - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); continue; } total_len = sizeof(*cmd); @@ -87,9 +89,10 @@ static int wlan_hdd_recovery_notifier_call(struct notifier_block *block, if (hdd_hang_data->offset + total_len > QDF_WLAN_HANG_FW_OFFSET) { hdd_objmgr_put_vdev(vdev); - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); if (next_adapter) - dev_put(next_adapter->dev); + hdd_adapter_dev_put_debug(next_adapter, + dbgid); return NOTIFY_STOP_MASK; } cmd = (struct hdd_hang_event_fixed_param *)hdd_buf_ptr; @@ -102,7 +105,7 @@ static int wlan_hdd_recovery_notifier_call(struct notifier_block *block, cmd->vdev_substate = wlan_vdev_mlme_get_substate(vdev); hdd_hang_data->offset += total_len; hdd_objmgr_put_vdev(vdev); - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } return NOTIFY_OK; diff --git a/core/hdd/src/wlan_hdd_hostapd.c b/core/hdd/src/wlan_hdd_hostapd.c index 43357ad36f73..d41689c84481 100644 --- a/core/hdd/src/wlan_hdd_hostapd.c +++ b/core/hdd/src/wlan_hdd_hostapd.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2021 The Linux Foundation. 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 @@ -2898,13 +2898,15 @@ static bool hdd_is_any_sta_connecting(struct hdd_context *hdd_ctx) { struct hdd_adapter *adapter = NULL, *next_adapter = NULL; struct hdd_station_ctx *sta_ctx; + wlan_net_dev_ref_dbgid dbgid = NET_DEV_HOLD_IS_ANY_STA_CONNECTING; if (!hdd_ctx) { hdd_err("HDD context is NULL"); return false; } - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); if ((adapter->device_mode == QDF_STA_MODE) || (adapter->device_mode == QDF_P2P_CLIENT_MODE) || @@ -2913,13 +2915,14 @@ static bool hdd_is_any_sta_connecting(struct hdd_context *hdd_ctx) eConnectionState_Connecting) { hdd_debug("vdev_id %d: connecting", adapter->vdev_id); - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); if (next_adapter) - dev_put(next_adapter->dev); + hdd_adapter_dev_put_debug(next_adapter, + dbgid); return true; } } - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } return false; @@ -3469,10 +3472,12 @@ void hdd_sap_destroy_ctx_all(struct hdd_context *hdd_ctx, bool is_ssr) hdd_debug("destroying all the sap context"); - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + NET_DEV_HOLD_SAP_DESTROY_CTX_ALL) { if (adapter->device_mode == QDF_SAP_MODE) hdd_sap_destroy_ctx(adapter); - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, + NET_DEV_HOLD_SAP_DESTROY_CTX_ALL); } } diff --git a/core/hdd/src/wlan_hdd_ioctl.c b/core/hdd/src/wlan_hdd_ioctl.c index 890f7fc50aa5..0e60e658a779 100644 --- a/core/hdd/src/wlan_hdd_ioctl.c +++ b/core/hdd/src/wlan_hdd_ioctl.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2021 The Linux Foundation. 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 @@ -5155,6 +5155,7 @@ static int drv_cmd_max_tx_power(struct hdd_adapter *adapter, struct qdf_mac_addr bssid = QDF_MAC_ADDR_BCAST_INIT; struct qdf_mac_addr selfmac = QDF_MAC_ADDR_BCAST_INIT; struct hdd_adapter *next_adapter = NULL; + wlan_net_dev_ref_dbgid dbgid = NET_DEV_HOLD_DRV_CMD_MAX_TX_POWER; ret = hdd_parse_setmaxtxpower_command(value, &tx_power); if (ret) { @@ -5162,7 +5163,8 @@ static int drv_cmd_max_tx_power(struct hdd_adapter *adapter, return ret; } - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { /* Assign correct self MAC address */ qdf_copy_macaddr(&bssid, &adapter->mac_addr); @@ -5180,13 +5182,14 @@ static int drv_cmd_max_tx_power(struct hdd_adapter *adapter, if (QDF_STATUS_SUCCESS != status) { hdd_err("Set max tx power failed"); ret = -EINVAL; - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); if (next_adapter) - dev_put(next_adapter->dev); + hdd_adapter_dev_put_debug(next_adapter, + dbgid); goto exit; } hdd_debug("Set max tx power success"); - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } exit: diff --git a/core/hdd/src/wlan_hdd_ipa.c b/core/hdd/src/wlan_hdd_ipa.c index 29bf717eabb7..87edbd5c8316 100644 --- a/core/hdd/src/wlan_hdd_ipa.c +++ b/core/hdd/src/wlan_hdd_ipa.c @@ -55,6 +55,7 @@ void hdd_ipa_set_tx_flow_info(void) void *soc = cds_get_context(QDF_MODULE_ID_SOC); #endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */ struct wlan_objmgr_psoc *psoc; + wlan_net_dev_ref_dbgid dbgid = NET_DEV_HOLD_IPA_SET_TX_FLOW_INFO; hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); if (!hdd_ctx) { @@ -70,7 +71,8 @@ void hdd_ipa_set_tx_flow_info(void) psoc = hdd_ctx->psoc; - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { switch (adapter->device_mode) { case QDF_STA_MODE: sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); @@ -207,7 +209,8 @@ void hdd_ipa_set_tx_flow_info(void) if (!preAdapterContext) { hdd_err("SCC: Previous adapter context NULL"); - dev_put(adapter->dev); + hdd_adapter_dev_put_debug( + adapter, dbgid); continue; } @@ -256,7 +259,8 @@ void hdd_ipa_set_tx_flow_info(void) if (!adapter5) { hdd_err("MCC: 5GHz adapter context NULL"); - dev_put(adapter->dev); + hdd_adapter_dev_put_debug( + adapter, dbgid); continue; } adapter5->tx_flow_low_watermark = @@ -285,7 +289,8 @@ void hdd_ipa_set_tx_flow_info(void) if (!adapter2_4) { hdd_err("MCC: 2.4GHz adapter context NULL"); - dev_put(adapter->dev); + hdd_adapter_dev_put_debug( + adapter, dbgid); continue; } adapter2_4->tx_flow_low_watermark = @@ -318,7 +323,7 @@ void hdd_ipa_set_tx_flow_info(void) } targetChannel = 0; #endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */ - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } } diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index 13fb20ffc69d..6efd2619cc40 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2021 The Linux Foundation. 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 @@ -627,9 +627,11 @@ static void hdd_set_rps_cpu_mask(struct hdd_context *hdd_ctx) { struct hdd_adapter *adapter, *next_adapter = NULL; - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + NET_DEV_HOLD_SET_RPS_CPU_MASK) { hdd_send_rps_ind(adapter); - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, + NET_DEV_HOLD_SET_RPS_CPU_MASK); } } @@ -2630,7 +2632,8 @@ bool hdd_dfs_indicate_radar(struct hdd_context *hdd_ctx) return true; } - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + NET_DEV_HOLD_DFS_INDICATE_RADAR) { ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); if ((QDF_SAP_MODE == adapter->device_mode || @@ -2646,7 +2649,8 @@ bool hdd_dfs_indicate_radar(struct hdd_context *hdd_ctx) cds_get_context(QDF_MODULE_ID_SOC), adapter->vdev_id); } - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, + NET_DEV_HOLD_DFS_INDICATE_RADAR); } return true; @@ -3350,19 +3354,23 @@ static bool hdd_is_chan_switch_in_progress(void) { struct hdd_adapter *adapter = NULL, *next_adapter = NULL; struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); + wlan_net_dev_ref_dbgid dbgid = + NET_DEV_HOLD_IS_CHAN_SWITCH_IN_PROGRESS; - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { if ((adapter->device_mode == QDF_SAP_MODE || adapter->device_mode == QDF_P2P_GO_MODE) && qdf_atomic_read(&adapter->ch_switch_in_progress)) { hdd_debug("channel switch progress for vdev_id %d", adapter->vdev_id); - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); if (next_adapter) - dev_put(next_adapter->dev); + hdd_adapter_dev_put_debug(next_adapter, + dbgid); return true; } - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } return false; @@ -5852,6 +5860,94 @@ error_init_txrx: } #endif +static char *net_dev_ref_debug_string_from_id(wlan_net_dev_ref_dbgid dbgid) +{ + static const char *strings[] = { + "NET_DEV_HOLD_ID_RESERVED", + "NET_DEV_HOLD_GET_STA_CONNECTION_IN_PROGRESS", + "NET_DEV_HOLD_CHECK_DFS_CHANNEL_FOR_ADAPTER", + "NET_DEV_HOLD_GET_SAP_OPERATING_BAND", + "NET_DEV_HOLD_RECOVERY_NOTIFIER_CALL", + "NET_DEV_HOLD_IS_ANY_STA_CONNECTING", + "NET_DEV_HOLD_SAP_DESTROY_CTX_ALL", + "NET_DEV_HOLD_DRV_CMD_MAX_TX_POWER", + "NET_DEV_HOLD_IPA_SET_TX_FLOW_INFO", + "NET_DEV_HOLD_SET_RPS_CPU_MASK", + "NET_DEV_HOLD_DFS_INDICATE_RADAR", + "NET_DEV_HOLD_MAX_STA_INTERFACE_UP_COUNT_REACHED", + "NET_DEV_HOLD_IS_CHAN_SWITCH_IN_PROGRESS", + "NET_DEV_HOLD_STA_DESTROY_CTX_ALL", + "NET_DEV_HOLD_CHECK_FOR_EXISTING_MACADDR", + "NET_DEV_HOLD_DEINIT_ALL_ADAPTERS", + "NET_DEV_HOLD_STOP_ALL_ADAPTERS", + "NET_DEV_HOLD_RESET_ALL_ADAPTERS", + "NET_DEV_HOLD_IS_ANY_INTERFACE_OPEN", + "NET_DEV_HOLD_START_ALL_ADAPTERS", + "NET_DEV_HOLD_GET_ADAPTER_BY_RAND_MACADDR", + "NET_DEV_HOLD_GET_ADAPTER_BY_MACADDR", + "NET_DEV_HOLD_GET_ADAPTER_BY_VDEV", + "NET_DEV_HOLD_ADAPTER_GET_BY_REFERENCE", + "NET_DEV_HOLD_GET_ADAPTER_BY_IFACE_NAME", + "NET_DEV_HOLD_GET_ADAPTER", + "NET_DEV_HOLD_GET_OPERATING_CHAN_FREQ", + "NET_DEV_HOLD_UNREGISTER_WEXT_ALL_ADAPTERS", + "NET_DEV_HOLD_ABORT_MAC_SCAN_ALL_ADAPTERS", + "NET_DEV_HOLD_ABORT_SCHED_SCAN_ALL_ADAPTERS", + "NET_DEV_HOLD_GET_FIRST_VALID_ADAPTER", + "NET_DEV_HOLD_CLEAR_RPS_CPU_MASK", + "NET_DEV_HOLD_BUS_BW_WORK_HANDLER", + "NET_DEV_HOLD_DISPLAY_NETIF_QUEUE_HISTORY_COMPACT", + "NET_DEV_HOLD_DISPLAY_NETIF_QUEUE_HISTORY", + "NET_DEV_HOLD_CLEAR_NETIF_QUEUE_HISTORY", + "NET_DEV_HOLD_UNSAFE_CHANNEL_RESTART_SAP", + "NET_DEV_HOLD_INDICATE_MGMT_FRAME", + "NET_DEV_HOLD_STATE_INFO_DUMP", + "NET_DEV_HOLD_DISABLE_ROAMING", + "NET_DEV_HOLD_ENABLE_ROAMING", + "NET_DEV_HOLD_AUTO_SHUTDOWN_ENABLE", + "NET_DEV_HOLD_GET_CON_SAP_ADAPTER", + "NET_DEV_HOLD_IS_ANY_ADAPTER_CONNECTED", + "NET_DEV_HOLD_IS_ROAMING_IN_PROGRESS", + "NET_DEV_HOLD_DEL_P2P_INTERFACE", + "NET_DEV_HOLD_IS_NDP_ALLOWED", + "NET_DEV_HOLD_NDI_OPEN", + "NET_DEV_HOLD_SEND_OEM_REG_RSP_NLINK_MSG", + "NET_DEV_HOLD_PERIODIC_STA_STATS_DISPLAY", + "NET_DEV_HOLD_SUSPEND_WLAN", + "NET_DEV_HOLD_RESUME_WLAN", + "NET_DEV_HOLD_SSR_RESTART_SAP", + "NET_DEV_HOLD_SEND_DEFAULT_SCAN_IES", + "NET_DEV_HOLD_CFG80211_SUSPEND_WLAN", + "NET_DEV_HOLD_COUNTRY_CHANGE_UPDATE_STA", + "NET_DEV_HOLD_COUNTRY_CHANGE_UPDATE_SAP", + "NET_DEV_HOLD_CACHE_STATION_STATS_CB", + "NET_DEV_HOLD_DISPLAY_TXRX_STATS", + "NET_DEV_HOLD_GET_MODE_SPECIFIC_IF_COUNT", + "NET_DEV_HOLD_ID_MAX"}; + int32_t num_dbg_strings = QDF_ARRAY_SIZE(strings); + + if (dbgid >= num_dbg_strings) { + char *ret = ""; + + hdd_err("Debug string not found for debug id %d", dbgid); + return ret; + } + + return (char *)strings[dbgid]; +} + +static void hdd_check_for_net_dev_ref_leak(struct hdd_adapter *adapter) +{ + int id; + + for (id = 0; id < NET_DEV_HOLD_ID_MAX; id++) { + if (adapter->net_dev_hold_ref_count[id]) { + hdd_err("net_dev hold reference leak detected for debug id: %s", + net_dev_ref_debug_string_from_id(id)); + } + } +} + /** * hdd_deinit_station_mode() - De-initialize the station adapter * @hdd_ctx: global hdd context @@ -5943,10 +6039,12 @@ void hdd_sta_destroy_ctx_all(struct hdd_context *hdd_ctx) { struct hdd_adapter *adapter, *next_adapter = NULL; - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + NET_DEV_HOLD_STA_DESTROY_CTX_ALL) { if (adapter->device_mode == QDF_STA_MODE) hdd_cleanup_conn_info(adapter); - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, + NET_DEV_HOLD_STA_DESTROY_CTX_ALL); } } #endif @@ -5972,6 +6070,7 @@ static void hdd_cleanup_adapter(struct hdd_context *hdd_ctx, qdf_spinlock_destroy(&adapter->vdev_lock); hdd_sta_info_deinit(&adapter->sta_info_list); hdd_sta_info_deinit(&adapter->cache_sta_info_list); + hdd_check_for_net_dev_ref_leak(adapter); wlan_hdd_debugfs_csr_deinit(adapter); @@ -6004,16 +6103,19 @@ static QDF_STATUS hdd_check_for_existing_macaddr(struct hdd_context *hdd_ctx, tSirMacAddr mac_addr) { struct hdd_adapter *adapter, *next_adapter = NULL; + wlan_net_dev_ref_dbgid dbgid = NET_DEV_HOLD_CHECK_FOR_EXISTING_MACADDR; - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { if (!qdf_mem_cmp(adapter->mac_addr.bytes, mac_addr, sizeof(tSirMacAddr))) { - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); if (next_adapter) - dev_put(next_adapter->dev); + hdd_adapter_dev_put_debug(next_adapter, + dbgid); return QDF_STATUS_E_FAILURE; } - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } return QDF_STATUS_SUCCESS; @@ -6514,11 +6616,14 @@ static u8 hdd_get_mode_specific_interface_count(struct hdd_context *hdd_ctx, struct hdd_adapter *adapter = NULL, *next_adapter = NULL; u8 intf_count = 0; - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe( + hdd_ctx, adapter, next_adapter, + NET_DEV_HOLD_GET_MODE_SPECIFIC_IF_COUNT) { if (adapter->device_mode == mode) intf_count++; - dev_put(adapter->dev); + hdd_adapter_dev_put_debug( + adapter, NET_DEV_HOLD_GET_MODE_SPECIFIC_IF_COUNT); } return intf_count; } @@ -7395,9 +7500,11 @@ void hdd_deinit_all_adapters(struct hdd_context *hdd_ctx, bool rtnl_held) hdd_enter(); - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + NET_DEV_HOLD_DEINIT_ALL_ADAPTERS) { hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, + NET_DEV_HOLD_DEINIT_ALL_ADAPTERS); } hdd_exit(); @@ -7412,9 +7519,11 @@ QDF_STATUS hdd_stop_all_adapters(struct hdd_context *hdd_ctx) if (hdd_ctx->sap_pre_cac_work.fn) cds_flush_work(&hdd_ctx->sap_pre_cac_work); - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + NET_DEV_HOLD_STOP_ALL_ADAPTERS) { hdd_stop_adapter(hdd_ctx, adapter); - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, + NET_DEV_HOLD_STOP_ALL_ADAPTERS); } hdd_exit(); @@ -7566,7 +7675,8 @@ QDF_STATUS hdd_reset_all_adapters(struct hdd_context *hdd_ctx) ucfg_mlme_get_sap_internal_restart(hdd_ctx->psoc, &value); - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + NET_DEV_HOLD_RESET_ALL_ADAPTERS) { hdd_info("[SSR] reset adapter with device mode %s(%d)", qdf_opmode_str(adapter->device_mode), adapter->device_mode); @@ -7619,7 +7729,8 @@ QDF_STATUS hdd_reset_all_adapters(struct hdd_context *hdd_ctx) hdd_set_disconnect_status(adapter, false); hdd_debug("Flush any mgmt references held by peer"); hdd_stop_adapter(hdd_ctx, adapter); - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, + NET_DEV_HOLD_RESET_ALL_ADAPTERS); } hdd_exit(); @@ -7630,21 +7741,24 @@ QDF_STATUS hdd_reset_all_adapters(struct hdd_context *hdd_ctx) bool hdd_is_any_interface_open(struct hdd_context *hdd_ctx) { struct hdd_adapter *adapter, *next_adapter = NULL; + wlan_net_dev_ref_dbgid dbgid = NET_DEV_HOLD_IS_ANY_INTERFACE_OPEN; if (hdd_get_conparam() == QDF_GLOBAL_FTM_MODE) { hdd_info("FTM mode, don't close the module"); return true; } - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags) || test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); if (next_adapter) - dev_put(next_adapter->dev); + hdd_adapter_dev_put_debug(next_adapter, + dbgid); return true; } - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } return false; @@ -8340,13 +8454,15 @@ QDF_STATUS hdd_start_all_adapters(struct hdd_context *hdd_ctx) eConnectionState conn_state; bool value; struct wlan_objmgr_vdev *vdev; + wlan_net_dev_ref_dbgid dbgid = NET_DEV_HOLD_START_ALL_ADAPTERS; hdd_enter(); - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { if (!hdd_is_interface_up(adapter) && adapter->device_mode != QDF_NDI_MODE) { - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); continue; } @@ -8487,19 +8603,20 @@ QDF_STATUS hdd_start_all_adapters(struct hdd_context *hdd_ctx) * applicable to all interfaces */ wlan_hdd_cfg80211_register_frames(adapter); - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { if (!hdd_is_interface_up(adapter)) { - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); continue; } if (adapter->device_mode == QDF_P2P_GO_MODE) hdd_stop_p2p_go(adapter); - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } hdd_exit(); @@ -8507,6 +8624,35 @@ QDF_STATUS hdd_start_all_adapters(struct hdd_context *hdd_ctx) return QDF_STATUS_SUCCESS; } +void hdd_adapter_dev_hold_debug(struct hdd_adapter *adapter, + wlan_net_dev_ref_dbgid dbgid) +{ + if (dbgid >= NET_DEV_HOLD_ID_MAX) { + hdd_err("Invalid debug id: %d", dbgid); + QDF_BUG(0); + } + dev_hold(adapter->dev); + adapter->net_dev_hold_ref_count[dbgid]++; +} + +void hdd_adapter_dev_put_debug(struct hdd_adapter *adapter, + wlan_net_dev_ref_dbgid dbgid) +{ + if (dbgid >= NET_DEV_HOLD_ID_MAX) { + hdd_err("Invalid debug id: %d", dbgid); + QDF_BUG(0); + } + + if (adapter->net_dev_hold_ref_count[dbgid] == 0) { + hdd_err("dev_put detected without dev_hold for debug id: %s", + net_dev_ref_debug_string_from_id(dbgid)); + QDF_BUG(0); + } + + dev_put(adapter->dev); + adapter->net_dev_hold_ref_count[dbgid]--; +} + QDF_STATUS hdd_get_front_adapter(struct hdd_context *hdd_ctx, struct hdd_adapter **out_adapter) { @@ -8695,19 +8841,23 @@ struct hdd_adapter *hdd_get_adapter_by_rand_macaddr( struct hdd_context *hdd_ctx, tSirMacAddr mac_addr) { struct hdd_adapter *adapter, *next_adapter = NULL; + wlan_net_dev_ref_dbgid dbgid = + NET_DEV_HOLD_GET_ADAPTER_BY_RAND_MACADDR; - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { if ((adapter->device_mode == QDF_STA_MODE || adapter->device_mode == QDF_P2P_CLIENT_MODE || adapter->device_mode == QDF_P2P_DEVICE_MODE) && ucfg_p2p_check_random_mac(hdd_ctx->psoc, adapter->vdev_id, mac_addr)) { - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); if (next_adapter) - dev_put(next_adapter->dev); + hdd_adapter_dev_put_debug(next_adapter, + dbgid); return adapter; } - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } return NULL; @@ -8717,16 +8867,19 @@ struct hdd_adapter *hdd_get_adapter_by_macaddr(struct hdd_context *hdd_ctx, tSirMacAddr mac_addr) { struct hdd_adapter *adapter, *next_adapter = NULL; + wlan_net_dev_ref_dbgid dbgid = NET_DEV_HOLD_GET_ADAPTER_BY_MACADDR; - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { if (!qdf_mem_cmp(adapter->mac_addr.bytes, mac_addr, sizeof(tSirMacAddr))) { - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); if (next_adapter) - dev_put(next_adapter->dev); + hdd_adapter_dev_put_debug(next_adapter, + dbgid); return adapter; } - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } return NULL; @@ -8736,15 +8889,18 @@ struct hdd_adapter *hdd_get_adapter_by_vdev(struct hdd_context *hdd_ctx, uint32_t vdev_id) { struct hdd_adapter *adapter, *next_adapter = NULL; + wlan_net_dev_ref_dbgid dbgid = NET_DEV_HOLD_GET_ADAPTER_BY_VDEV; - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { if (adapter->vdev_id == vdev_id) { - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); if (next_adapter) - dev_put(next_adapter->dev); + hdd_adapter_dev_put_debug(next_adapter, + dbgid); return adapter; } - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } return NULL; @@ -8754,16 +8910,19 @@ struct hdd_adapter *hdd_adapter_get_by_reference(struct hdd_context *hdd_ctx, struct hdd_adapter *reference) { struct hdd_adapter *adapter, *next_adapter = NULL; + wlan_net_dev_ref_dbgid dbgid = NET_DEV_HOLD_ADAPTER_GET_BY_REFERENCE; - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { if (adapter == reference) { dev_hold(adapter->dev); - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); if (next_adapter) - dev_put(next_adapter->dev); + hdd_adapter_dev_put_debug(next_adapter, + dbgid); break; } - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } return adapter; @@ -8778,15 +8937,18 @@ struct hdd_adapter *hdd_get_adapter_by_iface_name(struct hdd_context *hdd_ctx, const char *iface_name) { struct hdd_adapter *adapter, *next_adapter = NULL; + wlan_net_dev_ref_dbgid dbgid = NET_DEV_HOLD_GET_ADAPTER_BY_IFACE_NAME; - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { if (!qdf_str_cmp(adapter->dev->name, iface_name)) { - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); if (next_adapter) - dev_put(next_adapter->dev); + hdd_adapter_dev_put_debug(next_adapter, + dbgid); return adapter; } - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } return NULL; @@ -8806,15 +8968,18 @@ struct hdd_adapter *hdd_get_adapter(struct hdd_context *hdd_ctx, enum QDF_OPMODE mode) { struct hdd_adapter *adapter, *next_adapter = NULL; + wlan_net_dev_ref_dbgid dbgid = NET_DEV_HOLD_GET_ADAPTER; - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { if (adapter->device_mode == mode) { - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); if (next_adapter) - dev_put(next_adapter->dev); + hdd_adapter_dev_put_debug(next_adapter, + dbgid); return adapter; } - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } return NULL; @@ -8845,17 +9010,20 @@ uint32_t hdd_get_operating_chan_freq(struct hdd_context *hdd_ctx, { struct hdd_adapter *adapter, *next_adapter = NULL; uint32_t oper_chan_freq = 0; + wlan_net_dev_ref_dbgid dbgid = NET_DEV_HOLD_GET_OPERATING_CHAN_FREQ; - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { if (mode == adapter->device_mode) { oper_chan_freq = hdd_get_adapter_home_channel(adapter); - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); if (next_adapter) - dev_put(next_adapter->dev); + hdd_adapter_dev_put_debug(next_adapter, + dbgid); break; } - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } return oper_chan_freq; @@ -8865,10 +9033,13 @@ static inline QDF_STATUS hdd_unregister_wext_all_adapters(struct hdd_context * hdd_ctx) { struct hdd_adapter *adapter, *next_adapter = NULL; + wlan_net_dev_ref_dbgid dbgid = + NET_DEV_HOLD_UNREGISTER_WEXT_ALL_ADAPTERS; hdd_enter(); - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { if (adapter->device_mode == QDF_STA_MODE || adapter->device_mode == QDF_P2P_CLIENT_MODE || adapter->device_mode == QDF_P2P_DEVICE_MODE || @@ -8876,7 +9047,7 @@ static inline QDF_STATUS hdd_unregister_wext_all_adapters(struct hdd_context * adapter->device_mode == QDF_P2P_GO_MODE) { hdd_unregister_wext(adapter->dev); } - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } hdd_exit(); @@ -8887,10 +9058,13 @@ static inline QDF_STATUS hdd_unregister_wext_all_adapters(struct hdd_context * QDF_STATUS hdd_abort_mac_scan_all_adapters(struct hdd_context *hdd_ctx) { struct hdd_adapter *adapter, *next_adapter = NULL; + wlan_net_dev_ref_dbgid dbgid = + NET_DEV_HOLD_ABORT_MAC_SCAN_ALL_ADAPTERS; hdd_enter(); - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { if (adapter->device_mode == QDF_STA_MODE || adapter->device_mode == QDF_P2P_CLIENT_MODE || adapter->device_mode == QDF_P2P_DEVICE_MODE || @@ -8900,7 +9074,7 @@ QDF_STATUS hdd_abort_mac_scan_all_adapters(struct hdd_context *hdd_ctx) adapter->vdev_id, INVALID_SCAN_ID, true); } - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } hdd_exit(); @@ -8919,8 +9093,11 @@ static QDF_STATUS hdd_abort_sched_scan_all_adapters(struct hdd_context *hdd_ctx) { struct hdd_adapter *adapter, *next_adapter = NULL; int err; + wlan_net_dev_ref_dbgid dbgid = + NET_DEV_HOLD_ABORT_SCHED_SCAN_ALL_ADAPTERS; - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { if (adapter->device_mode == QDF_STA_MODE || adapter->device_mode == QDF_P2P_CLIENT_MODE || adapter->device_mode == QDF_P2P_DEVICE_MODE || @@ -8930,7 +9107,7 @@ static QDF_STATUS hdd_abort_sched_scan_all_adapters(struct hdd_context *hdd_ctx) if (err) hdd_err("Unable to stop scheduled scan"); } - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } return QDF_STATUS_SUCCESS; @@ -9286,15 +9463,18 @@ QDF_STATUS hdd_post_cds_enable_config(struct hdd_context *hdd_ctx) struct hdd_adapter *hdd_get_first_valid_adapter(struct hdd_context *hdd_ctx) { struct hdd_adapter *adapter, *next_adapter = NULL; + wlan_net_dev_ref_dbgid dbgid = NET_DEV_HOLD_GET_FIRST_VALID_ADAPTER; - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { if (adapter && adapter->magic == WLAN_HDD_ADAPTER_MAGIC) { - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); if (next_adapter) - dev_put(next_adapter->dev); + hdd_adapter_dev_put_debug(next_adapter, + dbgid); return adapter; } - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } return NULL; @@ -9568,9 +9748,11 @@ static void hdd_clear_rps_cpu_mask(struct hdd_context *hdd_ctx) { struct hdd_adapter *adapter, *next_adapter = NULL; - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + NET_DEV_HOLD_CLEAR_RPS_CPU_MASK) { hdd_send_rps_disable_ind(adapter); - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, + NET_DEV_HOLD_CLEAR_RPS_CPU_MASK); } } @@ -10259,6 +10441,7 @@ static void __hdd_bus_bw_work_handler(struct hdd_context *hdd_ctx) bool connected = false; uint32_t ipa_tx_packets = 0, ipa_rx_packets = 0; uint64_t sta_tx_bytes = 0, sap_tx_bytes = 0; + wlan_net_dev_ref_dbgid dbgid = NET_DEV_HOLD_BUS_BW_WORK_HANDLER; if (wlan_hdd_validate_context(hdd_ctx)) goto stop_work; @@ -10266,13 +10449,14 @@ static void __hdd_bus_bw_work_handler(struct hdd_context *hdd_ctx) if (hdd_ctx->is_wiphy_suspended) return; - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { /* * Validate magic so we don't end up accessing * an invalid adapter. */ if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) { - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); continue; } @@ -10280,16 +10464,14 @@ static void __hdd_bus_bw_work_handler(struct hdd_context *hdd_ctx) adapter->device_mode == QDF_P2P_CLIENT_MODE) && WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.conn_state != eConnectionState_Associated) { - - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); continue; } if ((adapter->device_mode == QDF_SAP_MODE || adapter->device_mode == QDF_P2P_GO_MODE) && WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active == false) { - - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); continue; } @@ -10347,7 +10529,7 @@ static void __hdd_bus_bw_work_handler(struct hdd_context *hdd_ctx) adapter->prev_tx_bytes = adapter->stats.tx_bytes; qdf_spin_unlock_bh(&hdd_ctx->bus_bw_lock); connected = true; - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } if (!connected) { @@ -10754,6 +10936,8 @@ hdd_display_netif_queue_history_compact(struct hdd_context *hdd_ctx) char *comb_log_str; uint32_t comb_log_str_size; struct hdd_adapter *adapter = NULL, *next_adapter = NULL; + wlan_net_dev_ref_dbgid dbgid = + NET_DEV_HOLD_DISPLAY_NETIF_QUEUE_HISTORY_COMPACT; comb_log_str_size = (ADAP_NETIFQ_LOG_LEN * WLAN_MAX_VDEVS) + 1; comb_log_str = qdf_mem_malloc(comb_log_str_size); @@ -10762,7 +10946,8 @@ hdd_display_netif_queue_history_compact(struct hdd_context *hdd_ctx) bytes_written = 0; - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { curr_time = qdf_system_ticks(); total = curr_time - adapter->start_time; delta = curr_time - adapter->last_time; @@ -10807,7 +10992,7 @@ hdd_display_netif_queue_history_compact(struct hdd_context *hdd_ctx) adapter_num++; /* dev_put has to be done here */ - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } /* using QDF_TRACE to avoid printing function name */ @@ -10922,20 +11107,23 @@ wlan_hdd_display_netif_queue_history(struct hdd_context *hdd_ctx, enum qdf_stats_verbosity_level verb_lvl) { struct hdd_adapter *adapter = NULL, *next_adapter = NULL; + wlan_net_dev_ref_dbgid dbgid = + NET_DEV_HOLD_DISPLAY_NETIF_QUEUE_HISTORY; if (verb_lvl == QDF_STATS_VERBOSITY_LEVEL_LOW) { hdd_display_netif_queue_history_compact(hdd_ctx); return; } - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { if (adapter->vdev_id == CDP_INVALID_VDEV_ID) { - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); continue; } wlan_hdd_display_adapter_netif_queue_stats(adapter); /* dev_put has to be done here */ - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } } @@ -10948,8 +11136,10 @@ wlan_hdd_display_netif_queue_history(struct hdd_context *hdd_ctx, void wlan_hdd_clear_netif_queue_history(struct hdd_context *hdd_ctx) { struct hdd_adapter *adapter = NULL, *next_adapter = NULL; + wlan_net_dev_ref_dbgid dbgid = NET_DEV_HOLD_CLEAR_NETIF_QUEUE_HISTORY; - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { qdf_mem_zero(adapter->queue_oper_stats, sizeof(adapter->queue_oper_stats)); qdf_mem_zero(adapter->queue_oper_history, @@ -10958,7 +11148,7 @@ void wlan_hdd_clear_netif_queue_history(struct hdd_context *hdd_ctx) adapter->start_time = adapter->last_time = qdf_system_ticks(); adapter->total_pause_time = 0; adapter->total_unpause_time = 0; - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } } @@ -11229,14 +11419,16 @@ void hdd_unsafe_channel_restart_sap(struct hdd_context *hdd_ctxt) bool is_acs_support_for_dfs_ltecoex = cfg_default(CFG_USER_ACS_DFS_LTE); bool is_vendor_acs_support = cfg_default(CFG_USER_AUTO_CHANNEL_SELECTION); + wlan_net_dev_ref_dbgid dbgid = NET_DEV_HOLD_UNSAFE_CHANNEL_RESTART_SAP; - hdd_for_each_adapter_dev_held_safe(hdd_ctxt, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctxt, adapter, next_adapter, + dbgid) { if (!(adapter->device_mode == QDF_SAP_MODE && adapter->session.ap.sap_config.acs_cfg.acs_mode)) { hdd_debug_rl("skip device mode:%d acs:%d", adapter->device_mode, adapter->session.ap.sap_config.acs_cfg.acs_mode); - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); continue; } @@ -11280,7 +11472,7 @@ void hdd_unsafe_channel_restart_sap(struct hdd_context *hdd_ctxt) restart_chan_store); hdd_debug("ch:%d is safe. no need to change channel", ap_chan); - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); continue; } @@ -11299,7 +11491,7 @@ void hdd_unsafe_channel_restart_sap(struct hdd_context *hdd_ctxt) if (is_vendor_acs_support && is_acs_support_for_dfs_ltecoex) { hdd_update_acs_timer_reason(adapter, QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX); - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); continue; } @@ -11343,9 +11535,10 @@ void hdd_unsafe_channel_restart_sap(struct hdd_context *hdd_ctxt) CSA_REASON_UNSAFE_CHANNEL); hdd_switch_sap_channel(adapter, restart_chan, true); - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); if (next_adapter) - dev_put(next_adapter->dev); + hdd_adapter_dev_put_debug(next_adapter, + dbgid); return; } else { @@ -11353,14 +11546,15 @@ void hdd_unsafe_channel_restart_sap(struct hdd_context *hdd_ctxt) wlan_hdd_send_svc_nlink_msg( hdd_ctxt->radio_index, WLAN_SVC_LTE_COEX_IND, NULL, 0); - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); if (next_adapter) - dev_put(next_adapter->dev); + hdd_adapter_dev_put_debug(next_adapter, + dbgid); return; } } /* dev_put has to be done here */ - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } } @@ -11540,6 +11734,7 @@ void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind) (struct ieee80211_mgmt *)frame_ind->frameBuf; QDF_STATUS status; struct wlan_objmgr_vdev *vdev; + wlan_net_dev_ref_dbgid dbgid = NET_DEV_HOLD_INDICATE_MGMT_FRAME; hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); if (wlan_hdd_validate_context(hdd_ctx)) @@ -11560,11 +11755,11 @@ void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind) } else if (SME_SESSION_ID_BROADCAST == frame_ind->sessionId) { num_adapters = 0; hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, - next_adapter) { + next_adapter, dbgid) { vdev_id[num_adapters] = adapter->vdev_id; num_adapters++; /* dev_put has to be done here */ - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } adapter = NULL; @@ -14381,6 +14576,7 @@ static void hdd_state_info_dump(char **buf_ptr, uint16_t *size) struct hdd_adapter *adapter, *next_adapter = NULL; uint16_t len = 0; char *buf = *buf_ptr; + wlan_net_dev_ref_dbgid dbgid = NET_DEV_HOLD_STATE_INFO_DUMP; hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); if (!hdd_ctx) { @@ -14396,7 +14592,8 @@ static void hdd_state_info_dump(char **buf_ptr, uint16_t *size) "\n is_scheduler_suspended %d", hdd_ctx->is_scheduler_suspended); - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { len += scnprintf(buf + len, *size - len, "\n device name: %s", adapter->dev->name); len += scnprintf(buf + len, *size - len, @@ -14413,7 +14610,7 @@ static void hdd_state_info_dump(char **buf_ptr, uint16_t *size) default: break; } - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } *size -= len; @@ -15326,11 +15523,13 @@ wlan_hdd_disable_roaming(struct hdd_adapter *cur_adapter, struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(cur_adapter); struct hdd_adapter *adapter = NULL, *next_adapter = NULL; struct hdd_station_ctx *sta_ctx; + wlan_net_dev_ref_dbgid dbgid = NET_DEV_HOLD_DISABLE_ROAMING; if (!policy_mgr_is_sta_active_connection_exists(hdd_ctx->psoc)) return; - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); if (cur_adapter->vdev_id != adapter->vdev_id && @@ -15342,7 +15541,7 @@ wlan_hdd_disable_roaming(struct hdd_adapter *cur_adapter, REASON_DRIVER_DISABLED, rso_op_requestor); } - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } } @@ -15353,11 +15552,13 @@ wlan_hdd_enable_roaming(struct hdd_adapter *cur_adapter, struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(cur_adapter); struct hdd_adapter *adapter = NULL, *next_adapter = NULL; struct hdd_station_ctx *sta_ctx; + wlan_net_dev_ref_dbgid dbgid = NET_DEV_HOLD_ENABLE_ROAMING; if (!policy_mgr_is_sta_active_connection_exists(hdd_ctx->psoc)) return; - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); if (cur_adapter->vdev_id != adapter->vdev_id && @@ -15369,7 +15570,7 @@ wlan_hdd_enable_roaming(struct hdd_adapter *cur_adapter, REASON_DRIVER_ENABLED, rso_op_requestor); } - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } } @@ -15494,6 +15695,7 @@ void wlan_hdd_auto_shutdown_enable(struct hdd_context *hdd_ctx, bool enable) struct hdd_adapter *adapter, *next_adapter = NULL; bool ap_connected = false, sta_connected = false; mac_handle_t mac_handle; + wlan_net_dev_ref_dbgid dbgid = NET_DEV_HOLD_AUTO_SHUTDOWN_ENABLE; mac_handle = hdd_ctx->mac_handle; if (!mac_handle) @@ -15515,15 +15717,18 @@ void wlan_hdd_auto_shutdown_enable(struct hdd_context *hdd_ctx, bool enable) /* To enable shutdown timer check conncurrency */ if (policy_mgr_concurrent_open_sessions_running(hdd_ctx->psoc)) { hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, - next_adapter) { + next_adapter, dbgid) { if (adapter->device_mode == QDF_STA_MODE) { if (WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> conn_info.conn_state == eConnectionState_Associated) { sta_connected = true; - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, + dbgid); if (next_adapter) - dev_put(next_adapter->dev); + hdd_adapter_dev_put_debug( + next_adapter, + dbgid); break; } } @@ -15532,13 +15737,16 @@ void wlan_hdd_auto_shutdown_enable(struct hdd_context *hdd_ctx, bool enable) if (WLAN_HDD_GET_AP_CTX_PTR(adapter)-> ap_active == true) { ap_connected = true; - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, + dbgid); if (next_adapter) - dev_put(next_adapter->dev); + hdd_adapter_dev_put_debug( + next_adapter, + dbgid); break; } } - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } } @@ -15563,10 +15771,12 @@ hdd_get_con_sap_adapter(struct hdd_adapter *this_sap_adapter, { struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(this_sap_adapter); struct hdd_adapter *adapter, *con_sap_adapter, *next_adapter = NULL; + wlan_net_dev_ref_dbgid dbgid = NET_DEV_HOLD_GET_CON_SAP_ADAPTER; con_sap_adapter = NULL; - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { if (adapter && ((adapter->device_mode == QDF_SAP_MODE) || (adapter->device_mode == QDF_P2P_GO_MODE)) && adapter != this_sap_adapter) { @@ -15574,20 +15784,24 @@ hdd_get_con_sap_adapter(struct hdd_adapter *this_sap_adapter, if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) { con_sap_adapter = adapter; - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, + dbgid); if (next_adapter) - dev_put(next_adapter->dev); + hdd_adapter_dev_put_debug( + next_adapter, + dbgid); break; } } else { con_sap_adapter = adapter; - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); if (next_adapter) - dev_put(next_adapter->dev); + hdd_adapter_dev_put_debug(next_adapter, + dbgid); break; } } - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } return con_sap_adapter; @@ -15608,34 +15822,39 @@ static inline bool hdd_adapter_is_ap(struct hdd_adapter *adapter) bool hdd_is_any_adapter_connected(struct hdd_context *hdd_ctx) { struct hdd_adapter *adapter, *next_adapter = NULL; + wlan_net_dev_ref_dbgid dbgid = NET_DEV_HOLD_IS_ANY_ADAPTER_CONNECTED; - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { if (hdd_adapter_is_sta(adapter) && WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> conn_info.conn_state == eConnectionState_Associated) { - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); if (next_adapter) - dev_put(next_adapter->dev); + hdd_adapter_dev_put_debug(next_adapter, + dbgid); return true; } if (hdd_adapter_is_ap(adapter) && WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active) { - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); if (next_adapter) - dev_put(next_adapter->dev); + hdd_adapter_dev_put_debug(next_adapter, + dbgid); return true; } if (adapter->device_mode == QDF_NDI_MODE && WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> conn_info.conn_state == eConnectionState_NdiConnected) { - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); if (next_adapter) - dev_put(next_adapter->dev); + hdd_adapter_dev_put_debug(next_adapter, + dbgid); return true; } - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } return false; @@ -17812,6 +18031,7 @@ bool hdd_is_roaming_in_progress(struct hdd_context *hdd_ctx) { struct hdd_adapter *adapter = NULL, *next_adapter = NULL; uint8_t vdev_id; + wlan_net_dev_ref_dbgid dbgid = NET_DEV_HOLD_IS_ROAMING_IN_PROGRESS; if (!hdd_ctx) { hdd_err("HDD context is NULL"); @@ -17821,7 +18041,8 @@ bool hdd_is_roaming_in_progress(struct hdd_context *hdd_ctx) if (!policy_mgr_is_sta_active_connection_exists(hdd_ctx->psoc)) return false; - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { vdev_id = adapter->vdev_id; if (adapter->device_mode == QDF_STA_MODE && (MLME_IS_ROAM_SYNCH_IN_PROGRESS(hdd_ctx->psoc, vdev_id) || @@ -17830,12 +18051,13 @@ bool hdd_is_roaming_in_progress(struct hdd_context *hdd_ctx) vdev_id))) { hdd_debug("Roaming is in progress on:vdev_id:%d", adapter->vdev_id); - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); if (next_adapter) - dev_put(next_adapter->dev); + hdd_adapter_dev_put_debug(next_adapter, + dbgid); return true; } - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } return false; @@ -18374,7 +18596,8 @@ wlan_hdd_del_p2p_interface(struct hdd_context *hdd_ctx) struct hdd_adapter *adapter = NULL, *next_adapter = NULL; struct osif_vdev_sync *vdev_sync; - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + NET_DEV_HOLD_DEL_P2P_INTERFACE) { if (adapter->device_mode == QDF_P2P_CLIENT_MODE || adapter->device_mode == QDF_P2P_DEVICE_MODE || adapter->device_mode == QDF_P2P_GO_MODE) { @@ -18387,7 +18610,8 @@ wlan_hdd_del_p2p_interface(struct hdd_context *hdd_ctx) if (vdev_sync) osif_vdev_sync_destroy(vdev_sync); } - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, + NET_DEV_HOLD_DEL_P2P_INTERFACE); } } diff --git a/core/hdd/src/wlan_hdd_nan_datapath.c b/core/hdd/src/wlan_hdd_nan_datapath.c index 98a8e4cfc9bd..a6c6f65a6b80 100644 --- a/core/hdd/src/wlan_hdd_nan_datapath.c +++ b/core/hdd/src/wlan_hdd_nan_datapath.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2016-2021 The Linux Foundation. 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 @@ -124,15 +124,18 @@ static bool hdd_is_ndp_allowed(struct hdd_context *hdd_ctx) { struct hdd_adapter *adapter, *next_adapter = NULL; struct hdd_station_ctx *sta_ctx; + wlan_net_dev_ref_dbgid dbgid = NET_DEV_HOLD_IS_NDP_ALLOWED; - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { switch (adapter->device_mode) { case QDF_P2P_GO_MODE: if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) { - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); if (next_adapter) - dev_put(next_adapter->dev); + hdd_adapter_dev_put_debug(next_adapter, + dbgid); return false; } break; @@ -140,16 +143,17 @@ static bool hdd_is_ndp_allowed(struct hdd_context *hdd_ctx) sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); if (hdd_conn_is_connected(sta_ctx) || hdd_is_connecting(sta_ctx)) { - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); if (next_adapter) - dev_put(next_adapter->dev); + hdd_adapter_dev_put_debug(next_adapter, + dbgid); return false; } break; default: break; } - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } return true; @@ -159,16 +163,19 @@ static bool hdd_is_ndp_allowed(struct hdd_context *hdd_ctx) { struct hdd_adapter *adapter, *next_adapter = NULL; struct hdd_station_ctx *sta_ctx; + wlan_net_dev_ref_dbgid dbgid = NET_DEV_HOLD_IS_NDP_ALLOWED; - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { switch (adapter->device_mode) { case QDF_P2P_GO_MODE: case QDF_SAP_MODE: if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) { - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); if (next_adapter) - dev_put(next_adapter->dev); + hdd_adapter_dev_put_debug(next_adapter, + dbgid); return false; } break; @@ -176,16 +183,17 @@ static bool hdd_is_ndp_allowed(struct hdd_context *hdd_ctx) sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); if (hdd_conn_is_connected(sta_ctx) || hdd_is_connecting(sta_ctx)) { - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); if (next_adapter) - dev_put(next_adapter->dev); + hdd_adapter_dev_put_debug(next_adapter, + dbgid); return false; } break; default: break; } - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } return true; @@ -576,10 +584,11 @@ int hdd_ndi_open(char *iface_name) return -EINVAL; } - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + NET_DEV_HOLD_NDI_OPEN) { if (WLAN_HDD_IS_NDI(adapter)) ndi_adapter_count++; - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, NET_DEV_HOLD_NDI_OPEN); } if (ndi_adapter_count >= MAX_NDI_ADAPTERS) { hdd_err("Can't allow more than %d NDI adapters", diff --git a/core/hdd/src/wlan_hdd_oemdata.c b/core/hdd/src/wlan_hdd_oemdata.c index 6d17436b6734..0194b48f9911 100644 --- a/core/hdd/src/wlan_hdd_oemdata.c +++ b/core/hdd/src/wlan_hdd_oemdata.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2021 The Linux Foundation. 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 @@ -191,6 +191,7 @@ static void send_oem_reg_rsp_nlink_msg(void) uint8_t *device_mode; uint8_t *vdev_id; struct hdd_adapter *adapter, *next_adapter = NULL; + wlan_net_dev_ref_dbgid dbgid = NET_DEV_HOLD_SEND_OEM_REG_RSP_NLINK_MSG; /* OEM msg is always to a specific process & cannot be a broadcast */ if (p_hdd_ctx->oem_pid == 0) { @@ -221,7 +222,8 @@ static void send_oem_reg_rsp_nlink_msg(void) *num_interfaces = 0; /* Iterate through each adapter and fill device mode and vdev id */ - hdd_for_each_adapter_dev_held_safe(p_hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(p_hdd_ctx, adapter, next_adapter, + dbgid) { device_mode = buf++; vdev_id = buf++; *device_mode = adapter->device_mode; @@ -230,7 +232,7 @@ static void send_oem_reg_rsp_nlink_msg(void) hdd_debug("num_interfaces: %d, device_mode: %d, vdev_id: %d", *num_interfaces, *device_mode, *vdev_id); - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } ani_hdr->length = diff --git a/core/hdd/src/wlan_hdd_periodic_sta_stats.c b/core/hdd/src/wlan_hdd_periodic_sta_stats.c index c9dd8eb3415b..887813ba1ce9 100644 --- a/core/hdd/src/wlan_hdd_periodic_sta_stats.c +++ b/core/hdd/src/wlan_hdd_periodic_sta_stats.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2020-2021, The Linux Foundation. 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 above @@ -46,15 +46,17 @@ void hdd_periodic_sta_stats_display(struct hdd_context *hdd_ctx) struct hdd_config *hdd_cfg; char *dev_name; bool should_log; + wlan_net_dev_ref_dbgid dbgid = NET_DEV_HOLD_PERIODIC_STA_STATS_DISPLAY; if (!hdd_ctx) return; - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { should_log = false; if (adapter->device_mode != QDF_STA_MODE) { - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); continue; } @@ -63,7 +65,7 @@ void hdd_periodic_sta_stats_display(struct hdd_context *hdd_ctx) if (!adapter->is_sta_periodic_stats_enabled) { qdf_mutex_release(&adapter->sta_periodic_stats_lock); - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); continue; } @@ -92,7 +94,7 @@ void hdd_periodic_sta_stats_display(struct hdd_context *hdd_ctx) hdd_nofl_info("%s: Rx DNS responses: %d", dev_name, sta_stats.hdd_dns_stats.rx_dns_rsp_count); } - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } } diff --git a/core/hdd/src/wlan_hdd_power.c b/core/hdd/src/wlan_hdd_power.c index 0031c8a95b10..a43b17c6fb25 100644 --- a/core/hdd/src/wlan_hdd_power.c +++ b/core/hdd/src/wlan_hdd_power.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2021 The Linux Foundation. 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 @@ -1320,9 +1320,11 @@ hdd_suspend_wlan(void) return -EINVAL; } - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + NET_DEV_HOLD_SUSPEND_WLAN) { if (wlan_hdd_validate_vdev_id(adapter->vdev_id)) { - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, + NET_DEV_HOLD_SUSPEND_WLAN); continue; } @@ -1339,7 +1341,7 @@ hdd_suspend_wlan(void) /* Configure supported OffLoads */ hdd_enable_host_offloads(adapter, pmo_apps_suspend); hdd_update_conn_state_mask(adapter, &conn_state_mask); - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, NET_DEV_HOLD_SUSPEND_WLAN); } status = ucfg_pmo_psoc_user_space_suspend_req(hdd_ctx->psoc, @@ -1385,9 +1387,11 @@ static int hdd_resume_wlan(void) hdd_wlan_suspend_resume_event(HDD_WLAN_EARLY_RESUME); /*loop through all adapters. Concurrency */ - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + NET_DEV_HOLD_RESUME_WLAN) { if (wlan_hdd_validate_vdev_id(adapter->vdev_id)) { - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, + NET_DEV_HOLD_RESUME_WLAN); continue; } @@ -1404,7 +1408,7 @@ static int hdd_resume_wlan(void) if (adapter->device_mode == QDF_STA_MODE) status = hdd_disable_default_pkt_filters(adapter); - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, NET_DEV_HOLD_RESUME_WLAN); } ucfg_ipa_resume(hdd_ctx->pdev); @@ -1441,14 +1445,16 @@ static void hdd_ssr_restart_sap(struct hdd_context *hdd_ctx) hdd_enter(); - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + NET_DEV_HOLD_SSR_RESTART_SAP) { if (adapter->device_mode == QDF_SAP_MODE) { if (test_bit(SOFTAP_INIT_DONE, &adapter->event_flags)) { hdd_debug("Restart prev SAP session"); wlan_hdd_start_sap(adapter, true); } } - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, + NET_DEV_HOLD_SSR_RESTART_SAP); } hdd_exit(); @@ -1570,7 +1576,8 @@ static void hdd_send_default_scan_ies(struct hdd_context *hdd_ctx) { struct hdd_adapter *adapter, *next_adapter = NULL; - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + NET_DEV_HOLD_SEND_DEFAULT_SCAN_IES) { if (hdd_is_interface_up(adapter) && (adapter->device_mode == QDF_STA_MODE || adapter->device_mode == QDF_P2P_DEVICE_MODE) && @@ -1580,7 +1587,8 @@ static void hdd_send_default_scan_ies(struct hdd_context *hdd_ctx) adapter->scan_info.default_scan_ies, adapter->scan_info.default_scan_ies_len); } - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, + NET_DEV_HOLD_SEND_DEFAULT_SCAN_IES); } } @@ -2009,6 +2017,7 @@ static int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy, mac_handle_t mac_handle; struct wlan_objmgr_vdev *vdev; int rc; + wlan_net_dev_ref_dbgid dbgid = NET_DEV_HOLD_CFG80211_SUSPEND_WLAN; hdd_enter(); @@ -2042,9 +2051,10 @@ static int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy, * "dfs_cac_block_tx" is set to true when RADAR is found and stay true * until CAC is done for a SoftAP which is in started state. */ - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { if (wlan_hdd_validate_vdev_id(adapter->vdev_id)) { - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); continue; } @@ -2057,9 +2067,10 @@ static int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy, hdd_err("RADAR detection in progress, do not allow suspend"); wlan_hdd_inc_suspend_stats(hdd_ctx, SUSPEND_FAIL_RADAR); - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); if (next_adapter) - dev_put(next_adapter->dev); + hdd_adapter_dev_put_debug(next_adapter, + dbgid); return -EAGAIN; } else if (!ucfg_pmo_get_enable_sap_suspend( hdd_ctx->psoc)) { @@ -2067,9 +2078,10 @@ static int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy, * suspend */ hdd_err("SAP does not support suspend!!"); - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); if (next_adapter) - dev_put(next_adapter->dev); + hdd_adapter_dev_put_debug(next_adapter, + dbgid); return -EOPNOTSUPP; } } else if (QDF_P2P_GO_MODE == adapter->device_mode) { @@ -2079,13 +2091,14 @@ static int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy, * suspend */ hdd_err("GO does not support suspend!!"); - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); if (next_adapter) - dev_put(next_adapter->dev); + hdd_adapter_dev_put_debug(next_adapter, + dbgid); return -EOPNOTSUPP; } } - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } /* p2p cleanup task based on scheduler */ ucfg_p2p_cleanup_tx_by_psoc(hdd_ctx->psoc); @@ -2097,14 +2110,15 @@ static int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy, } /* flush any pending powersave timers */ - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { if (wlan_hdd_validate_vdev_id(adapter->vdev_id)) { - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); continue; } sme_ps_timer_flush_sync(mac_handle, adapter->vdev_id); - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } /* diff --git a/core/hdd/src/wlan_hdd_regulatory.c b/core/hdd/src/wlan_hdd_regulatory.c index 391cd376e4ab..2f573f65b250 100644 --- a/core/hdd/src/wlan_hdd_regulatory.c +++ b/core/hdd/src/wlan_hdd_regulatory.c @@ -1397,10 +1397,12 @@ static void hdd_country_change_update_sta(struct hdd_context *hdd_ctx) bool freq_changed, phy_changed; qdf_freq_t oper_freq; eCsrPhyMode csr_phy_mode; + wlan_net_dev_ref_dbgid dbgid = NET_DEV_HOLD_COUNTRY_CHANGE_UPDATE_STA; pdev = hdd_ctx->pdev; - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { oper_freq = hdd_get_adapter_home_channel(adapter); freq_changed = wlan_reg_is_disable_for_freq(pdev, oper_freq); @@ -1433,7 +1435,7 @@ static void hdd_country_change_update_sta(struct hdd_context *hdd_ctx) break; } /* dev_put has to be done here */ - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } } @@ -1525,10 +1527,12 @@ static void hdd_country_change_update_sap(struct hdd_context *hdd_ctx) bool phy_changed; qdf_freq_t oper_freq; eCsrPhyMode csr_phy_mode; + wlan_net_dev_ref_dbgid dbgid = NET_DEV_HOLD_COUNTRY_CHANGE_UPDATE_SAP; pdev = hdd_ctx->pdev; - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { oper_freq = hdd_get_adapter_home_channel(adapter); switch (adapter->device_mode) { @@ -1561,7 +1565,7 @@ static void hdd_country_change_update_sap(struct hdd_context *hdd_ctx) break; } /* dev_put has to be done here */ - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); } } diff --git a/core/hdd/src/wlan_hdd_stats.c b/core/hdd/src/wlan_hdd_stats.c index 484889ff8d9e..5e2c809fe940 100644 --- a/core/hdd/src/wlan_hdd_stats.c +++ b/core/hdd/src/wlan_hdd_stats.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2021 The Linux Foundation. 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 @@ -1747,17 +1747,20 @@ static void cache_station_stats_cb(struct stats_event *ev, void *cookie) struct hdd_adapter *adapter = cookie, *next_adapter = NULL; struct hdd_context *hdd_ctx = adapter->hdd_ctx; uint8_t vdev_id = adapter->vdev_id; + wlan_net_dev_ref_dbgid dbgid = NET_DEV_HOLD_DISPLAY_TXRX_STATS; - hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter, + dbgid) { if (adapter->vdev_id != vdev_id) { - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); continue; } copy_station_stats_to_adapter(adapter, ev); /* dev_put has to be done here */ - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); if (next_adapter) - dev_put(next_adapter->dev); + hdd_adapter_dev_put_debug(next_adapter, + dbgid); break; } } @@ -6570,8 +6573,10 @@ void wlan_hdd_display_txrx_stats(struct hdd_context *ctx) int i = 0; uint32_t total_rx_pkt, total_rx_dropped, total_rx_delv, total_rx_refused; + wlan_net_dev_ref_dbgid dbgid = NET_DEV_HOLD_CACHE_STATION_STATS_CB; - hdd_for_each_adapter_dev_held_safe(ctx, adapter, next_adapter) { + hdd_for_each_adapter_dev_held_safe(ctx, adapter, next_adapter, + dbgid) { total_rx_pkt = 0; total_rx_dropped = 0; total_rx_delv = 0; @@ -6579,7 +6584,7 @@ void wlan_hdd_display_txrx_stats(struct hdd_context *ctx) stats = &adapter->hdd_stats.tx_rx_stats; if (adapter->vdev_id == INVAL_VDEV_ID) { - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); continue; } @@ -6592,7 +6597,7 @@ void wlan_hdd_display_txrx_stats(struct hdd_context *ctx) } /* dev_put has to be done here */ - dev_put(adapter->dev); + hdd_adapter_dev_put_debug(adapter, dbgid); hdd_debug("TX - called %u, dropped %u orphan %u", stats->tx_called, stats->tx_dropped,