From 7b3dea22f9c298083fbc3044dc80277f80da78ac Mon Sep 17 00:00:00 2001 From: Dustin Brown Date: Mon, 10 Jul 2017 13:02:47 -0700 Subject: [PATCH] qcacld-3.0: Statically allocate wlan logging buffer To aid in debugging memory leaks, and improve the robustness of log recovery from crash dumps, statically allocate pglog_msg in the global scope. This allows logs to be inspected even in cases where a crash came late in the unload process. It also improves log recovery robustness by removing the possibility of using a NULL pointer offset under certain memory corruptions scenarios. Change-Id: I7301254d3d3ff811b322e435962e78f997937c2b CRs-Fixed: 2074611 --- core/hdd/inc/wlan_hdd_cfg.h | 11 ++----- core/hdd/src/wlan_hdd_cfg.c | 7 ----- core/hdd/src/wlan_hdd_main.c | 61 ++---------------------------------- 3 files changed, 4 insertions(+), 75 deletions(-) diff --git a/core/hdd/inc/wlan_hdd_cfg.h b/core/hdd/inc/wlan_hdd_cfg.h index 868b03cede45..ef40f9368608 100644 --- a/core/hdd/inc/wlan_hdd_cfg.h +++ b/core/hdd/inc/wlan_hdd_cfg.h @@ -7899,12 +7899,6 @@ enum hdd_link_speed_rpt_type { #define CFG_WLAN_LOGGING_CONSOLE_SUPPORT_ENABLE (1) #define CFG_WLAN_LOGGING_CONSOLE_SUPPORT_DISABLE (0) #define CFG_WLAN_LOGGING_CONSOLE_SUPPORT_DEFAULT (1) - -/* Number of buffers to be used for WLAN logging */ -#define CFG_WLAN_LOGGING_NUM_BUF_NAME "wlanLoggingNumBuf" -#define CFG_WLAN_LOGGING_NUM_BUF_MIN (4) -#define CFG_WLAN_LOGGING_NUM_BUF_MAX (512) -#define CFG_WLAN_LOGGING_NUM_BUF_DEFAULT (256) #endif /* WLAN_LOGGING_SOCK_SVC_ENABLE */ /* @@ -12111,9 +12105,8 @@ struct hdd_config { uint32_t IpaUcTxPartitionBase; #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE /* WLAN Logging */ - uint32_t wlanLoggingEnable; - uint32_t wlanLoggingToConsole; - uint32_t wlanLoggingNumBuf; + bool wlanLoggingEnable; + bool wlanLoggingToConsole; #endif /* WLAN_LOGGING_SOCK_SVC_ENABLE */ uint8_t enableSifsBurst; diff --git a/core/hdd/src/wlan_hdd_cfg.c b/core/hdd/src/wlan_hdd_cfg.c index 980243ea2fc9..6b8d6841655f 100644 --- a/core/hdd/src/wlan_hdd_cfg.c +++ b/core/hdd/src/wlan_hdd_cfg.c @@ -3300,13 +3300,6 @@ struct reg_table_entry g_registry_table[] = { CFG_WLAN_LOGGING_CONSOLE_SUPPORT_DEFAULT, CFG_WLAN_LOGGING_CONSOLE_SUPPORT_DISABLE, CFG_WLAN_LOGGING_CONSOLE_SUPPORT_ENABLE), - - REG_VARIABLE(CFG_WLAN_LOGGING_NUM_BUF_NAME, WLAN_PARAM_Integer, - struct hdd_config, wlanLoggingNumBuf, - VAR_FLAGS_OPTIONAL | VAR_FLAGS_RANGE_CHECK_ASSUME_DEFAULT, - CFG_WLAN_LOGGING_NUM_BUF_DEFAULT, - CFG_WLAN_LOGGING_NUM_BUF_MIN, - CFG_WLAN_LOGGING_NUM_BUF_MAX), #endif /* WLAN_LOGGING_SOCK_SVC_ENABLE */ REG_VARIABLE(CFG_ENABLE_SIFS_BURST, WLAN_PARAM_Integer, diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index ae63a920a9ea..ca1d46ccbfb7 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -5554,57 +5554,6 @@ static int hdd_wlan_register_ip6_notifier(hdd_context_t *hdd_ctx) } #endif -#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE -/** - * hdd_logging_sock_activate_svc() - Activate logging - * @hdd_ctx: HDD context - * - * Activates the logging service - * - * Return: Zero in case of success, negative value otherwise - */ -static int hdd_logging_sock_activate_svc(hdd_context_t *hdd_ctx) -{ - int ret; - struct hdd_config *config = hdd_ctx->config; - - if (!config->wlanLoggingEnable) - return 0; - - ret = wlan_logging_sock_activate_svc(config->wlanLoggingToConsole, - config->wlanLoggingNumBuf); - if (ret) - hdd_err("wlan_logging_sock_activate_svc failed: %d", ret); - return ret; -} - -/** - * wlan_hdd_logging_sock_deactivate_svc() - Deactivate logging - * @hdd_ctx: HDD context - * - * Deactivates the logging service - * - * Return: 0 on deactivating the logging service - */ -static int hdd_logging_sock_deactivate_svc(hdd_context_t *hdd_ctx) -{ - if (hdd_ctx && hdd_ctx->config->wlanLoggingEnable) - return wlan_logging_sock_deactivate_svc(); - - return 0; -} -#else -static inline int hdd_logging_sock_activate_svc(hdd_context_t *hdd_ctx) -{ - return 0; -} - -static inline int hdd_logging_sock_deactivate_svc(hdd_context_t *hdd_ctx) -{ - return 0; -} -#endif - /** * hdd_register_notifiers - Register netdev notifiers. * @hdd_ctx: HDD context @@ -5867,8 +5816,6 @@ static int hdd_context_deinit(hdd_context_t *hdd_ctx) static void hdd_context_destroy(hdd_context_t *hdd_ctx) { - hdd_logging_sock_deactivate_svc(hdd_ctx); - wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); hdd_context_deinit(hdd_ctx); @@ -7887,9 +7834,8 @@ static hdd_context_t *hdd_context_create(struct device *dev) if (ret) goto err_deinit_hdd_context; - ret = hdd_logging_sock_activate_svc(hdd_ctx); - if (ret) - goto err_free_histogram; + wlan_logging_set_log_to_console(hdd_ctx->config->wlanLoggingToConsole); + wlan_logging_set_active(hdd_ctx->config->wlanLoggingEnable); skip_multicast_logging: hdd_set_trace_level_for_each(hdd_ctx); @@ -7898,9 +7844,6 @@ skip_multicast_logging: return hdd_ctx; -err_free_histogram: - wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); - err_deinit_hdd_context: hdd_context_deinit(hdd_ctx);