summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJani Nikula <jani.nikula@intel.com>2024-01-16 15:07:28 +0200
committerJani Nikula <jani.nikula@intel.com>2024-02-09 11:51:53 +0200
commit9fd6f61a297e944fa045a1cb6cd53916d0fea454 (patch)
treee01f6eae9240f0d9b38d49c786809699aee01919
parent82195d48b77c71b5084a6d6a03d0c574a9fc6749 (diff)
downloadlinux-9fd6f61a297e944fa045a1cb6cd53916d0fea454.tar.gz
linux-9fd6f61a297e944fa045a1cb6cd53916d0fea454.tar.bz2
linux-9fd6f61a297e944fa045a1cb6cd53916d0fea454.zip
drm/print: add drm_dbg_printer() for drm device specific printer
We've lacked a device specific debug printer. Add one. Take category into account too. __builtin_return_address(0) is inaccurate here, so don't use it. If necessary, we can later pass __func__ to drm_dbg_printer() by wrapping it inside a macro. Signed-off-by: Jani Nikula <jani.nikula@intel.com> Reviewed-by: Luca Coelho <luciano.coelho@intel.com> Acked-by: Maxime Ripard <mripard@kernel.org> Link: https://patchwork.freedesktop.org/patch/msgid/48607d58e5cdf8341ffdd522257542fa2ce41a19.1705410327.git.jani.nikula@intel.com
-rw-r--r--drivers/gpu/drm/drm_print.c21
-rw-r--r--include/drm/drm_print.h24
2 files changed, 45 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c
index 91dbcdeaad3f..673b29c732ea 100644
--- a/drivers/gpu/drm/drm_print.c
+++ b/drivers/gpu/drm/drm_print.c
@@ -189,6 +189,27 @@ void __drm_printfn_debug(struct drm_printer *p, struct va_format *vaf)
}
EXPORT_SYMBOL(__drm_printfn_debug);
+void __drm_printfn_dbg(struct drm_printer *p, struct va_format *vaf)
+{
+ const struct drm_device *drm = p->arg;
+ const struct device *dev = drm ? drm->dev : NULL;
+ enum drm_debug_category category = p->category;
+ const char *prefix = p->prefix ?: "";
+ const char *prefix_pad = p->prefix ? " " : "";
+
+ if (!__drm_debug_enabled(category))
+ return;
+
+ /* Note: __builtin_return_address(0) is useless here. */
+ if (dev)
+ dev_printk(KERN_DEBUG, dev, "[" DRM_NAME "]%s%s %pV",
+ prefix_pad, prefix, vaf);
+ else
+ printk(KERN_DEBUG "[" DRM_NAME "]%s%s %pV",
+ prefix_pad, prefix, vaf);
+}
+EXPORT_SYMBOL(__drm_printfn_dbg);
+
void __drm_printfn_err(struct drm_printer *p, struct va_format *vaf)
{
struct drm_device *drm = p->arg;
diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h
index 2d57939429a9..c6a7a7fecccc 100644
--- a/include/drm/drm_print.h
+++ b/include/drm/drm_print.h
@@ -176,6 +176,7 @@ struct drm_printer {
void (*puts)(struct drm_printer *p, const char *str);
void *arg;
const char *prefix;
+ enum drm_debug_category category;
};
void __drm_printfn_coredump(struct drm_printer *p, struct va_format *vaf);
@@ -184,6 +185,7 @@ void __drm_printfn_seq_file(struct drm_printer *p, struct va_format *vaf);
void __drm_puts_seq_file(struct drm_printer *p, const char *str);
void __drm_printfn_info(struct drm_printer *p, struct va_format *vaf);
void __drm_printfn_debug(struct drm_printer *p, struct va_format *vaf);
+void __drm_printfn_dbg(struct drm_printer *p, struct va_format *vaf);
void __drm_printfn_err(struct drm_printer *p, struct va_format *vaf);
__printf(2, 3)
@@ -332,6 +334,28 @@ static inline struct drm_printer drm_debug_printer(const char *prefix)
}
/**
+ * drm_dbg_printer - construct a &drm_printer for drm device specific output
+ * @drm: the &struct drm_device pointer, or NULL
+ * @category: the debug category to use
+ * @prefix: debug output prefix, or NULL for no prefix
+ *
+ * RETURNS:
+ * The &drm_printer object
+ */
+static inline struct drm_printer drm_dbg_printer(struct drm_device *drm,
+ enum drm_debug_category category,
+ const char *prefix)
+{
+ struct drm_printer p = {
+ .printfn = __drm_printfn_dbg,
+ .arg = drm,
+ .prefix = prefix,
+ .category = category,
+ };
+ return p;
+}
+
+/**
* drm_err_printer - construct a &drm_printer that outputs to drm_err()
* @drm: the &struct drm_device pointer
* @prefix: debug output prefix, or NULL for no prefix