Skip to content

Commit

Permalink
drm_print: interpose drm_*dbg with forwarding macros
Browse files Browse the repository at this point in the history
change drm_dev_dbg & drm_dbg to macros, which forward to the renamed
functions (with __ prefix added).

Those functions sit below the categorized layer of macros implementing
the DRM debug.category API, and implement most of it.  These are good
places to insert dynamic-debug jump-label mechanics, which will allow
DRM to avoid the runtime cost of drm_debug_enabled().

no functional changes.

memory cost baseline: (unchanged)
bash-5.1# drms_load
[    9.220389] dyndbg:   1 debug prints in module drm
[    9.224426] ACPI: bus type drm_connector registered
[    9.302192] dyndbg:   2 debug prints in module ttm
[    9.305033] dyndbg:   8 debug prints in module video
[    9.627563] dyndbg: 127 debug prints in module i915
[    9.721505] AMD-Vi: AMD IOMMUv2 functionality not available on this system - This is not a bug.
[   10.091345] dyndbg: 2196 debug prints in module amdgpu
[   10.106589] [drm] amdgpu kernel modesetting enabled.
[   10.107270] amdgpu: CRAT table not found
[   10.107926] amdgpu: Virtual CRAT table created for CPU
[   10.108398] amdgpu: Topology: Add CPU node
[   10.168507] dyndbg:   3 debug prints in module wmi
[   10.329587] dyndbg:   3 debug prints in module nouveau

Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Link: https://lore.kernel.org/r/20220912052852.1123868-4-jim.cromie@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Jim Cromie authored and Greg Kroah-Hartman committed Sep 24, 2022
1 parent f158936 commit e820f52
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
10 changes: 5 additions & 5 deletions drivers/gpu/drm/drm_print.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ void drm_dev_printk(const struct device *dev, const char *level,
}
EXPORT_SYMBOL(drm_dev_printk);

void drm_dev_dbg(const struct device *dev, enum drm_debug_category category,
const char *format, ...)
void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category,
const char *format, ...)
{
struct va_format vaf;
va_list args;
Expand All @@ -301,9 +301,9 @@ void drm_dev_dbg(const struct device *dev, enum drm_debug_category category,

va_end(args);
}
EXPORT_SYMBOL(drm_dev_dbg);
EXPORT_SYMBOL(__drm_dev_dbg);

void __drm_dbg(enum drm_debug_category category, const char *format, ...)
void ___drm_dbg(enum drm_debug_category category, const char *format, ...)
{
struct va_format vaf;
va_list args;
Expand All @@ -320,7 +320,7 @@ void __drm_dbg(enum drm_debug_category category, const char *format, ...)

va_end(args);
}
EXPORT_SYMBOL(__drm_dbg);
EXPORT_SYMBOL(___drm_dbg);

void __drm_err(const char *format, ...)
{
Expand Down
9 changes: 7 additions & 2 deletions include/drm/drm_print.h
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ __printf(3, 4)
void drm_dev_printk(const struct device *dev, const char *level,
const char *format, ...);
__printf(3, 4)
void drm_dev_dbg(const struct device *dev, enum drm_debug_category category,
void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category,
const char *format, ...);

/**
Expand Down Expand Up @@ -384,6 +384,9 @@ void drm_dev_dbg(const struct device *dev, enum drm_debug_category category,
} \
})

#define drm_dev_dbg(dev, cat, fmt, ...) \
__drm_dev_dbg(dev, cat, fmt, ##__VA_ARGS__)

/**
* DRM_DEV_DEBUG() - Debug output for generic drm code
*
Expand Down Expand Up @@ -485,10 +488,12 @@ void drm_dev_dbg(const struct device *dev, enum drm_debug_category category,
*/

__printf(2, 3)
void __drm_dbg(enum drm_debug_category category, const char *format, ...);
void ___drm_dbg(enum drm_debug_category category, const char *format, ...);
__printf(1, 2)
void __drm_err(const char *format, ...);

#define __drm_dbg(fmt, ...) ___drm_dbg(fmt, ##__VA_ARGS__)

/* Macros to make printk easier */

#define _DRM_PRINTK(once, level, fmt, ...) \
Expand Down

0 comments on commit e820f52

Please sign in to comment.