فهرست منبع

qcacld-3.0: Add code to rate limit pld logs

Due to SPF, multiple drivers are supported and are loaded
run time. It is expected for one driver to fail to load,
however the failing driver should not flood the dmesg.
Add code to rate limit pld logs to avoid flooding of dmesg.

Change-Id: I1a3b397a3e1de750e520b62d97ccea19a4bbbf7d
Mohammed Siddiq 3 سال پیش
والد
کامیت
b53ad320b6
2فایلهای تغییر یافته به همراه27 افزوده شده و 3 حذف شده
  1. 24 0
      core/pld/inc/pld_common.h
  2. 3 3
      core/pld/src/pld_common.c

+ 24 - 0
core/pld/inc/pld_common.h

@@ -52,6 +52,30 @@
 #endif
 #endif
 
+#define PLD_LIMIT_LOG_FOR_SEC 6
+/**
+ * __PLD_TRACE_RATE_LIMITED() - rate limited version of PLD_TRACE
+ * @params: parameters to pass through to PLD_TRACE
+ *
+ * This API prevents logging a message more than once in PLD_LIMIT_LOG_FOR_SEC
+ * seconds. This means any subsequent calls to this API from the same location
+ * within PLD_LIMIT_LOG_FOR_SEC seconds will be dropped.
+ *
+ * Return: None
+ */
+#define __PLD_TRACE_RATE_LIMITED(params...)\
+	do {\
+		static ulong __last_ticks;\
+		ulong __ticks = jiffies;\
+		if (time_after(__ticks,\
+			       __last_ticks + (HZ * PLD_LIMIT_LOG_FOR_SEC))) {\
+			pr_err(params);\
+			__last_ticks = __ticks;\
+		} \
+	} while (0)
+
+#define pld_err_rl(params...) __PLD_TRACE_RATE_LIMITED(params)
+
 /**
  * enum pld_bus_type - bus type
  * @PLD_BUS_TYPE_NONE: invalid bus type, only return in error cases

+ 3 - 3
core/pld/src/pld_common.c

@@ -330,14 +330,14 @@ int pld_register_driver(struct pld_driver_ops *ops)
 
 	ret = pld_pcie_register_driver();
 	if (ret) {
-		pr_err("Fail to register pcie driver\n");
+		pld_err_rl("Fail to register pcie driver\n");
 		goto fail_pcie;
 	}
 	pld_context->pld_driver_state |= PLD_PCIE_REGISTERED;
 
 	ret = pld_snoc_register_driver();
 	if (ret) {
-		pr_err("Fail to register snoc driver\n");
+		pld_err_rl("Fail to register snoc driver\n");
 		goto fail_snoc;
 	}
 	pld_context->pld_driver_state |= PLD_SNOC_REGISTERED;
@@ -372,7 +372,7 @@ int pld_register_driver(struct pld_driver_ops *ops)
 
 	ret = pld_ipci_register_driver();
 	if (ret) {
-		pr_err("Fail to register ipci driver\n");
+		pld_err_rl("Fail to register ipci driver\n");
 		goto fail_ipci;
 	}
 	pld_context->pld_driver_state |= PLD_IPCI_REGISTERED;