Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1457329

[PATCH 6/7] drm: Add ratelimited versions of the DRM_DEBUG* macros

From Lyude <cpaul@redhat.com>
Newsgroups linux.kernel
Subject [PATCH 6/7] drm: Add ratelimited versions of the DRM_DEBUG* macros
Date 2016-08-06 22:30 +0200
Message-ID <s3goi-263-29@gated-at.bofh.it> (permalink)
References <s3goh-263-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


There's a couple of places where this would be useful for drivers (such
as reporting DP aux transaction timeouts).

Signed-off-by: Lyude <cpaul@redhat.com>
---
 include/drm/drmP.h | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index d377865..1c4d91b 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -231,6 +231,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)
+
 /*@}*/
 
 /***********************************************************************/
-- 
2.7.4

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH 6/7] drm: Add ratelimited versions of the DRM_DEBUG* macros Lyude <cpaul@redhat.com> - 2016-08-06 22:30 +0200
  Re: [PATCH 6/7] drm: Add ratelimited versions of the DRM_DEBUG*  macros Joe Perches <joe@perches.com> - 2016-08-06 22:40 +0200

csiph-web