Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm_print: add _ddebug descriptor to drm_*dbg prototypes

upgrade the callchain to drm_dbg() and drm_dev_dbg(); add a struct
_ddebug ptr parameter to them, and supply that additional param by
replacing the '_no_desc' flavor of dyndbg Factory macro currently used
with the flavor that supplies the descriptor.

NOTES:

The descriptor gives these fns access to the decorator flags, but they
do none of the dynamic-prefixing done by dynamic_emit_prefix(), which
is currently static.

DRM already has conventions for logging/messaging; just tossing
optional decorations on top probably wouldn't help. Instead, existing
flags (or new ones, perhaps 'sd' ala lspci) can be used to make
current message conventions optional. This suggests a new
drmdbg_prefix_emit() to handle prefixing locally.

For CONFIG_DRM_USE_DYNAMIC_DEBUG=N, just pass null descriptor.

desc->class_id is redundant with category parameter, but its
availability is dependent on desc.

Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Link: https://lore.kernel.org/r/20220912052852.1123868-10-jim.cromie@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jim Cromie and committed by
Greg Kroah-Hartman
16deeb8e ccc2b496

+17 -14
+5 -3
drivers/gpu/drm/drm_print.c
··· 29 29 #include <linux/moduleparam.h> 30 30 #include <linux/seq_file.h> 31 31 #include <linux/slab.h> 32 + #include <linux/dynamic_debug.h> 32 33 33 34 #include <drm/drm.h> 34 35 #include <drm/drm_drv.h> ··· 279 278 } 280 279 EXPORT_SYMBOL(drm_dev_printk); 281 280 282 - void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category, 283 - const char *format, ...) 281 + void __drm_dev_dbg(struct _ddebug *desc, const struct device *dev, 282 + enum drm_debug_category category, const char *format, ...) 284 283 { 285 284 struct va_format vaf; 286 285 va_list args; ··· 288 287 if (!__drm_debug_enabled(category)) 289 288 return; 290 289 290 + /* we know we are printing for either syslog, tracefs, or both */ 291 291 va_start(args, format); 292 292 vaf.fmt = format; 293 293 vaf.va = &args; ··· 304 302 } 305 303 EXPORT_SYMBOL(__drm_dev_dbg); 306 304 307 - void ___drm_dbg(enum drm_debug_category category, const char *format, ...) 305 + void ___drm_dbg(struct _ddebug *desc, enum drm_debug_category category, const char *format, ...) 308 306 { 309 307 struct va_format vaf; 310 308 va_list args;
+12 -11
include/drm/drm_print.h
··· 354 354 __printf(3, 4) 355 355 void drm_dev_printk(const struct device *dev, const char *level, 356 356 const char *format, ...); 357 - __printf(3, 4) 358 - void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category, 359 - const char *format, ...); 357 + struct _ddebug; 358 + __printf(4, 5) 359 + void __drm_dev_dbg(struct _ddebug *desc, const struct device *dev, 360 + enum drm_debug_category category, const char *format, ...); 360 361 361 362 /** 362 363 * DRM_DEV_ERROR() - Error output. ··· 407 406 408 407 #if !defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) 409 408 #define drm_dev_dbg(dev, cat, fmt, ...) \ 410 - __drm_dev_dbg(dev, cat, fmt, ##__VA_ARGS__) 409 + __drm_dev_dbg(NULL, dev, cat, fmt, ##__VA_ARGS__) 411 410 #else 412 411 #define drm_dev_dbg(dev, cat, fmt, ...) \ 413 - _dynamic_func_call_no_desc(fmt, __drm_dev_dbg, \ 414 - dev, cat, fmt, ##__VA_ARGS__) 412 + _dynamic_func_call_cls(cat, fmt, __drm_dev_dbg, \ 413 + dev, cat, fmt, ##__VA_ARGS__) 415 414 #endif 416 415 417 416 /** ··· 515 514 * Prefer drm_device based logging over device or prink based logging. 516 515 */ 517 516 518 - __printf(2, 3) 519 - void ___drm_dbg(enum drm_debug_category category, const char *format, ...); 517 + __printf(3, 4) 518 + void ___drm_dbg(struct _ddebug *desc, enum drm_debug_category category, const char *format, ...); 520 519 __printf(1, 2) 521 520 void __drm_err(const char *format, ...); 522 521 523 522 #if !defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) 524 - #define __drm_dbg(fmt, ...) ___drm_dbg(fmt, ##__VA_ARGS__) 523 + #define __drm_dbg(fmt, ...) ___drm_dbg(NULL, fmt, ##__VA_ARGS__) 525 524 #else 526 525 #define __drm_dbg(cat, fmt, ...) \ 527 - _dynamic_func_call_no_desc(fmt, ___drm_dbg, \ 528 - cat, fmt, ##__VA_ARGS__) 526 + _dynamic_func_call_cls(cat, fmt, ___drm_dbg, \ 527 + cat, fmt, ##__VA_ARGS__) 529 528 #endif 530 529 531 530 /* Macros to make printk easier */