UPSTREAM: drm: Add ratelimited versions of the DRM_DEBUG* macros
authorLyude <cpaul@redhat.com>
Sat, 6 Aug 2016 00:30:38 +0000 (20:30 -0400)
committerHuang, Tao <huangtao@rock-chips.com>
Mon, 19 Dec 2016 10:04:51 +0000 (18:04 +0800)
There's a couple of places where this would be useful for drivers (such
as reporting DP aux transaction timeouts).

Change-Id: I027648bacec5e23890f6743207d66858f91c05df
Signed-off-by: Lyude <cpaul@redhat.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1470443443-27252-7-git-send-email-cpaul@redhat.com
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit 27528c667a210845b35a1f49c810dba469bced52)

include/drm/drmP.h

index d0fb88499350b37e448e5e234ad9c329f1cf1682..6ebc3fc7bb3bdb54f346fd4ae8cfaf5d7cf8f392 100644 (file)
@@ -227,6 +227,36 @@ void drm_err(const char *format, ...);
                        drm_ut_debug_printk(__func__, fmt, ##args);     \
        } while (0)
 
+#define _DRM_DEFINE_DEBUG_RATELIMITED(level, fmt, args...)             \
+       do {                                                            \
+               if (unlikely(drm_debug & DRM_UT_ ## level)) {           \
+                       static DEFINE_RATELIMIT_STATE(                  \
+                               _rs,                                    \
+                               DEFAULT_RATELIMIT_INTERVAL,             \
+                               DEFAULT_RATELIMIT_BURST);               \
+                                                                       \
+                       if (__ratelimit(&_rs)) {                        \
+                               drm_ut_debug_printk(__func__, fmt,      \
+                                                   ##args);            \
+                       }                                               \
+               }                                                       \
+       } while (0)
+
+/**
+ * Rate limited debug output. Like DRM_DEBUG() but won't flood the log.
+ *
+ * \param fmt printf() like format string.
+ * \param arg arguments
+ */
+#define DRM_DEBUG_RATELIMITED(fmt, args...)                            \
+       _DRM_DEFINE_DEBUG_RATELIMITED(CORE, fmt, ##args)
+#define DRM_DEBUG_DRIVER_RATELIMITED(fmt, args...)                     \
+       _DRM_DEFINE_DEBUG_RATELIMITED(DRIVER, fmt, ##args)
+#define DRM_DEBUG_KMS_RATELIMITED(fmt, args...)                                \
+       _DRM_DEFINE_DEBUG_RATELIMITED(KMS, fmt, ##args)
+#define DRM_DEBUG_PRIME_RATELIMITED(fmt, args...)                      \
+       _DRM_DEFINE_DEBUG_RATELIMITED(PRIME, fmt, ##args)
+
 /*@}*/
 
 /***********************************************************************/