Bläddra i källkod

qcacmn: Always enable ce debug history for ce2/ce3

Current there is no ce debug history when testing
perf build, so it is hard to debug some issue.

Here it only enable ce2/ce3 on perf build, which keep
only necessary log here.

Change-Id: I29b998939cfa25f0547a9871721c6daeb0fdd961
CRs-Fixed: 3058740
Jingxiang Ge 3 år sedan
förälder
incheckning
a1f2c00c65
3 ändrade filer med 126 tillägg och 11 borttagningar
  1. 32 2
      hif/inc/hif.h
  2. 91 6
      hif/src/ce/ce_main.c
  3. 3 3
      hif/src/hif_main.h

+ 32 - 2
hif/inc/hif.h

@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 2013-2021 The Linux Foundation. All rights reserved.
- * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2013-2022 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. 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
@@ -1712,6 +1712,36 @@ ssize_t hif_ce_en_desc_hist(struct hif_softc *scn,
 				const char *buf, size_t size);
 ssize_t hif_disp_ce_enable_desc_data_hist(struct hif_softc *scn, char *buf);
 ssize_t hif_dump_desc_event(struct hif_softc *scn, char *buf);
+/**
+ * hif_ce_debug_history_prealloc_init() - alloc ce debug history memory
+ *
+ * alloc ce debug history memory with driver init, so such memory can
+ * be existed even after stop module.
+ * on ini value.
+ *
+ * Return: QDF_STATUS_SUCCESS for success, other for fail.
+ */
+QDF_STATUS hif_ce_debug_history_prealloc_init(void);
+/**
+ * hif_ce_debug_history_prealloc_deinit() - free ce debug history memory
+ *
+ * free ce debug history memory when driver deinit.
+ *
+ * Return: QDF_STATUS_SUCCESS for success, other for fail.
+ */
+QDF_STATUS hif_ce_debug_history_prealloc_deinit(void);
+#else
+static inline
+QDF_STATUS hif_ce_debug_history_prealloc_init(void)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+static inline
+QDF_STATUS hif_ce_debug_history_prealloc_deinit(void)
+{
+	return QDF_STATUS_SUCCESS;
+}
 #endif/*#if defined(HIF_CONFIG_SLUB_DEBUG_ON)||defined(HIF_CE_DEBUG_DATA_BUF)*/
 
 /**

+ 91 - 6
hif/src/ce/ce_main.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2021 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2022 The Linux Foundation. All rights reserved.
  * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
@@ -1905,6 +1905,7 @@ QDF_STATUS alloc_mem_ce_debug_hist_data(struct hif_softc *scn, uint32_t ce_id)
 			(uint8_t *)qdf_mem_malloc(CE_DEBUG_MAX_DATA_BUF_SIZE);
 		if (!event->data) {
 			hif_err_rl("ce debug data alloc failed");
+			scn->hif_ce_desc_hist.data_enable[ce_id] = false;
 			return QDF_STATUS_E_NOMEM;
 		}
 	}
@@ -1944,7 +1945,72 @@ void free_mem_ce_debug_hist_data(struct hif_softc *scn, uint32_t ce_id)
 
 #ifndef HIF_CE_DEBUG_DATA_DYNAMIC_BUF
 #if defined(HIF_CONFIG_SLUB_DEBUG_ON) || defined(HIF_CE_DEBUG_DATA_BUF)
-struct hif_ce_desc_event hif_ce_desc_history[CE_COUNT_MAX][HIF_CE_HISTORY_MAX];
+struct hif_ce_desc_event *hif_ce_desc_history[CE_COUNT_MAX];
+
+/* define this variable for crashscope parse */
+uint32_t hif_ce_history_max = HIF_CE_HISTORY_MAX;
+
+/**
+ * hif_ce_debug_only_enable_ce2_ce3() - if only enable ce2/ce3 debug
+ * This is different config for perf/debug buid version.
+ * for debug build, it will enable ce history for all ce, but for
+ * perf build(if CONFIG_SLUB_DEBUG_ON is N), it only enable for
+ * ce2(wmi event) & ce3(wmi cmd) history.
+ *
+ * Return: true if only enable ce2/ce3 debug, otherwise false.
+ */
+#if defined(CONFIG_SLUB_DEBUG_ON)
+static inline bool hif_ce_debug_only_enable_ce2_ce3(void)
+{
+	return false;
+}
+#else
+static inline bool hif_ce_debug_only_enable_ce2_ce3(void)
+{
+	return true;
+}
+#endif
+
+QDF_STATUS hif_ce_debug_history_prealloc_deinit(void)
+{
+	int ce_id;
+
+	for (ce_id = 0; ce_id < CE_COUNT_MAX; ce_id++) {
+		if (hif_ce_desc_history[ce_id]) {
+			qdf_mem_free(hif_ce_desc_history[ce_id]);
+			hif_ce_desc_history[ce_id] = NULL;
+		}
+	}
+	hif_debug("ce debug memory freed");
+
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS hif_ce_debug_history_prealloc_init(void)
+{
+	int ce_id;
+
+	hif_debug("alloc ce debug memory, only_ce2/ce3 %d",
+		  hif_ce_debug_only_enable_ce2_ce3());
+	for (ce_id = 0; ce_id < CE_COUNT_MAX; ce_id++) {
+		if (hif_ce_debug_only_enable_ce2_ce3() &&
+		    ce_id != CE_ID_2 &&
+		    ce_id != CE_ID_3) {
+			hif_ce_desc_history[ce_id] = NULL;
+			continue;
+		}
+
+		hif_ce_desc_history[ce_id] =
+			qdf_mem_malloc(HIF_CE_HISTORY_MAX *
+				       sizeof(struct hif_ce_desc_event));
+		if (!hif_ce_desc_history[ce_id]) {
+			hif_ce_debug_history_prealloc_deinit();
+			return QDF_STATUS_E_NOMEM;
+		}
+	}
+
+	return QDF_STATUS_SUCCESS;
+}
 
 /**
  * alloc_mem_ce_debug_history() - Allocate CE descriptor history
@@ -1959,13 +2025,29 @@ alloc_mem_ce_debug_history(struct hif_softc *scn, unsigned int ce_id,
 {
 	struct ce_desc_hist *ce_hist = &scn->hif_ce_desc_hist;
 	QDF_STATUS status = QDF_STATUS_SUCCESS;
+
+	if (hif_ce_debug_only_enable_ce2_ce3() &&
+	    ce_id != CE_ID_2 &&
+	    ce_id != CE_ID_3) {
+		ce_hist->enable[ce_id] = false;
+		ce_hist->data_enable[ce_id] = false;
+		return QDF_STATUS_SUCCESS;
+	}
+
+	if (!hif_ce_desc_history[ce_id]) {
+		hif_err("prealloc memory failed");
+		return QDF_STATUS_E_NOMEM;
+	}
 	ce_hist->hist_ev[ce_id] = hif_ce_desc_history[ce_id];
-	ce_hist->enable[ce_id] = 1;
+	ce_hist->enable[ce_id] = true;
 
 	if (src_nentries) {
 		status = alloc_mem_ce_debug_hist_data(scn, ce_id);
-		if (status != QDF_STATUS_SUCCESS)
+		if (status != QDF_STATUS_SUCCESS) {
+			ce_hist->enable[ce_id] = false;
+			ce_hist->hist_ev[ce_id] = NULL;
 			return status;
+		}
 	} else {
 		ce_hist->data_enable[ce_id] = false;
 	}
@@ -1984,7 +2066,10 @@ static void free_mem_ce_debug_history(struct hif_softc *scn, unsigned int ce_id)
 {
 	struct ce_desc_hist *ce_hist = &scn->hif_ce_desc_hist;
 
-	ce_hist->enable[ce_id] = 0;
+	if (!ce_hist->enable[ce_id])
+		return;
+
+	ce_hist->enable[ce_id] = false;
 	if (ce_hist->data_enable[ce_id]) {
 		ce_hist->data_enable[ce_id] = false;
 		free_mem_ce_debug_hist_data(scn, ce_id);
@@ -2034,7 +2119,7 @@ static void free_mem_ce_debug_history(struct hif_softc *scn, unsigned int CE_id)
 		free_mem_ce_debug_hist_data(scn, CE_id);
 	}
 
-	ce_hist->enable[CE_id] = 0;
+	ce_hist->enable[CE_id] = false;
 	qdf_mem_free(ce_hist->hist_ev[CE_id]);
 	ce_hist->hist_ev[CE_id] = NULL;
 }

+ 3 - 3
hif/src/hif_main.h

@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 2013-2021 The Linux Foundation. All rights reserved.
- * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2013-2022 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. 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
@@ -186,7 +186,7 @@ struct hif_latency_detect {
 #if defined(HIF_CONFIG_SLUB_DEBUG_ON) || defined(HIF_CE_DEBUG_DATA_BUF)
 struct ce_desc_hist {
 	qdf_atomic_t history_index[CE_COUNT_MAX];
-	uint32_t enable[CE_COUNT_MAX];
+	bool enable[CE_COUNT_MAX];
 	bool data_enable[CE_COUNT_MAX];
 	qdf_mutex_t ce_dbg_datamem_lock[CE_COUNT_MAX];
 	uint32_t hist_index;