Forráskód Böngészése

qcacmn: Fix the limitations in enabling memory debug on WIN

Copy the file name to a QDF local array, rather than using
the pointer to file name, to avoid access to the invalid pointer.
Also, separate out SKB debug from memory debug.
SKB debug will be enabled once the SKB related false positives are fixed.

CRs-Fixed: 2216661
Change-Id: I0ada1acb84c24c961cf614c9c47261f272959874
Shiva Krishna Pittala 7 éve
szülő
commit
b155431361

+ 4 - 0
qdf/Kbuild

@@ -53,6 +53,10 @@ src/qdf_types.o
 #linux/src/qdf_net_ioctl.o
 #linux/src/qdf_net_wext.o
 
+ifeq ($(MEMORY_DEBUG),1)
+qdf-objs += src/qdf_debug_domain.o
+endif
+
 ifeq ($(LOGGING_UTILS_SUPPORT),1)
 qdf-objs += \
 $(HOST_CMN_CONVG_NLINK)/src/wlan_nlink_srv.o \

+ 4 - 4
qdf/inc/qdf_nbuf.h

@@ -574,7 +574,7 @@ qdf_nbuf_set_send_complete_flag(qdf_nbuf_t buf, bool flag)
 	__qdf_nbuf_set_send_complete_flag(buf, flag);
 }
 
-#ifdef MEMORY_DEBUG
+#ifdef NBUF_MEMORY_DEBUG
 /**
  * qdf_nbuf_map_check_for_leaks() - check for nbut map leaks
  *
@@ -662,7 +662,7 @@ void qdf_nbuf_unmap_nbytes_single_debug(qdf_device_t osdev,
 	qdf_nbuf_unmap_nbytes_single_debug(osdev, buf, dir, nbytes, \
 					   __FILE__, __LINE__)
 
-#else /* MEMORY_DEBUG */
+#else /* NBUF_MEMORY_DEBUG */
 
 static inline QDF_STATUS
 qdf_nbuf_map(qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir)
@@ -715,7 +715,7 @@ qdf_nbuf_unmap_nbytes_single(
 {
 	return __qdf_nbuf_unmap_nbytes_single(osdev, buf, dir, nbytes);
 }
-#endif /* MEMORY_DEBUG */
+#endif /* NBUF_MEMORY_DEBUG */
 
 static inline void
 qdf_nbuf_sync_for_cpu(qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir)
@@ -1069,7 +1069,7 @@ static inline qdf_nbuf_t qdf_nbuf_next(qdf_nbuf_t buf)
 	return __qdf_nbuf_next(buf);
 }
 
-#ifdef MEMORY_DEBUG
+#ifdef NBUF_MEMORY_DEBUG
 void qdf_net_buf_debug_init(void);
 void qdf_net_buf_debug_exit(void);
 void qdf_net_buf_debug_clean(void);

+ 1 - 0
qdf/linux/src/i_qdf_trace.h

@@ -98,6 +98,7 @@
 
 #define QDF_TRACE qdf_trace_msg
 
+#define QDF_VTRACE qdf_vtrace_msg
 #define QDF_TRACE_HEX_DUMP qdf_trace_hex_dump
 #endif /* CONFIG_MCL */
 

+ 14 - 8
qdf/linux/src/qdf_mem.c

@@ -38,6 +38,7 @@
 #include "qdf_module.h"
 #include <qdf_trace.h>
 #include "qdf_atomic.h"
+#include "qdf_str.h"
 #include <linux/debugfs.h>
 #include <linux/seq_file.h>
 #include <linux/string.h>
@@ -64,6 +65,7 @@
 #define QDF_MEM_MAX_MALLOC (4096 * 1024) /* 4 Mega Bytes */
 #define QDF_MEM_WARN_THRESHOLD 300 /* ms */
 #define QDF_DEBUG_STRING_SIZE 512
+#define QDF_MEM_FILE_NAME_SIZE 48
 
 static qdf_list_t qdf_mem_domains[QDF_DEBUG_DOMAIN_COUNT];
 static qdf_spinlock_t qdf_mem_list_lock;
@@ -97,7 +99,7 @@ struct qdf_mem_header {
 	qdf_list_node_t node;
 	enum qdf_debug_domain domain;
 	uint8_t freed;
-	const char *file;
+	char file[QDF_MEM_FILE_NAME_SIZE];
 	uint32_t line;
 	uint32_t size;
 	void *caller;
@@ -153,7 +155,10 @@ static void qdf_mem_header_init(struct qdf_mem_header *header, qdf_size_t size,
 
 	header->domain = qdf_debug_domain_get();
 	header->freed = false;
-	header->file = file;
+
+	/* copy the file name, rather than pointing to it */
+	qdf_str_lcopy(header->file, kbasename(file), QDF_MEM_FILE_NAME_SIZE);
+
 	header->line = line;
 	header->size = size;
 	header->caller = caller;
@@ -276,7 +281,7 @@ qdf_mem_header_assert_valid(struct qdf_mem_header *header,
 			qdf_debug_domain_name(current_domain), current_domain);
 
 	panic("A fatal memory error was detected @ %s:%d",
-	      kbasename(file), line);
+	      file, line);
 }
 #endif /* MEMORY_DEBUG */
 
@@ -366,7 +371,7 @@ static int seq_printf_printer(void *priv, const char *fmt, ...)
  *
  */
 struct __qdf_mem_info {
-	const char *file;
+	char file[QDF_MEM_FILE_NAME_SIZE];
 	uint32_t line;
 	uint32_t size;
 	void *caller;
@@ -425,12 +430,12 @@ static void qdf_mem_meta_table_print(struct __qdf_mem_info *table,
 		      table[i].count,
 		      table[i].size,
 		      table[i].count * table[i].size,
-		      kbasename(table[i].file),
+		      table[i].file,
 		      table[i].line, table[i].caller);
 		len += qdf_scnprintf(debug_str + len,
 				     sizeof(debug_str) - len,
 				     " @ %s:%u %pS",
-				     kbasename(table[i].file),
+				     table[i].file,
 				     table[i].line,
 				     table[i].caller);
 	}
@@ -451,7 +456,8 @@ static bool qdf_mem_meta_table_insert(struct __qdf_mem_info *table,
 
 	for (i = 0; i < QDF_MEM_STAT_TABLE_SIZE; i++) {
 		if (!table[i].count) {
-			table[i].file = meta->file;
+			qdf_str_lcopy(table[i].file, meta->file,
+				      QDF_MEM_FILE_NAME_SIZE);
 			table[i].line = meta->line;
 			table[i].size = meta->size;
 			table[i].count = 1;
@@ -459,7 +465,7 @@ static bool qdf_mem_meta_table_insert(struct __qdf_mem_info *table,
 			break;
 		}
 
-		if (table[i].file == meta->file &&
+		if (qdf_str_eq(table[i].file, meta->file) &&
 		    table[i].line == meta->line &&
 		    table[i].size == meta->size &&
 		    table[i].caller == meta->caller) {

+ 3 - 0
qdf/linux/src/qdf_module.c

@@ -34,6 +34,7 @@
 #include <qdf_perf.h>
 #include <qdf_trace.h>
 #include <qdf_nbuf.h>
+#include <qdf_mem.h>
 
 MODULE_AUTHOR("Qualcomm Atheros Inc.");
 MODULE_DESCRIPTION("Qualcomm Atheros Device Framework Module");
@@ -52,6 +53,7 @@ static int __init
 qdf_mod_init(void)
 {
 	qdf_shared_print_ctrl_init();
+	qdf_mem_init();
 	qdf_logging_init();
 	qdf_perfmod_init();
 	qdf_nbuf_mod_init();
@@ -70,6 +72,7 @@ qdf_mod_exit(void)
 	qdf_nbuf_mod_exit();
 	qdf_perfmod_exit();
 	qdf_logging_exit();
+	qdf_mem_exit();
 	qdf_shared_print_ctrl_cleanup();
 }
 module_exit(qdf_mod_exit);

+ 33 - 4
qdf/linux/src/qdf_nbuf.c

@@ -541,7 +541,7 @@ void __qdf_nbuf_free(struct sk_buff *skb)
 
 qdf_export_symbol(__qdf_nbuf_free);
 
-#ifdef MEMORY_DEBUG
+#ifdef NBUF_MEMORY_DEBUG
 enum qdf_nbuf_event_type {
 	QDF_NBUF_ALLOC,
 	QDF_NBUF_FREE,
@@ -737,6 +737,8 @@ QDF_STATUS qdf_nbuf_map_debug(qdf_device_t osdev,
 	return status;
 }
 
+qdf_export_symbol(qdf_nbuf_map_debug);
+
 void qdf_nbuf_unmap_debug(qdf_device_t osdev,
 			  qdf_nbuf_t buf,
 			  qdf_dma_dir_t dir,
@@ -747,6 +749,8 @@ void qdf_nbuf_unmap_debug(qdf_device_t osdev,
 	__qdf_nbuf_unmap_single(osdev, buf, dir);
 }
 
+qdf_export_symbol(qdf_nbuf_unmap_debug);
+
 QDF_STATUS qdf_nbuf_map_single_debug(qdf_device_t osdev,
 				     qdf_nbuf_t buf,
 				     qdf_dma_dir_t dir,
@@ -766,6 +770,8 @@ QDF_STATUS qdf_nbuf_map_single_debug(qdf_device_t osdev,
 	return status;
 }
 
+qdf_export_symbol(qdf_nbuf_map_single_debug);
+
 void qdf_nbuf_unmap_single_debug(qdf_device_t osdev,
 				 qdf_nbuf_t buf,
 				 qdf_dma_dir_t dir,
@@ -776,6 +782,8 @@ void qdf_nbuf_unmap_single_debug(qdf_device_t osdev,
 	__qdf_nbuf_unmap_single(osdev, buf, dir);
 }
 
+qdf_export_symbol(qdf_nbuf_unmap_single_debug);
+
 QDF_STATUS qdf_nbuf_map_nbytes_debug(qdf_device_t osdev,
 				     qdf_nbuf_t buf,
 				     qdf_dma_dir_t dir,
@@ -796,6 +804,8 @@ QDF_STATUS qdf_nbuf_map_nbytes_debug(qdf_device_t osdev,
 	return status;
 }
 
+qdf_export_symbol(qdf_nbuf_map_nbytes_debug);
+
 void qdf_nbuf_unmap_nbytes_debug(qdf_device_t osdev,
 				 qdf_nbuf_t buf,
 				 qdf_dma_dir_t dir,
@@ -807,6 +817,8 @@ void qdf_nbuf_unmap_nbytes_debug(qdf_device_t osdev,
 	__qdf_nbuf_unmap_nbytes(osdev, buf, dir, nbytes);
 }
 
+qdf_export_symbol(qdf_nbuf_unmap_nbytes_debug);
+
 QDF_STATUS qdf_nbuf_map_nbytes_single_debug(qdf_device_t osdev,
 					    qdf_nbuf_t buf,
 					    qdf_dma_dir_t dir,
@@ -827,6 +839,8 @@ QDF_STATUS qdf_nbuf_map_nbytes_single_debug(qdf_device_t osdev,
 	return status;
 }
 
+qdf_export_symbol(qdf_nbuf_map_nbytes_single_debug);
+
 void qdf_nbuf_unmap_nbytes_single_debug(qdf_device_t osdev,
 					qdf_nbuf_t buf,
 					qdf_dma_dir_t dir,
@@ -837,7 +851,9 @@ void qdf_nbuf_unmap_nbytes_single_debug(qdf_device_t osdev,
 	qdf_nbuf_untrack_map(buf, file, line);
 	__qdf_nbuf_unmap_nbytes_single(osdev, buf, dir, nbytes);
 }
-#endif /* MEMORY_DEBUG */
+
+qdf_export_symbol(qdf_nbuf_unmap_nbytes_single_debug);
+#endif /* NBUF_MEMORY_DEBUG */
 
 /**
  * __qdf_nbuf_map() - map a buffer to local bus address space
@@ -2055,7 +2071,7 @@ bool __qdf_nbuf_is_bcast_pkt(qdf_nbuf_t nbuf)
 }
 qdf_export_symbol(__qdf_nbuf_is_bcast_pkt);
 
-#ifdef MEMORY_DEBUG
+#ifdef NBUF_MEMORY_DEBUG
 #define QDF_NET_BUF_TRACK_MAX_SIZE    (1024)
 
 /**
@@ -2625,7 +2641,20 @@ free_buf:
 }
 qdf_export_symbol(qdf_nbuf_free_debug);
 
-#endif /*MEMORY_DEBUG */
+#else
+void qdf_net_buf_debug_init(void)
+{
+}
+
+qdf_export_symbol(qdf_net_buf_debug_init);
+
+void qdf_net_buf_debug_exit(void)
+{
+}
+
+qdf_export_symbol(qdf_net_buf_debug_exit);
+
+#endif /*NBUF_MEMORY_DEBUG */
 #if defined(FEATURE_TSO)
 
 /**

+ 2 - 10
qdf/linux/src/qdf_trace.c

@@ -2579,7 +2579,7 @@ static void set_default_trace_levels(struct category_info *cinfo)
 		[QDF_MODULE_ID_PE] = QDF_TRACE_LEVEL_NONE,
 		[QDF_MODULE_ID_WMA] = QDF_TRACE_LEVEL_NONE,
 		[QDF_MODULE_ID_SYS] = QDF_TRACE_LEVEL_NONE,
-		[QDF_MODULE_ID_QDF] = QDF_TRACE_LEVEL_NONE,
+		[QDF_MODULE_ID_QDF] = QDF_TRACE_LEVEL_ERROR,
 		[QDF_MODULE_ID_SAP] = QDF_TRACE_LEVEL_NONE,
 		[QDF_MODULE_ID_HDD_SOFTAP] = QDF_TRACE_LEVEL_NONE,
 		[QDF_MODULE_ID_HDD_DATA] = QDF_TRACE_LEVEL_NONE,
@@ -2640,14 +2640,7 @@ static void set_default_trace_levels(struct category_info *cinfo)
 void qdf_shared_print_ctrl_init(void)
 {
 	int i;
-	struct category_info *cinfo = qdf_mem_malloc((sizeof(*cinfo))*
-			MAX_SUPPORTED_CATEGORY);
-	if (cinfo == NULL) {
-		pr_info("ERROR!! qdf_mem_malloc failed. \
-			Shared Print Ctrl object not initialized \
-			\nQDF_TRACE messages may not be logged/displayed");
-		return;
-	}
+	struct category_info cinfo[MAX_SUPPORTED_CATEGORY];
 
 	set_default_trace_levels(cinfo);
 
@@ -2674,7 +2667,6 @@ void qdf_shared_print_ctrl_init(void)
 	}
 	qdf_pidx = qdf_print_ctrl_register(cinfo, NULL, NULL,
 			"LOG_SHARED_OBJ");
-	qdf_mem_free(cinfo);
 }
 qdf_export_symbol(qdf_shared_print_ctrl_init);
 #endif

+ 1 - 1
wmi/inc/wmi_unified_api.h

@@ -196,7 +196,7 @@ wmi_unified_remove_work(struct wmi_unified *wmi_handle);
  *  @param len             : length of the buffer
  *  @return wmi_buf_t.
  */
-#ifdef MEMORY_DEBUG
+#ifdef NBUF_MEMORY_DEBUG
 #define wmi_buf_alloc(h, l) wmi_buf_alloc_debug(h, l, __FILE__, __LINE__)
 wmi_buf_t
 wmi_buf_alloc_debug(wmi_unified_t wmi_handle, uint16_t len,

+ 1 - 1
wmi/src/wmi_unified.c

@@ -1216,7 +1216,7 @@ qdf_export_symbol(wmi_mgmt_cmd_record);
 int wmi_get_host_credits(wmi_unified_t wmi_handle);
 /* WMI buffer APIs */
 
-#ifdef MEMORY_DEBUG
+#ifdef NBUF_MEMORY_DEBUG
 wmi_buf_t
 wmi_buf_alloc_debug(wmi_unified_t wmi_handle, uint16_t len, uint8_t *file_name,
 			uint32_t line_num)