Commit 5e0c04c8 authored by Jani Nikula's avatar Jani Nikula

drm/print: make drm_err_printer() device specific by using drm_err()

With few users for drm_err_printer(), it's still feasible to convert it
to be device specific. Use drm_err() under the hood.

While at it, make the prefix optional.
Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
Reviewed-by: default avatarLuca Coelho <luciano.coelho@intel.com>
Acked-by: default avatarMaxime Ripard <mripard@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/2a9cdcfc1df44568078f7c131e2e7e0f7c94e97e.1705410327.git.jani.nikula@intel.com
parent 27b8f91c
...@@ -191,7 +191,12 @@ EXPORT_SYMBOL(__drm_printfn_debug); ...@@ -191,7 +191,12 @@ EXPORT_SYMBOL(__drm_printfn_debug);
void __drm_printfn_err(struct drm_printer *p, struct va_format *vaf) void __drm_printfn_err(struct drm_printer *p, struct va_format *vaf)
{ {
pr_err("*ERROR* %s %pV", p->prefix, vaf); struct drm_device *drm = p->arg;
if (p->prefix)
drm_err(drm, "%s %pV", p->prefix, vaf);
else
drm_err(drm, "%pV", vaf);
} }
EXPORT_SYMBOL(__drm_printfn_err); EXPORT_SYMBOL(__drm_printfn_err);
......
...@@ -122,7 +122,7 @@ static int __live_idle_pulse(struct intel_engine_cs *engine, ...@@ -122,7 +122,7 @@ static int __live_idle_pulse(struct intel_engine_cs *engine,
GEM_BUG_ON(!llist_empty(&engine->barrier_tasks)); GEM_BUG_ON(!llist_empty(&engine->barrier_tasks));
if (engine_sync_barrier(engine)) { if (engine_sync_barrier(engine)) {
struct drm_printer m = drm_err_printer("pulse"); struct drm_printer m = drm_err_printer(&engine->i915->drm, "pulse");
pr_err("%s: no heartbeat pulse?\n", engine->name); pr_err("%s: no heartbeat pulse?\n", engine->name);
intel_engine_dump(engine, &m, "%s", engine->name); intel_engine_dump(engine, &m, "%s", engine->name);
...@@ -136,7 +136,7 @@ static int __live_idle_pulse(struct intel_engine_cs *engine, ...@@ -136,7 +136,7 @@ static int __live_idle_pulse(struct intel_engine_cs *engine,
pulse_unlock_wait(p); /* synchronize with the retirement callback */ pulse_unlock_wait(p); /* synchronize with the retirement callback */
if (!i915_active_is_idle(&p->active)) { if (!i915_active_is_idle(&p->active)) {
struct drm_printer m = drm_err_printer("pulse"); struct drm_printer m = drm_err_printer(&engine->i915->drm, "pulse");
pr_err("%s: heartbeat pulse did not flush idle tasks\n", pr_err("%s: heartbeat pulse did not flush idle tasks\n",
engine->name); engine->name);
......
...@@ -156,7 +156,7 @@ static int live_active_wait(void *arg) ...@@ -156,7 +156,7 @@ static int live_active_wait(void *arg)
__i915_active_wait(&active->base, TASK_UNINTERRUPTIBLE); __i915_active_wait(&active->base, TASK_UNINTERRUPTIBLE);
if (!READ_ONCE(active->retired)) { if (!READ_ONCE(active->retired)) {
struct drm_printer p = drm_err_printer(__func__); struct drm_printer p = drm_err_printer(&i915->drm, __func__);
pr_err("i915_active not retired after waiting!\n"); pr_err("i915_active not retired after waiting!\n");
i915_active_print(&active->base, &p); i915_active_print(&active->base, &p);
...@@ -189,7 +189,7 @@ static int live_active_retire(void *arg) ...@@ -189,7 +189,7 @@ static int live_active_retire(void *arg)
err = -EIO; err = -EIO;
if (!READ_ONCE(active->retired)) { if (!READ_ONCE(active->retired)) {
struct drm_printer p = drm_err_printer(__func__); struct drm_printer p = drm_err_printer(&i915->drm, __func__);
pr_err("i915_active not retired after flushing!\n"); pr_err("i915_active not retired after flushing!\n");
i915_active_print(&active->base, &p); i915_active_print(&active->base, &p);
......
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
#include <drm/drm.h> #include <drm/drm.h>
struct drm_device;
/* Do *not* use outside of drm_print.[ch]! */ /* Do *not* use outside of drm_print.[ch]! */
extern unsigned long __drm_debug; extern unsigned long __drm_debug;
...@@ -235,16 +237,19 @@ static inline struct drm_printer drm_debug_printer(const char *prefix) ...@@ -235,16 +237,19 @@ static inline struct drm_printer drm_debug_printer(const char *prefix)
} }
/** /**
* drm_err_printer - construct a &drm_printer that outputs to pr_err() * drm_err_printer - construct a &drm_printer that outputs to drm_err()
* @prefix: debug output prefix * @drm: the &struct drm_device pointer
* @prefix: debug output prefix, or NULL for no prefix
* *
* RETURNS: * RETURNS:
* The &drm_printer object * The &drm_printer object
*/ */
static inline struct drm_printer drm_err_printer(const char *prefix) static inline struct drm_printer drm_err_printer(struct drm_device *drm,
const char *prefix)
{ {
struct drm_printer p = { struct drm_printer p = {
.printfn = __drm_printfn_err, .printfn = __drm_printfn_err,
.arg = drm,
.prefix = prefix .prefix = prefix
}; };
return p; return p;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment