From: Tvrtko Ursulin <tursulin@ursulin.net>
To: Intel-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Subject: [RFC 4/5] drm: Use drm_printk for all logging macros
Date: Tue, 6 Dec 2016 18:58:00 +0000 [thread overview]
Message-ID: <1481050681-23416-5-git-send-email-tvrtko.ursulin@linux.intel.com> (raw)
In-Reply-To: <1481050681-23416-1-git-send-email-tvrtko.ursulin@linux.intel.com>
From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Eliminate _DRM_PRINTK macro and use drm_printk for all log levels.
This required drm_printk to vary the verbosity level of the logged
metadata depending on the log level.
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
drivers/gpu/drm/drm_drv.c | 31 ++++++++++++++++++++++---------
include/drm/drmP.h | 44 ++++++++++++++++++++++++++++++--------------
2 files changed, 52 insertions(+), 23 deletions(-)
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index a2f4eb4509b9..bda4639c73e4 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -80,12 +80,21 @@ void drm_dev_printk(const struct device *dev, const char *level,
vaf.fmt = format;
vaf.va = &args;
- if (dev)
- dev_printk(level, dev, "[%s:%ps]%s %pV",
- driver, function_name, prefix, &vaf);
- else
- printk("%s[%s:%ps]%s %pV",
- level, driver, function_name, prefix, &vaf);
+ if (level[1] != KERN_DEBUG[1]) {
+ if (dev)
+ dev_printk(level, dev, "[%s]%s %pV",
+ driver, prefix, &vaf);
+ else
+ printk("%s[%s]%s %pV",
+ level, driver, prefix, &vaf);
+ } else {
+ if (dev)
+ dev_printk(level, dev, "[%s:%ps]%s %pV",
+ driver, function_name, prefix, &vaf);
+ else
+ printk("%s[%s:%ps]%s %pV",
+ level, driver, function_name, prefix, &vaf);
+ }
va_end(args);
}
@@ -104,9 +113,13 @@ void drm_printk(const char *level, unsigned int category,
vaf.fmt = format;
vaf.va = &args;
- printk("%s[%s:%ps]%s %pV",
- level, driver, __builtin_return_address(0),
- strcmp(level, KERN_ERR) == 0 ? " *ERROR*" : "", &vaf);
+ if (level[1] != KERN_DEBUG[1])
+ printk("%s[%s]%s %pV",
+ level, driver,
+ strcmp(level, KERN_ERR) == 0 ? " *ERROR*" : "", &vaf);
+ else
+ printk("%s[%s:%ps] %pV",
+ level, driver, __builtin_return_address(0), &vaf);
va_end(args);
}
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 8661045ffaf1..b8f9dcd49b36 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -146,25 +146,41 @@ struct dma_buf_attachment;
/** \name Macros to make printk easier */
/*@{*/
-#define _DRM_PRINTK(once, level, fmt, ...) \
- do { \
- printk##once(KERN_##level "[" DRM_NAME "] " fmt, \
- ##__VA_ARGS__); \
- } while (0)
-
#define DRM_INFO(fmt, ...) \
- _DRM_PRINTK(, INFO, fmt, ##__VA_ARGS__)
-#define DRM_NOTE(fmt, ...) \
- _DRM_PRINTK(, NOTICE, fmt, ##__VA_ARGS__)
-#define DRM_WARN(fmt, ...) \
- _DRM_PRINTK(, WARNING, fmt, ##__VA_ARGS__)
+ drm_printk(KERN_INFO, DRM_UT_NONE, DRM_NAME, fmt, ##__VA_ARGS__)
#define DRM_INFO_ONCE(fmt, ...) \
- _DRM_PRINTK(_once, INFO, fmt, ##__VA_ARGS__)
+({ \
+ static bool __print_once __read_mostly; \
+ if (!__print_once) { \
+ __print_once = true; \
+ DRM_INFO(fmt, ##__VA_ARGS__); \
+ } \
+})
+
+#define DRM_NOTE(fmt, ...) \
+ drm_printk(KERN_NOTICE, DRM_UT_NONE, DRM_NAME, fmt, ##__VA_ARGS__)
+
#define DRM_NOTE_ONCE(fmt, ...) \
- _DRM_PRINTK(_once, NOTICE, fmt, ##__VA_ARGS__)
+({ \
+ static bool __print_once __read_mostly; \
+ if (!__print_once) { \
+ __print_once = true; \
+ DRM_NOTE(fmt, ##__VA_ARGS__); \
+ } \
+})
+
+#define DRM_WARN(fmt, ...) \
+ drm_printk(KERN_WARNING, DRM_UT_NONE, DRM_NAME, fmt, ##__VA_ARGS__)
+
#define DRM_WARN_ONCE(fmt, ...) \
- _DRM_PRINTK(_once, WARNING, fmt, ##__VA_ARGS__)
+({ \
+ static bool __print_once __read_mostly; \
+ if (!__print_once) { \
+ __print_once = true; \
+ DRM_WARN(fmt, ##__VA_ARGS__); \
+ } \
+})
/**
* Error output.
--
2.7.4
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2016-12-06 18:58 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-06 18:57 [RFC 0/5] DRM logging tidy Tvrtko Ursulin
2016-12-06 18:57 ` [RFC 1/5] drm/i915: Give our log messages our name Tvrtko Ursulin
2016-12-06 18:57 ` [RFC 2/5] drm: Respect driver set DRM_NAME in drm_printk Tvrtko Ursulin
2016-12-06 18:57 ` [RFC 3/5] drm: Respect driver set DRM_NAME in drm_dev_printk Tvrtko Ursulin
2016-12-06 18:58 ` Tvrtko Ursulin [this message]
2016-12-06 18:58 ` [RFC 5/5] drm: Do not log driver prefix in debug messages Tvrtko Ursulin
2016-12-06 19:49 ` Gustavo Padovan
2016-12-07 6:52 ` [Intel-gfx] " Tvrtko Ursulin
2016-12-06 19:31 ` ✗ Fi.CI.BAT: failure for DRM logging tidy Patchwork
2016-12-07 17:44 ` [RFC 0/5] " Robert Bragg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1481050681-23416-5-git-send-email-tvrtko.ursulin@linux.intel.com \
--to=tursulin@ursulin.net \
--cc=Intel-gfx@lists.freedesktop.org \
--cc=dri-devel@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox