[PATCH] drm/nouveau: add nv_error_ratelimited()

Rob Clark robdclark at gmail.com
Thu May 21 16:51:18 PDT 2015


When things go badly, the log is flooded with SCHED_ERROR messages,
which is less than useful.  Instead lets ratelimit these so we can
still find the traces leading up to the problems.

Signed-off-by: Rob Clark <robdclark at gmail.com>
---
 drivers/gpu/drm/nouveau/include/nvkm/core/printk.h | 9 +++++++++
 drivers/gpu/drm/nouveau/nvkm/engine/fifo/gf100.c   | 2 +-
 drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c   | 2 +-
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/printk.h b/drivers/gpu/drm/nouveau/include/nvkm/core/printk.h
index 8364817..aad5a54 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/core/printk.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/core/printk.h
@@ -14,6 +14,15 @@ nv_printk_(struct nvkm_object *, int, const char *, ...);
 
 #define nv_fatal(o,f,a...) nv_printk((o), FATAL, f, ##a)
 #define nv_error(o,f,a...) nv_printk((o), ERROR, f, ##a)
+#define nv_error_ratelimited(o,f,a...) 				\
+({									\
+	static DEFINE_RATELIMIT_STATE(_rs,				\
+				      DEFAULT_RATELIMIT_INTERVAL,	\
+				      DEFAULT_RATELIMIT_BURST);		\
+									\
+	if (__ratelimit(&_rs))						\
+		nv_printk((o), ERROR, f, ##a);				\
+})
 #define nv_warn(o,f,a...) nv_printk((o), WARN, f, ##a)
 #define nv_info(o,f,a...) nv_printk((o), INFO, f, ##a)
 #define nv_debug(o,f,a...) nv_printk((o), DEBUG, f, ##a)
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gf100.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gf100.c
index b745252..d0f47f0 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gf100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gf100.c
@@ -523,7 +523,7 @@ gf100_fifo_intr_sched(struct gf100_fifo_priv *priv)
 	if (!en)
 		snprintf(enunk, sizeof(enunk), "UNK%02x", code);
 
-	nv_error(priv, "SCHED_ERROR [ %s ]\n", en ? en->name : enunk);
+	nv_error_ratelimited(priv, "SCHED_ERROR [ %s ]\n", en ? en->name : enunk);
 
 	switch (code) {
 	case 0x0a:
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c
index e10f964..ac67d0b 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c
@@ -576,7 +576,7 @@ gk104_fifo_intr_sched(struct gk104_fifo_priv *priv)
 	if (!en)
 		snprintf(enunk, sizeof(enunk), "UNK%02x", code);
 
-	nv_error(priv, "SCHED_ERROR [ %s ]\n", en ? en->name : enunk);
+	nv_error_ratelimited(priv, "SCHED_ERROR [ %s ]\n", en ? en->name : enunk);
 
 	switch (code) {
 	case 0x0a:
-- 
2.4.1



More information about the dri-devel mailing list