From: Rob Clark Date: Thu, 21 Nov 2013 19:29:51 +0000 (-0500) Subject: drm: add DRM_ERROR_RATELIMITED X-Git-Tag: v3.14-rc1~47^2~88 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5d13d425eb58d28c8be6dc8bf706ca361373c3ba;p=profile%2Fcommon%2Fkernel-common.git drm: add DRM_ERROR_RATELIMITED For error traces in situations that can run away, it is nice to have a rate-limited version of DRM_ERROR() to avoid massive log flooding. Signed-off-by: Rob Clark Reviewed-by: Thierry Reding Signed-off-by: Dave Airlie --- diff --git a/include/drm/drmP.h b/include/drm/drmP.h index 1d4a920..bc07c7a 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -56,6 +56,7 @@ #include #include #include +#include #if defined(__alpha__) || defined(__powerpc__) #include /* For pte_wrprotect */ #endif @@ -180,6 +181,22 @@ int drm_err(const char *func, const char *format, ...); #define DRM_ERROR(fmt, ...) \ drm_err(__func__, fmt, ##__VA_ARGS__) +/** + * Rate limited error output. Like DRM_ERROR() but won't flood the log. + * + * \param fmt printf() like format string. + * \param arg arguments + */ +#define DRM_ERROR_RATELIMITED(fmt, ...) \ +({ \ + static DEFINE_RATELIMIT_STATE(_rs, \ + DEFAULT_RATELIMIT_INTERVAL, \ + DEFAULT_RATELIMIT_BURST); \ + \ + if (__ratelimit(&_rs)) \ + drm_err(__func__, fmt, ##__VA_ARGS__); \ +}) + #define DRM_INFO(fmt, ...) \ printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__)