[PATCH v4 3/3] drm/print: fix drm_printer dynamic debug bit-test bypass

From: Jim Cromie via B4 Relay

Date: Tue Nov 24 2026 - 18:38:51 EST


From: Jim Cromie <jim.cromie@xxxxxxxxx>

drm_debug_enabled() [$1] is the canonical bit-test for drm.debug.
Commit 6ce6fae84536 ("drm_print: optimize drm_debug_enabled for
jump-label") elaborated it into 4 names, controlled by
CONFIG_DRM_USE_DYNAMIC_DEBUG:

A- $1_raw() - rename of the original bit-test.
B- $1_instrumented() - like raw, but adds a pr_debug(), allowing us to
count callsite frequency and consider optimizing them later.
C- __$1() - evaluates to 'true' when CONFIG_DRM_USE_DYNAMIC_DEBUG=y
(avoiding the bit-test where callsites are already guarded by a
dyndbg static-key), and forwards to A when =n.
D- $1() - forwards to B when CONFIG_DRM_USE_DYNAMIC_DEBUG=y, and to A
when =n, for cases where an explicit bit-mask check is required.

Later, commit 9fd6f61a297e ("drm/print: add drm_dbg_printer() for drm
device specific printer") added a general-use __drm_printfn_dbg()
function, but used __$1() instead of $1(). When
CONFIG_DRM_USE_DYNAMIC_DEBUG=y, __$1() evaluates to 'true' and always
prints. This went unnoticed because CONFIG_DRM_USE_DYNAMIC_DEBUG was
marked BROKEN.

With =y, this results in a flood of messages, and in CI-tests on slow
serial consoles, creates bottlenecks, as seen in DRM-CI on i915 CML
devices. When IGT causes a mismatch in intel_pipe_config_compare(),
the resulting UART storm causes a hard timeout after 20 minutes.

NOTES:

Drop the single-use `category` local variable and pass p->category
directly (which previously also triggered an unused-variable warning
under the old __$1() bypass).

Because __drm_printfn_dbg() is a shared helper invoked via p->printfn
with a runtime p->category, the callsite cannot be guarded by a
static-key; we'd need a macro version and callsites where category is
a compile-time constant.

Replacing __$1() with $1() or $1_raw() would also work, but
$1_instrumented() adds the pr_debug() in both =y and =n configs; when
enabled it can provide call-freq data to inform further callsite
optimization choices.

Fixes: 9fd6f61a297e ("drm/print: add drm_dbg_printer() for drm device specific printer")
Signed-off-by: Jim Cromie <jim.cromie@xxxxxxxxx>
---
drivers/gpu/drm/drm_print.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c
index 2e7685849f44..3d26483975f2 100644
--- a/drivers/gpu/drm/drm_print.c
+++ b/drivers/gpu/drm/drm_print.c
@@ -218,9 +218,8 @@ 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;

- if (!__drm_debug_enabled(category))
+ if (!drm_debug_enabled_instrumented(p->category))
return;

__drm_dev_vprintk(dev, KERN_DEBUG, p->origin, p->prefix, vaf);

--
2.56.1