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
This commit is contained in:
Mohammed Siddiq
2022-02-10 12:45:41 +05:30
کامیت شده توسط Madan Koyyalamudi
والد 2fa299894c
کامیت b53ad320b6
2فایلهای تغییر یافته به همراه27 افزوده شده و 3 حذف شده

مشاهده پرونده

@@ -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