From: Jim Cromie <[email protected]> When the dynamic debug core is enabled (CONFIG_DYNAMIC_DEBUG_CORE=y) but the global CONFIG_DYNAMIC_DEBUG is disabled, subsystems can opt-in to dynamic debug by defining DYNAMIC_DEBUG_MODULE.
However, for built-in code (like DRM core) where DYNAMIC_DEBUG_MODULE is not defined, the macros fall back to the disabled #else block in include/linux/dynamic_debug.h. In this block, the family of _dynamic_func_call_cls macros were completely undefined. This caused build failures (implicit declarations) in subsystems (like DRM) that attempt to use these macros to wrap their own debug functions even when dynamic debug is disabled. Add stub definitions that mirror the enabled behavior and respect the DEBUG macro, similar to pr_debug. If DEBUG is defined, they inject NULL as the first argument (to satisfy the expected descriptor pointer) and pass the arguments through, allowing the wrapped function's own slow-path fallback logic to execute. If DEBUG is not defined, they use an if (0) statement-expression to compile out the call while returning 0, achieving zero overhead while maintaining compile-time argument checking. Reported-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/ Assisted-by: Gemini-CLI:gemini-2.5-pro Signed-off-by: Jim Cromie <[email protected]> --- include/linux/dynamic_debug.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 0e3af8948a56..ce142ad366dc 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -538,6 +538,23 @@ void ddebug_increment_call_count(void); #define DYNAMIC_DEBUG_BRANCH(descriptor) false #define DECLARE_DYNDBG_CLASSMAP(...) +#if defined(DEBUG) +#define _dynamic_func_call_cls(cls, fmt, func, ...) \ + do { func(NULL, ##__VA_ARGS__); } while (0) +#define _dynamic_func_call_cls_no_desc(cls, fmt, func, ...) \ + do { func(__VA_ARGS__); } while (0) +#else +#define _dynamic_func_call_cls(cls, fmt, func, ...) \ + do { if (0) func(NULL, ##__VA_ARGS__); } while (0) +#define _dynamic_func_call_cls_no_desc(cls, fmt, func, ...) \ + do { if (0) func(__VA_ARGS__); } while (0) +#endif + +#define _dynamic_func_call(fmt, func, ...) \ + _dynamic_func_call_cls(_DPRINTK_CLASS_DFLT, fmt, func, ##__VA_ARGS__) +#define _dynamic_func_call_no_desc(fmt, func, ...) \ + _dynamic_func_call_cls_no_desc(_DPRINTK_CLASS_DFLT, fmt, func, ##__VA_ARGS__) + #define dynamic_pr_debug(fmt, ...) \ no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) #define dynamic_dev_dbg(dev, fmt, ...) \ -- 2.55.0
