diff mbox series

[v3,1/3] drm/print: Add drm_debug_once* macros

Message ID 20220510183313.1046628-2-jouni.hogander@intel.com (mailing list archive)
State New, archived
Headers show
Series Fixes for selective fetch area calculation | expand

Commit Message

Hogander, Jouni May 10, 2022, 6:33 p.m. UTC
Add drm_debug_once* macros to allow printing out one time debug
messages which can be still controlled via drm.debug parameter.

Cc: José Roberto de Souza <jose.souza@intel.com>
Cc: Mika Kahola <mika.kahola@intel.com>
Cc: Mark Pearson <markpearson@lenovo.com>
Signed-off-by: Jouni Högander <jouni.hogander@intel.com>
---
 include/drm/drm_print.h | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

Comments

Souza, Jose May 10, 2022, 7:22 p.m. UTC | #1
On Tue, 2022-05-10 at 21:33 +0300, Jouni Högander wrote:
> Add drm_debug_once* macros to allow printing out one time debug
> messages which can be still controlled via drm.debug parameter.

Reviewed-by: José Roberto de Souza <jose.souza@intel.com>

> 
> Cc: José Roberto de Souza <jose.souza@intel.com>
> Cc: Mika Kahola <mika.kahola@intel.com>
> Cc: Mark Pearson <markpearson@lenovo.com>
> Signed-off-by: Jouni Högander <jouni.hogander@intel.com>
> ---
>  include/drm/drm_print.h | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
> 
> diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h
> index 22fabdeed297..e339f47eeb6d 100644
> --- a/include/drm/drm_print.h
> +++ b/include/drm/drm_print.h
> @@ -476,6 +476,35 @@ void drm_dev_dbg(const struct device *dev, enum drm_debug_category category,
>  #define drm_dbg_drmres(drm, fmt, ...)					\
>  	drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_DRMRES, fmt, ##__VA_ARGS__)
>  
> +#define drm_dev_dbg_once(dev, cat, fmt, ...)			\
> +({								\
> +	static bool __print_once __read_mostly;			\
> +	if (!__print_once) {					\
> +		__print_once = true;				\
> +		drm_dev_dbg(dev, cat, fmt, ##__VA_ARGS__);	\
> +	}							\
> +})
> +
> +#define drm_dbg_once_core(drm, fmt, ...)					\
> +	drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_CORE, fmt, ##__VA_ARGS__)
> +#define drm_dbg_once(drm, fmt, ...)						\
> +	drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_DRIVER, fmt, ##__VA_ARGS__)
> +#define drm_dbg_once_kms(drm, fmt, ...)					\
> +	drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_KMS, fmt, ##__VA_ARGS__)
> +#define drm_dbg_once_prime(drm, fmt, ...)					\
> +	drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_PRIME, fmt, ##__VA_ARGS__)
> +#define drm_dbg_once_atomic(drm, fmt, ...)					\
> +	drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_ATOMIC, fmt, ##__VA_ARGS__)
> +#define drm_dbg_once_vbl(drm, fmt, ...)					\
> +	drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_VBL, fmt, ##__VA_ARGS__)
> +#define drm_dbg_once_state(drm, fmt, ...)					\
> +	drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_STATE, fmt, ##__VA_ARGS__)
> +#define drm_dbg_once_lease(drm, fmt, ...)					\
> +	drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_LEASE, fmt, ##__VA_ARGS__)
> +#define drm_dbg_once_dp(drm, fmt, ...)					\
> +	drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_DP, fmt, ##__VA_ARGS__)
> +#define drm_dbg_once_drmres(drm, fmt, ...)					\
> +	drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_DRMRES, fmt, ##__VA_ARGS__)
>  
>  /*
>   * printk based logging
diff mbox series

Patch

diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h
index 22fabdeed297..e339f47eeb6d 100644
--- a/include/drm/drm_print.h
+++ b/include/drm/drm_print.h
@@ -476,6 +476,35 @@  void drm_dev_dbg(const struct device *dev, enum drm_debug_category category,
 #define drm_dbg_drmres(drm, fmt, ...)					\
 	drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_DRMRES, fmt, ##__VA_ARGS__)
 
+#define drm_dev_dbg_once(dev, cat, fmt, ...)			\
+({								\
+	static bool __print_once __read_mostly;			\
+	if (!__print_once) {					\
+		__print_once = true;				\
+		drm_dev_dbg(dev, cat, fmt, ##__VA_ARGS__);	\
+	}							\
+})
+
+#define drm_dbg_once_core(drm, fmt, ...)					\
+	drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_CORE, fmt, ##__VA_ARGS__)
+#define drm_dbg_once(drm, fmt, ...)						\
+	drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_DRIVER, fmt, ##__VA_ARGS__)
+#define drm_dbg_once_kms(drm, fmt, ...)					\
+	drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_KMS, fmt, ##__VA_ARGS__)
+#define drm_dbg_once_prime(drm, fmt, ...)					\
+	drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_PRIME, fmt, ##__VA_ARGS__)
+#define drm_dbg_once_atomic(drm, fmt, ...)					\
+	drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_ATOMIC, fmt, ##__VA_ARGS__)
+#define drm_dbg_once_vbl(drm, fmt, ...)					\
+	drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_VBL, fmt, ##__VA_ARGS__)
+#define drm_dbg_once_state(drm, fmt, ...)					\
+	drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_STATE, fmt, ##__VA_ARGS__)
+#define drm_dbg_once_lease(drm, fmt, ...)					\
+	drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_LEASE, fmt, ##__VA_ARGS__)
+#define drm_dbg_once_dp(drm, fmt, ...)					\
+	drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_DP, fmt, ##__VA_ARGS__)
+#define drm_dbg_once_drmres(drm, fmt, ...)					\
+	drm_dev_dbg_once((drm) ? (drm)->dev : NULL, DRM_UT_DRMRES, fmt, ##__VA_ARGS__)
 
 /*
  * printk based logging