Skip to content

Commit c5261e9

Browse files
committed
drm/print: Fixup DRM_DEBUG_KMS_RATELIMITED()
Since we're about to move drm_dp_helper.c over to drm_dbg_*(), we'll want to make sure that we can also add ratelimited versions of these macros in order to retain some of the previous debugging output behavior we had. However, as I was preparing to do this I noticed that the current rate limited macros we have are kind of bogus. It looks like when I wrote these, I didn't notice that we'd always be calling __ratelimit() even if the debugging message we'd be printing would normally be filtered out due to the relevant DRM debugging category being disabled. So, let's fix this by making sure to check drm_debug_enabled() in our ratelimited macros before calling __ratelimit(), and start using drm_dev_printk() in order to print debugging messages since that will save us from doing a redundant drm_debug_enabled() check. And while we're at it, let's move the code for this into another macro that we can reuse for defining new ratelimited DRM debug macros more easily. v2: * Make sure to use tabs where possible in __DRM_DEFINE_DBG_RATELIMITED() Signed-off-by: Lyude Paul <[email protected]> Cc: Robert Foss <[email protected]> Reviewed-by: Robert Foss <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 39c17ae commit c5261e9

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

include/drm/drm_print.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -524,16 +524,20 @@ void __drm_err(const char *format, ...);
524524
#define DRM_DEBUG_DP(fmt, ...) \
525525
__drm_dbg(DRM_UT_DP, fmt, ## __VA_ARGS__)
526526

527-
528-
#define DRM_DEBUG_KMS_RATELIMITED(fmt, ...) \
529-
({ \
530-
static DEFINE_RATELIMIT_STATE(_rs, \
531-
DEFAULT_RATELIMIT_INTERVAL, \
532-
DEFAULT_RATELIMIT_BURST); \
533-
if (__ratelimit(&_rs)) \
534-
drm_dev_dbg(NULL, DRM_UT_KMS, fmt, ##__VA_ARGS__); \
527+
#define __DRM_DEFINE_DBG_RATELIMITED(category, drm, fmt, ...) \
528+
({ \
529+
static DEFINE_RATELIMIT_STATE(rs_, DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST);\
530+
const struct drm_device *drm_ = (drm); \
531+
\
532+
if (drm_debug_enabled(DRM_UT_ ## category) && __ratelimit(&rs_)) \
533+
drm_dev_printk(drm_ ? drm_->dev : NULL, KERN_DEBUG, fmt, ## __VA_ARGS__); \
535534
})
536535

536+
#define drm_dbg_kms_ratelimited(drm, fmt, ...) \
537+
__DRM_DEFINE_DBG_RATELIMITED(KMS, drm, fmt, ## __VA_ARGS__)
538+
539+
#define DRM_DEBUG_KMS_RATELIMITED(fmt, ...) drm_dbg_kms_ratelimited(NULL, fmt, ## __VA_ARGS__)
540+
537541
/*
538542
* struct drm_device based WARNs
539543
*

0 commit comments

Comments
 (0)