Skip to contentSkip to conversation

Improve drm printer code

PATCH Superseded Michal Wajdeczko 4 participants 11 messages May 17, 2024

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Improve drm printer code

We already have some drm printk functions that need to duplicate a code to get a similar format of the final result, for example:

[ ] 0000:00:00.0: [drm:foo] bar
[ ] 0000:00:00.0: [drm] foo bar
[ ] 0000:00:00.0: [drm] *ERROR* foo

Add a generic __drm_dev_vprintk() function that can format the final message like all other existing function do and allows us to keep the formatting code in one place.

Above also allows to improve drm_dbg_printer() that today lacks of outputing symbolic name of the caller, like drm_dbg() does.

Cc Maxime Ripard <[email protected]>
Cc Jani Nikula <[email protected]>

Michal Wajdeczko (3):
drm/print: Add generic drm dev printk function drm/print: Improve drm_dbg_printer
drm/i915: Don't use __func__ as prefix for drm_dbg_printer

 drivers/gpu/drm/drm_print.c                | 50 ++++++++++++----------
 drivers/gpu/drm/i915/gt/intel_reset.c      |  2 +-
 drivers/gpu/drm/i915/gt/selftest_context.c |  2 +-
 include/drm/drm_print.h                    |  5 +++
 4 files changed, 34 insertions(+), 25 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/3 drm/print: Add generic drm dev printk function

We already have some drm printk functions that need to duplicate a code to get a similar format of the final result, for example:

[ ] 0000:00:00.0: [drm:foo] bar
[ ] 0000:00:00.0: [drm] foo bar
[ ] 0000:00:00.0: [drm] *ERROR* foo

Add a generic __drm_dev_vprintk() function that can format the final message like all other existing function do and allows us to keep the formatting code in one place.

---
 drivers/gpu/drm/drm_print.c | 49 ++++++++++++++++++++-----------------
 include/drm/drm_print.h     |  3 +++
 2 files changed, 30 insertions(+), 22 deletions(-)
drivers/gpu/drm/drm_print.c +27 -22
index cf2efb44722c..a2b60c8245a1 100644
@@ -187,19 +187,12 @@ 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);
+	__drm_dev_vprintk(dev, KERN_DEBUG, NULL, p->prefix, vaf);
 }
 EXPORT_SYMBOL(__drm_printfn_dbg);
 
@@ -277,6 +270,29 @@ void drm_print_bits(struct drm_printer *p, unsigned long value,
 }
 EXPORT_SYMBOL(drm_print_bits);
 
+void __drm_dev_vprintk(const struct device *dev, const char *level,
+		       const void *origin, const char *prefix,
+		       struct va_format *vaf)
+{
+	const char *prefix_pad = prefix ? " " : (prefix = "");
+
+	if (dev)
+		if (origin)
+			dev_printk(level, dev, "[" DRM_NAME ":%ps]%s%s %pV",
+				   origin, prefix_pad, prefix, vaf);
+		else
+			dev_printk(level, dev, "[" DRM_NAME "]%s%s %pV",
+				   prefix_pad, prefix, vaf);
+	else
+		if (origin)
+			printk("%s" "[" DRM_NAME ":%ps]%s%s %pV",
+			       level, origin, prefix_pad, prefix, vaf);
+		else
+			printk("%s" "[" DRM_NAME "]%s%s %pV",
+			       level, prefix_pad, prefix, vaf);
+}
+EXPORT_SYMBOL(__drm_dev_vprintk);
+
 void drm_dev_printk(const struct device *dev, const char *level,
 		    const char *format, ...)
 {
@@ -287,12 +303,7 @@ void drm_dev_printk(const struct device *dev, const char *level,
 	vaf.fmt = format;
 	vaf.va = &args;
 
-	if (dev)
-		dev_printk(level, dev, "[" DRM_NAME ":%ps] %pV",
-			   __builtin_return_address(0), &vaf);
-	else
-		printk("%s" "[" DRM_NAME ":%ps] %pV",
-		       level, __builtin_return_address(0), &vaf);
+	__drm_dev_vprintk(dev, level, __builtin_return_address(0), NULL, &vaf);
 
 	va_end(args);
 }
@@ -312,12 +323,7 @@ void __drm_dev_dbg(struct _ddebug *desc, const struct device *dev,
 	vaf.fmt = format;
 	vaf.va = &args;
 
-	if (dev)
-		dev_printk(KERN_DEBUG, dev, "[" DRM_NAME ":%ps] %pV",
-			   __builtin_return_address(0), &vaf);
-	else
-		printk(KERN_DEBUG "[" DRM_NAME ":%ps] %pV",
-		       __builtin_return_address(0), &vaf);
+	__drm_dev_vprintk(dev, KERN_DEBUG, __builtin_return_address(0), NULL, &vaf);
 
 	va_end(args);
 }
@@ -351,8 +357,7 @@ void __drm_err(const char *format, ...)
 	vaf.fmt = format;
 	vaf.va = &args;
 
-	printk(KERN_ERR "[" DRM_NAME ":%ps] *ERROR* %pV",
-	       __builtin_return_address(0), &vaf);
+	__drm_dev_vprintk(NULL, KERN_ERR, __builtin_return_address(0), "*ERROR*", &vaf);
 
 	va_end(args);
 }
include/drm/drm_print.h +3 -0
index 089950ad8681..bb1801c58544 100644
@@ -366,6 +366,9 @@ static inline struct drm_printer drm_err_printer(struct drm_device *drm,
 __printf(3, 4)
 void drm_dev_printk(const struct device *dev, const char *level,
 		    const char *format, ...);
+void __drm_dev_vprintk(const struct device *dev, const char *level,
+		       const void *origin, const char *prefix,
+		       struct va_format *vaf);
 struct _ddebug;
 __printf(4, 5)
 void __drm_dev_dbg(struct _ddebug *desc, const struct device *dev,
Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH 1/3] drm/print: Add generic drm dev printk function

Quoted 10 lines · Michal Wajdeczko

We already have some drm printk functions that need to duplicate a code to get a similar format of the final result, for example:

[ ] 0000:00:00.0: [drm:foo] bar
[ ] 0000:00:00.0: [drm] foo bar
[ ] 0000:00:00.0: [drm] *ERROR* foo

Add a generic __drm_dev_vprintk() function that can format the final message like all other existing function do and allows us to keep the formatting code in one place.

Nice idea!

Quoted 33 lines
---
 drivers/gpu/drm/drm_print.c | 49 ++++++++++++++++++++-----------------
 include/drm/drm_print.h     |  3 +++
 2 files changed, 30 insertions(+), 22 deletions(-)
drivers/gpu/drm/drm_print.c +1 -8
index cf2efb44722c..a2b60c8245a1 100644
@@ -187,19 +187,12 @@ 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);
+	__drm_dev_vprintk(dev, KERN_DEBUG, NULL, p->prefix, vaf);
 }
 EXPORT_SYMBOL(__drm_printfn_dbg);
 

drivers/gpu/drm/drm_print.c void drm_print_bits(struct drm_printer *p, unsigned long value, · line 277

Quoted 8 lines
drivers/gpu/drm/drm_print.c +5 -0
@@ -277,6 +270,29 @@ void drm_print_bits(struct drm_printer *p, unsigned long value,
 }
 EXPORT_SYMBOL(drm_print_bits);
 
+void __drm_dev_vprintk(const struct device *dev, const char *level,
+		       const void *origin, const char *prefix,
+		       struct va_format *vaf)
+{
+	const char *prefix_pad = prefix ? " " : (prefix = "");

Too clever, please just keep it simple:

	const char *prefix_pad = prefix ? " " : "";

	if (!prefix)
		prefix = "";
Quoted 5 lines
drivers/gpu/drm/drm_print.c +5 -0
+
+	if (dev)
+		if (origin)
+			dev_printk(level, dev, "[" DRM_NAME ":%ps]%s%s %pV",
+				   origin, prefix_pad, prefix, vaf);

drivers/gpu/drm/drm_print.c void drm_print_bits(struct drm_printer *p, unsigned long value, · line 292

Quoted 10 lines
drivers/gpu/drm/drm_print.c +10 -0
+		else
+			dev_printk(level, dev, "[" DRM_NAME "]%s%s %pV",
+				   prefix_pad, prefix, vaf);
+	else
+		if (origin)
+			printk("%s" "[" DRM_NAME ":%ps]%s%s %pV",
+			       level, origin, prefix_pad, prefix, vaf);
+		else
+			printk("%s" "[" DRM_NAME "]%s%s %pV",
+			       level, prefix_pad, prefix, vaf);

I'd sprinkle a few curly braces around the top level if-else blocks.

Side note, feels like using DRM_NAME makes things harder, not easier. But that's for another patch.

drivers/gpu/drm/drm_print.c void drm_print_bits(struct drm_printer *p, unsigned long value, · line 294

Quoted 2 lines
drivers/gpu/drm/drm_print.c +2 -0
+}
+EXPORT_SYMBOL(__drm_dev_vprintk);

AFAICT this could be a non-exported static function. And probably moved earlier in the file to not require a declaration.

BR,
Jani.

Quoted 56 lines
drivers/gpu/drm/drm_print.c +4 -14
+
 void drm_dev_printk(const struct device *dev, const char *level,
 		    const char *format, ...)
 {
@@ -287,12 +303,7 @@ void drm_dev_printk(const struct device *dev, const char *level,
 	vaf.fmt = format;
 	vaf.va = &args;
 
-	if (dev)
-		dev_printk(level, dev, "[" DRM_NAME ":%ps] %pV",
-			   __builtin_return_address(0), &vaf);
-	else
-		printk("%s" "[" DRM_NAME ":%ps] %pV",
-		       level, __builtin_return_address(0), &vaf);
+	__drm_dev_vprintk(dev, level, __builtin_return_address(0), NULL, &vaf);
 
 	va_end(args);
 }
@@ -312,12 +323,7 @@ void __drm_dev_dbg(struct _ddebug *desc, const struct device *dev,
 	vaf.fmt = format;
 	vaf.va = &args;
 
-	if (dev)
-		dev_printk(KERN_DEBUG, dev, "[" DRM_NAME ":%ps] %pV",
-			   __builtin_return_address(0), &vaf);
-	else
-		printk(KERN_DEBUG "[" DRM_NAME ":%ps] %pV",
-		       __builtin_return_address(0), &vaf);
+	__drm_dev_vprintk(dev, KERN_DEBUG, __builtin_return_address(0), NULL, &vaf);
 
 	va_end(args);
 }
@@ -351,8 +357,7 @@ void __drm_err(const char *format, ...)
 	vaf.fmt = format;
 	vaf.va = &args;
 
-	printk(KERN_ERR "[" DRM_NAME ":%ps] *ERROR* %pV",
-	       __builtin_return_address(0), &vaf);
+	__drm_dev_vprintk(NULL, KERN_ERR, __builtin_return_address(0), "*ERROR*", &vaf);
 
 	va_end(args);
 }
include/drm/drm_print.h +3 -0
index 089950ad8681..bb1801c58544 100644
@@ -366,6 +366,9 @@ static inline struct drm_printer drm_err_printer(struct drm_device *drm,
 __printf(3, 4)
 void drm_dev_printk(const struct device *dev, const char *level,
 		    const char *format, ...);
+void __drm_dev_vprintk(const struct device *dev, const char *level,
+		       const void *origin, const char *prefix,
+		       struct va_format *vaf);
 struct _ddebug;
 __printf(4, 5)
 void __drm_dev_dbg(struct _ddebug *desc, const struct device *dev,
Signature · 1 line
Jani Nikula, Intel
#3 lore raw

Re: [PATCH 1/3] drm/print: Add generic drm dev printk function

Quoted 81 lines · Jani Nikula
Quoted 10 lines · Michal Wajdeczko

We already have some drm printk functions that need to duplicate a code to get a similar format of the final result, for example:

[ ] 0000:00:00.0: [drm:foo] bar
[ ] 0000:00:00.0: [drm] foo bar
[ ] 0000:00:00.0: [drm] *ERROR* foo

Add a generic __drm_dev_vprintk() function that can format the final message like all other existing function do and allows us to keep the formatting code in one place.

Nice idea!

Quoted 33 lines
---
 drivers/gpu/drm/drm_print.c | 49 ++++++++++++++++++++-----------------
 include/drm/drm_print.h     |  3 +++
 2 files changed, 30 insertions(+), 22 deletions(-)
drivers/gpu/drm/drm_print.c +1 -8
index cf2efb44722c..a2b60c8245a1 100644
@@ -187,19 +187,12 @@ 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);
+	__drm_dev_vprintk(dev, KERN_DEBUG, NULL, p->prefix, vaf);
 }
 EXPORT_SYMBOL(__drm_printfn_dbg);
 

drivers/gpu/drm/drm_print.c void drm_print_bits(struct drm_printer *p, unsigned long value, · line 277

Quoted 8 lines
drivers/gpu/drm/drm_print.c +5 -0
@@ -277,6 +270,29 @@ void drm_print_bits(struct drm_printer *p, unsigned long value,
 }
 EXPORT_SYMBOL(drm_print_bits);
 
+void __drm_dev_vprintk(const struct device *dev, const char *level,
+		       const void *origin, const char *prefix,
+		       struct va_format *vaf)
+{
+	const char *prefix_pad = prefix ? " " : (prefix = "");

Too clever, please just keep it simple:

	const char *prefix_pad = prefix ? " " : "";

	if (!prefix)
		prefix = "";
Quoted 5 lines
drivers/gpu/drm/drm_print.c +5 -0
+
+	if (dev)
+		if (origin)
+			dev_printk(level, dev, "[" DRM_NAME ":%ps]%s%s %pV",
+				   origin, prefix_pad, prefix, vaf);

drivers/gpu/drm/drm_print.c void drm_print_bits(struct drm_printer *p, unsigned long value, · line 292

Quoted 10 lines
drivers/gpu/drm/drm_print.c +10 -0
+		else
+			dev_printk(level, dev, "[" DRM_NAME "]%s%s %pV",
+				   prefix_pad, prefix, vaf);
+	else
+		if (origin)
+			printk("%s" "[" DRM_NAME ":%ps]%s%s %pV",
+			       level, origin, prefix_pad, prefix, vaf);
+		else
+			printk("%s" "[" DRM_NAME "]%s%s %pV",
+			       level, prefix_pad, prefix, vaf);

I'd sprinkle a few curly braces around the top level if-else blocks.

Quoted 8 lines

Side note, feels like using DRM_NAME makes things harder, not easier. But that's for another patch.

drivers/gpu/drm/drm_print.c void drm_print_bits(struct drm_printer *p, unsigned long value, · line 294

Quoted 2 lines
drivers/gpu/drm/drm_print.c +2 -0
+}
+EXPORT_SYMBOL(__drm_dev_vprintk);

AFAICT this could be a non-exported static function. And probably moved earlier in the file to not require a declaration.

true for now, but I was planning to add Xe GT specific printer that would use this function like this:

+static inline void __xe_gt_printfn_dbg(struct drm_printer *p, struct va_format *vaf)
+{

+       struct xe_gt *gt = p->arg;
+       const struct device *dev = gt_to_xe(gt)->drm.dev;
+       char prefix[8];

+
+ if (!drm_debug_enabled(DRM_UT_DRIVER))
+ return;
+

+       /* xe_gt_dbg() callsite decorations are unhelpful */
+       snprintf(prefix, sizeof(prefix), "GT%u:", gt->info.id);
+       __drm_dev_vprintk(dev, KERN_DEBUG, p->origin, prefix, vaf);

+}
+

but I can add this new custom printer to the series right now in v2 to show the usage and avoid any confusion

Quoted 61 lines

BR,
Jani.

Quoted 56 lines
drivers/gpu/drm/drm_print.c +4 -14
+
 void drm_dev_printk(const struct device *dev, const char *level,
 		    const char *format, ...)
 {
@@ -287,12 +303,7 @@ void drm_dev_printk(const struct device *dev, const char *level,
 	vaf.fmt = format;
 	vaf.va = &args;
 
-	if (dev)
-		dev_printk(level, dev, "[" DRM_NAME ":%ps] %pV",
-			   __builtin_return_address(0), &vaf);
-	else
-		printk("%s" "[" DRM_NAME ":%ps] %pV",
-		       level, __builtin_return_address(0), &vaf);
+	__drm_dev_vprintk(dev, level, __builtin_return_address(0), NULL, &vaf);
 
 	va_end(args);
 }
@@ -312,12 +323,7 @@ void __drm_dev_dbg(struct _ddebug *desc, const struct device *dev,
 	vaf.fmt = format;
 	vaf.va = &args;
 
-	if (dev)
-		dev_printk(KERN_DEBUG, dev, "[" DRM_NAME ":%ps] %pV",
-			   __builtin_return_address(0), &vaf);
-	else
-		printk(KERN_DEBUG "[" DRM_NAME ":%ps] %pV",
-		       __builtin_return_address(0), &vaf);
+	__drm_dev_vprintk(dev, KERN_DEBUG, __builtin_return_address(0), NULL, &vaf);
 
 	va_end(args);
 }
@@ -351,8 +357,7 @@ void __drm_err(const char *format, ...)
 	vaf.fmt = format;
 	vaf.va = &args;
 
-	printk(KERN_ERR "[" DRM_NAME ":%ps] *ERROR* %pV",
-	       __builtin_return_address(0), &vaf);
+	__drm_dev_vprintk(NULL, KERN_ERR, __builtin_return_address(0), "*ERROR*", &vaf);
 
 	va_end(args);
 }
include/drm/drm_print.h +3 -0
index 089950ad8681..bb1801c58544 100644
@@ -366,6 +366,9 @@ static inline struct drm_printer drm_err_printer(struct drm_device *drm,
 __printf(3, 4)
 void drm_dev_printk(const struct device *dev, const char *level,
 		    const char *format, ...);
+void __drm_dev_vprintk(const struct device *dev, const char *level,
+		       const void *origin, const char *prefix,
+		       struct va_format *vaf);
 struct _ddebug;
 __printf(4, 5)
 void __drm_dev_dbg(struct _ddebug *desc, const struct device *dev,
#4 lore raw

PATCH 2/3 drm/print: Improve drm_dbg_printer

In reply to Michal Wajdeczko

With recent introduction of a generic drm dev printk function, we can now store and use location where drm_dbg_printer was invoked and output it's symbolic name like we do for all drm debug prints.

---
 drivers/gpu/drm/drm_print.c | 3 +--
 include/drm/drm_print.h     | 2 ++
 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_print.c +1 -2
index a2b60c8245a1..0a205fdee7cf 100644
@@ -191,8 +191,7 @@ void __drm_printfn_dbg(struct drm_printer *p, struct va_format *vaf)
 	if (!__drm_debug_enabled(category))
 		return;
 
-	/* Note: __builtin_return_address(0) is useless here. */
-	__drm_dev_vprintk(dev, KERN_DEBUG, NULL, p->prefix, vaf);
+	__drm_dev_vprintk(dev, KERN_DEBUG, p->origin, p->prefix, vaf);
 }
 EXPORT_SYMBOL(__drm_printfn_dbg);
 
include/drm/drm_print.h +2 -0
index bb1801c58544..761ce01761b7 100644
@@ -175,6 +175,7 @@ struct drm_printer {
 	void (*printfn)(struct drm_printer *p, struct va_format *vaf);
 	void (*puts)(struct drm_printer *p, const char *str);
 	void *arg;
+	const void *origin;
 	const char *prefix;
 	enum drm_debug_category category;
 };
@@ -332,6 +333,7 @@ static inline struct drm_printer drm_dbg_printer(struct drm_device *drm,
 	struct drm_printer p = {
 		.printfn = __drm_printfn_dbg,
 		.arg = drm,
+		.origin = (void *)_THIS_IP_, /* it's fine as we will be inlined */
 		.prefix = prefix,
 		.category = category,
 	};
Signature · 1 line
2.43.0
Reviewed-by on v1 2/3
#5 lore raw

Re: [PATCH 2/3] drm/print: Improve drm_dbg_printer

Quoted 38 lines · Michal Wajdeczko

With recent introduction of a generic drm dev printk function, we can now store and use location where drm_dbg_printer was invoked and output it's symbolic name like we do for all drm debug prints.

---
 drivers/gpu/drm/drm_print.c | 3 +--
 include/drm/drm_print.h     | 2 ++
 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_print.c +1 -2
index a2b60c8245a1..0a205fdee7cf 100644
@@ -191,8 +191,7 @@ void __drm_printfn_dbg(struct drm_printer *p, struct va_format *vaf)
 	if (!__drm_debug_enabled(category))
 		return;
 
-	/* Note: __builtin_return_address(0) is useless here. */
-	__drm_dev_vprintk(dev, KERN_DEBUG, NULL, p->prefix, vaf);
+	__drm_dev_vprintk(dev, KERN_DEBUG, p->origin, p->prefix, vaf);
 }
 EXPORT_SYMBOL(__drm_printfn_dbg);
 
include/drm/drm_print.h +1 -0
index bb1801c58544..761ce01761b7 100644
@@ -175,6 +175,7 @@ struct drm_printer {
 	void (*printfn)(struct drm_printer *p, struct va_format *vaf);
 	void (*puts)(struct drm_printer *p, const char *str);
 	void *arg;
+	const void *origin;
 	const char *prefix;
 	enum drm_debug_category category;
 };

include/drm/drm_print.h static inline struct drm_printer drm_dbg_printer(struct drm_device *drm, · line 336

Quoted 4 lines
include/drm/drm_print.h +1 -0
@@ -332,6 +333,7 @@ static inline struct drm_printer drm_dbg_printer(struct drm_device *drm,
 	struct drm_printer p = {
 		.printfn = __drm_printfn_dbg,
 		.arg = drm,
+		.origin = (void *)_THIS_IP_, /* it's fine as we will be inlined */

Not that it makes a difference, but I guess I'd cast to (const void *) to match the member.

Quoted 3 lines
include/drm/drm_print.h +0 -0
 		.prefix = prefix,
 		.category = category,
 	};
Signature · 1 line
Jani Nikula, Intel
#6 lore raw

PATCH 3/3 drm/i915: Don't use __func__ as prefix for drm_dbg_printer

In reply to Michal Wajdeczko

Updated code of drm_dbg_printer() is already printing symbolic name of the caller like drm_dbg() does.

---
 drivers/gpu/drm/i915/gt/intel_reset.c      | 2 +-
 drivers/gpu/drm/i915/gt/selftest_context.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/gt/intel_reset.c +1 -1
index 6161f7a3ff70..735cd23a43c6 100644
@@ -1025,7 +1025,7 @@ void intel_gt_set_wedged(struct intel_gt *gt)
 
 	if (GEM_SHOW_DEBUG()) {
 		struct drm_printer p = drm_dbg_printer(&gt->i915->drm,
-						       DRM_UT_DRIVER, __func__);
+						       DRM_UT_DRIVER, NULL);
 		struct intel_engine_cs *engine;
 		enum intel_engine_id id;
 
drivers/gpu/drm/i915/gt/selftest_context.c +1 -1
index 12eca750f7d0..5eb46700dc4e 100644
@@ -286,7 +286,7 @@ static int __live_active_context(struct intel_engine_cs *engine)
 
 	if (intel_engine_pm_is_awake(engine)) {
 		struct drm_printer p = drm_dbg_printer(&engine->i915->drm,
-						       DRM_UT_DRIVER, __func__);
+						       DRM_UT_DRIVER, NULL);
 
 		intel_engine_dump(engine, &p,
 				  "%s is still awake:%d after idle-barriers\n",
Signature · 1 line
2.43.0
maintainer Reviewed-by on v1 3/3
#7 lore raw

Re: [PATCH 3/3] drm/i915: Don't use __func__ as prefix for drm_dbg_printer

Quoted 4 lines · Michal Wajdeczko

Updated code of drm_dbg_printer() is already printing symbolic name of the caller like drm_dbg() does.

Quoted 31 lines
---
 drivers/gpu/drm/i915/gt/intel_reset.c      | 2 +-
 drivers/gpu/drm/i915/gt/selftest_context.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/gt/intel_reset.c +1 -1
index 6161f7a3ff70..735cd23a43c6 100644
@@ -1025,7 +1025,7 @@ void intel_gt_set_wedged(struct intel_gt *gt)
 
 	if (GEM_SHOW_DEBUG()) {
 		struct drm_printer p = drm_dbg_printer(&gt->i915->drm,
-						       DRM_UT_DRIVER, __func__);
+						       DRM_UT_DRIVER, NULL);
 		struct intel_engine_cs *engine;
 		enum intel_engine_id id;
 
drivers/gpu/drm/i915/gt/selftest_context.c +1 -1
index 12eca750f7d0..5eb46700dc4e 100644
@@ -286,7 +286,7 @@ static int __live_active_context(struct intel_engine_cs *engine)
 
 	if (intel_engine_pm_is_awake(engine)) {
 		struct drm_printer p = drm_dbg_printer(&engine->i915->drm,
-						       DRM_UT_DRIVER, __func__);
+						       DRM_UT_DRIVER, NULL);
 
 		intel_engine_dump(engine, &p,
 				  "%s is still awake:%d after idle-barriers\n",
Signature · 1 line
Jani Nikula, Intel
#8 lore raw

✗ Fi.CI.CHECKPATCH: warning for Improve drm printer code

In reply to Michal Wajdeczko
== Series Details ==

== Series Details ==

Series: Improve drm printer code
URL : https://patchwork.freedesktop.org/series/133749/
State : warning

== Summary ==

Error: dim checkpatch failed
6cab5b4517bb drm/print: Add generic drm dev printk function
-:64: WARNING:PRINTK_WITHOUT_KERN_LEVEL: printk() should include KERN_<LEVEL> facility level #64: FILE: drivers/gpu/drm/drm_print.c:288:
+ printk("%s" "[" DRM_NAME ":%ps]%s%s %pV",

-:64: WARNING:STRING_FRAGMENTS: Consecutive strings are generally better as a single string #64: FILE: drivers/gpu/drm/drm_print.c:288:
+ printk("%s" "[" DRM_NAME ":%ps]%s%s %pV",

-:67: WARNING:PRINTK_WITHOUT_KERN_LEVEL: printk() should include KERN_<LEVEL> facility level #67: FILE: drivers/gpu/drm/drm_print.c:291:
+ printk("%s" "[" DRM_NAME "]%s%s %pV",

-:67: WARNING:STRING_FRAGMENTS: Consecutive strings are generally better as a single string #67: FILE: drivers/gpu/drm/drm_print.c:291:
+ printk("%s" "[" DRM_NAME "]%s%s %pV",

total: 0 errors, 4 warnings, 0 checks, 93 lines checked a4fd3a4ec7e7 drm/print: Improve drm_dbg_printer
6b5b0966356e drm/i915: Don't use __func__ as prefix for drm_dbg_printer

#10 lore raw

✓ Fi.CI.BAT: success for Improve drm printer code

In reply to Michal Wajdeczko
== Series Details ==

== Series Details ==

Series: Improve drm printer code
URL : https://patchwork.freedesktop.org/series/133749/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_14781 -> Patchwork_133749v1
====================================================

Summary
-------

**SUCCESS**

No regressions found.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_133749v1/index.html

Participating hosts (45 -> 43)
------------------------------

Missing (2): fi-snb-2520m fi-kbl-8809g

Known issues
------------

Here are the changes found in Patchwork_133749v1 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@i915_module_load@load:
- bat-arls-3: [PASS][1] -> [ABORT][2] ([i915#11041])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14781/bat-arls-3/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_133749v1/bat-arls-3/igt@[email protected]

#### Possible fixes ####

* igt@gem_lmem_swapping@basic@lmem0:
- bat-dg2-8: [FAIL][3] ([i915#10378]) -> [PASS][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14781/bat-dg2-8/igt@gem_lmem_swapping@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_133749v1/bat-dg2-8/igt@gem_lmem_swapping@[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[i915#10378]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/10378
[i915#10435]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/10435
[i915#11041]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/11041
[i915#9157]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/9157

Build changes
-------------

* Linux: CI_DRM_14781 -> Patchwork_133749v1

CI-20190529: 20190529
CI_DRM_14781: d953159dab6ba6800d7316fb516ca2330dcbefe4 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_7860: 05b3f5540c6dcaacdf2169dc730c126df9ffd7e2 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_133749v1: d953159dab6ba6800d7316fb516ca2330dcbefe4 @ git://anongit.freedesktop.org/gfx-ci/linux

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_133749v1/index.html