dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Sam Ravnborg <sam@ravnborg.org>
To: dri-devel@lists.freedesktop.org,
	Jani Nikula <jani.nikula@intel.com>,
	Daniel Vetter <daniel@ffwll.ch>
Cc: Joe Perches <joe@perches.com>, Sam Ravnborg <sam@ravnborg.org>,
	Sean Paul <sean@poorly.run>
Subject: [PATCH v1 7/8] drm/print: add drm_pr_ logging
Date: Sat, 21 Dec 2019 10:55:52 +0100	[thread overview]
Message-ID: <20191221095553.13332-8-sam@ravnborg.org> (raw)
In-Reply-To: <20191221095553.13332-1-sam@ravnborg.org>

Add standard logging functions that can be used when
no struct device *, nor struct drm_device * is available.

Include brief documentation.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Sean Paul <sean@poorly.run>
Cc: Daniel Vetter <daniel@ffwll.ch>
---
 include/drm/drm_print.h | 88 ++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 87 insertions(+), 1 deletion(-)

diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h
index b2e5d0209010..0b0468340573 100644
--- a/include/drm/drm_print.h
+++ b/include/drm/drm_print.h
@@ -384,7 +384,46 @@ static inline struct drm_printer drm_err_printer(const char *prefix)
  *
  * Logging when no &device * nor &drm_device * is available
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- * TODO
+ *
+ * When there is neither a struct &drm_device *, nor a struct device * use
+ * the logging variants that does not take a pointer.
+ * It is important to note that the logging core cannot provide much extra
+ * info but as the logging has a fixed *[drm]* prefix then the logging continue
+ * to be easy to spot.
+ *
+ * All logging functions in this block share the same prototype:
+ *
+ * .. code-block:: c
+ *
+ *   void drm_pr_xxx(char * fmt, ...)
+ *
+ * The following functions are available:
+ *
+ * .. code-block:: none
+ *
+ *   # Plain logging
+ *   drm_pr_dbg()
+ *   drm_pr_info()
+ *   drm_pr_notice()
+ *   drm_pr_warn()
+ *   drm_pr_err()
+ *
+ *   # Log only once
+ *   drm_pr_info_once()
+ *   drm_pr_notice_once()
+ *   drm_pr_warn_once()
+ *   drm_pr_err_once()
+ *
+ *   # Logging with a specific category
+ *   drm_pr_dbg_core()
+ *   drm_pr_dbg()		# Uses the DRIVER category
+ *   drm_pr_dbg_kms()
+ *   drm_pr_dbg_prime()
+ *   drm_pr_dbg_atomic()
+ *   drm_pr_dbg_vbl()
+ *   drm_pr_dbg_state()
+ *   drm_pr_dbg_lease()
+ *   drm_pr_dbg_dp()
  *
  * Obsoleted logging functions
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -565,6 +604,53 @@ static inline bool drm_debug_enabled(enum drm_debug_category category)
 #define drm_dev_dbg_dp(dev, fmt, ...)					\
 	__drm_dev_cat_printk((dev), DRM_UT_DP,, fmt, ##__VA_ARGS__)
 
+/* logging with no struct device * and no struct drm_device * */
+#define __drm_pr_printk(level, type, fmt, ...)				\
+	pr_##level##type("[drm] " fmt, ##__VA_ARGS__)
+
+#define __drm_pr_cat_printk(cat, type, fmt, ...)			\
+({									\
+	if (drm_debug_enabled(cat))					\
+		pr_debug##type("[drm] " fmt, ##__VA_ARGS__);		\
+})
+
+#define drm_pr_info(fmt, ...)						\
+	__drm_pr_printk(info,, fmt, ##__VA_ARGS__)
+#define drm_pr_notice(fmt, ...)						\
+	__drm_pr_printk(notice,, fmt, ##__VA_ARGS__)
+#define drm_pr_warn(fmt, ...)						\
+	__drm_pr_printk(warn,, fmt, ##__VA_ARGS__)
+#define drm_pr_err(fmt, ...)						\
+	__drm_pr_printk(err,, "*ERROR* " fmt, ##__VA_ARGS__)
+
+#define drm_pr_info_once(fmt, ...)					\
+	__drm_pr_printk(info, _once, fmt, ##__VA_ARGS__)
+#define drm_pr_notice_once(fmt, ...)					\
+	__drm_pr_printk(notice, _once, fmt, ##__VA_ARGS__)
+#define drm_pr_warn_once(fmt, ...)					\
+	__drm_pr_printk(warn, _once, fmt, ##__VA_ARGS__)
+#define drm_pr_err_once(fmt, ...)					\
+	__drm_pr_printk(err, _once, "*ERROR* " fmt, ##__VA_ARGS__)
+
+#define drm_pr_dbg_core(fmt, ...)					\
+	__drm_pr_cat_printk(DRM_UT_CORE,, fmt, ##__VA_ARGS__)
+#define drm_pr_dbg(fmt, ...)						\
+	__drm_pr_cat_printk(DRM_UT_DRIVER,, fmt, ##__VA_ARGS__)
+#define drm_pr_dbg_kms(fmt, ...)					\
+	__drm_pr_cat_printk(DRM_UT_KMS,, fmt, ##__VA_ARGS__)
+#define drm_pr_dbg_prime(fmt, ...)					\
+	__drm_pr_cat_printk(DRM_UT_PRIME,, fmt, ##__VA_ARGS__)
+#define drm_pr_dbg_atomic(fmt, ...)					\
+	__drm_pr_cat_printk(DRM_UT_ATOMIC,, fmt, ##__VA_ARGS__)
+#define drm_pr_dbg_vbl(fmt, ...)					\
+	__drm_pr_cat_printk(DRM_UT_VBL,, fmt, ##__VA_ARGS__)
+#define drm_pr_dbg_state(fmt, ...)					\
+	__drm_pr_cat_printk(DRM_UT_STATE,, fmt, ##__VA_ARGS__)
+#define drm_pr_dbg_lease(fmt, ...)					\
+	__drm_pr_cat_printk(DRM_UT_LEASE,, fmt, ##__VA_ARGS__)
+#define drm_pr_dbg_dp(fmt, ...)						\
+	__drm_pr_cat_printk(DRM_UT_DP,, fmt, ##__VA_ARGS__)
+
 /*
  * LEGACY logging support - do not use in new code
  */
-- 
2.20.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2019-12-21  9:56 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-21  9:55 [RFC PATCH 0/9] drm: add more new-style logging functions Sam Ravnborg
2019-12-21  9:55 ` [PATCH v1 1/8] drm/print: document " Sam Ravnborg
2019-12-23 11:23   ` Jani Nikula
2019-12-23 12:07     ` Sam Ravnborg
2019-12-21  9:55 ` [PATCH v1 2/8] drm/print: move new style " Sam Ravnborg
2019-12-21  9:55 ` [PATCH v1 3/8] drm/print: add new logging helper for drm logging Sam Ravnborg
2019-12-23 11:16   ` Jani Nikula
2019-12-23 11:18     ` Joe Perches
2019-12-23 12:10     ` Sam Ravnborg
2019-12-21  9:55 ` [PATCH v1 4/8] drm/print: add kernel-doc for drm_debug_enabled Sam Ravnborg
2019-12-23 11:18   ` Jani Nikula
2019-12-21  9:55 ` [PATCH v1 5/8] drm/print: rename drm_dev_dbg Sam Ravnborg
2019-12-21  9:55 ` [PATCH v1 6/8] drm/print: add drm_dev_* logging functions Sam Ravnborg
2019-12-21 13:56   ` Joe Perches
2019-12-21 14:48     ` Sam Ravnborg
2019-12-23 11:21       ` Jani Nikula
2019-12-23 11:29   ` Jani Nikula
2019-12-23 12:35     ` Sam Ravnborg
2019-12-31 14:35       ` Jani Nikula
2019-12-21  9:55 ` Sam Ravnborg [this message]
2019-12-21  9:55 ` [PATCH v1 8/8] drm/print: let legacy logging use new style functions Sam Ravnborg

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=20191221095553.13332-8-sam@ravnborg.org \
    --to=sam@ravnborg.org \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jani.nikula@intel.com \
    --cc=joe@perches.com \
    --cc=sean@poorly.run \
    /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