Преглед изворни кода

qcacmn: Refactor the hif_latency detection code based on the bitmap

Based on the bitmap whether the issue is because of the
HIF_DETECT_TASKLET or HIF_DETECT_CREDIT, the hif_latency detection
code needs to be refactor to different functions so that it will
help parsing tools to find the reason of crash.

Change-Id: I2d8a83493354dfbd1c484cb7727018ddeb14c158
CRs-Fixed: 2929736
Abdul Muqtadeer Ahmed пре 4 година
родитељ
комит
f284efa6f8
2 измењених фајлова са 56 додато и 29 уклоњено
  1. 2 0
      hif/inc/hif.h
  2. 54 29
      hif/src/hif_main.c

+ 2 - 0
hif/inc/hif.h

@@ -1920,6 +1920,8 @@ void hif_latency_detect_credit_record_time(
 
 void hif_latency_detect_timer_start(struct hif_opaque_softc *hif_ctx);
 void hif_latency_detect_timer_stop(struct hif_opaque_softc *hif_ctx);
+void hif_tasklet_latency(struct hif_softc *scn, bool from_timer);
+void hif_credit_latency(struct hif_softc *scn, bool from_timer);
 void hif_check_detection_latency(struct hif_softc *scn,
 				 bool from_timer,
 				 uint32_t bitmap_type);

+ 54 - 29
hif/src/hif_main.c

@@ -651,44 +651,24 @@ static void hif_cpuhp_unregister(struct hif_softc *scn)
 #endif /* ifdef HIF_CPU_PERF_AFFINE_MASK */
 
 #ifdef HIF_DETECTION_LATENCY_ENABLE
-/**
- * hif_check_detection_latency(): to check if latency for tasklet/credit
- *
- * @scn: hif context
- * @from_timer: if called from timer handler
- * @bitmap_type: indicate if check tasklet or credit
- *
- * Return: none
- */
-void hif_check_detection_latency(struct hif_softc *scn,
-				 bool from_timer,
-				 uint32_t bitmap_type)
+
+void hif_tasklet_latency(struct hif_softc *scn, bool from_timer)
 {
 	qdf_time_t ce2_tasklet_sched_time =
 		scn->latency_detect.ce2_tasklet_sched_time;
 	qdf_time_t ce2_tasklet_exec_time =
 		scn->latency_detect.ce2_tasklet_exec_time;
-	qdf_time_t credit_request_time =
-		scn->latency_detect.credit_request_time;
-	qdf_time_t credit_report_time =
-		scn->latency_detect.credit_report_time;
 	qdf_time_t curr_jiffies = qdf_system_ticks();
 	uint32_t detect_latency_threshold =
 		scn->latency_detect.detect_latency_threshold;
 	int cpu_id = qdf_get_cpu();
 
-	if (QDF_GLOBAL_MISSION_MODE != hif_get_conparam(scn))
-		return;
-
-	if (!scn->latency_detect.enable_detection)
-		return;
-
 	/* 2 kinds of check here.
-	 * from_timer==true:  check if tasklet or credit report stall
-	 * from_timer==false: check tasklet execute or credit report comes late
+	 * from_timer==true:  check if tasklet stall
+	 * from_timer==false: check tasklet execute comes late
 	 */
-	if (bitmap_type & BIT(HIF_DETECT_TASKLET) &&
-	    (from_timer ?
+
+	if ((from_timer ?
 	    qdf_system_time_after(ce2_tasklet_sched_time,
 				  ce2_tasklet_exec_time) :
 	    qdf_system_time_after(ce2_tasklet_exec_time,
@@ -704,9 +684,29 @@ void hif_check_detection_latency(struct hif_softc *scn,
 			cpu_id, (void *)_RET_IP_);
 		goto latency;
 	}
+	return;
 
-	if (bitmap_type & BIT(HIF_DETECT_CREDIT) &&
-	    (from_timer ?
+latency:
+	qdf_trigger_self_recovery(NULL, QDF_TASKLET_CREDIT_LATENCY_DETECT);
+}
+
+void hif_credit_latency(struct hif_softc *scn, bool from_timer)
+{
+	qdf_time_t credit_request_time =
+		scn->latency_detect.credit_request_time;
+	qdf_time_t credit_report_time =
+		scn->latency_detect.credit_report_time;
+	qdf_time_t curr_jiffies = qdf_system_ticks();
+	uint32_t detect_latency_threshold =
+		scn->latency_detect.detect_latency_threshold;
+	int cpu_id = qdf_get_cpu();
+
+	/* 2 kinds of check here.
+	 * from_timer==true:  check if credit report stall
+	 * from_timer==false: check credit report comes late
+	 */
+
+	if ((from_timer ?
 	    qdf_system_time_after(credit_request_time,
 				  credit_report_time) :
 	    qdf_system_time_after(credit_report_time,
@@ -722,13 +722,38 @@ void hif_check_detection_latency(struct hif_softc *scn,
 			cpu_id, (void *)_RET_IP_);
 		goto latency;
 	}
-
 	return;
 
 latency:
 	qdf_trigger_self_recovery(NULL, QDF_TASKLET_CREDIT_LATENCY_DETECT);
 }
 
+/**
+ * hif_check_detection_latency(): to check if latency for tasklet/credit
+ *
+ * @scn: hif context
+ * @from_timer: if called from timer handler
+ * @bitmap_type: indicate if check tasklet or credit
+ *
+ * Return: none
+ */
+void hif_check_detection_latency(struct hif_softc *scn,
+				 bool from_timer,
+				 uint32_t bitmap_type)
+{
+	if (QDF_GLOBAL_MISSION_MODE != hif_get_conparam(scn))
+		return;
+
+	if (!scn->latency_detect.enable_detection)
+		return;
+
+	if (bitmap_type & BIT(HIF_DETECT_TASKLET))
+		hif_tasklet_latency(scn, from_timer);
+
+	if (bitmap_type & BIT(HIF_DETECT_CREDIT))
+		hif_credit_latency(scn, from_timer);
+}
+
 static void hif_latency_detect_timeout_handler(void *arg)
 {
 	struct hif_softc *scn = (struct hif_softc *)arg;