intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Ville Syrjala <ville.syrjala@linux.intel.com>,
	intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 12/12] drm/i915: Create the printer only once in intel_pipe_config_compare()
Date: Thu, 29 Feb 2024 17:29:19 +0200	[thread overview]
Message-ID: <87h6hr70hc.fsf@intel.com> (raw)
In-Reply-To: <20240215164055.30585-13-ville.syrjala@linux.intel.com>

On Thu, 15 Feb 2024, Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Create the drm_printer at the start of intel_pipe_config_compare()
> and pass it on to all the mismatch() functions.

Nice!

Reviewed-by: Jani Nikula <jani.nikula@intel.com>


>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_display.c | 101 +++++++++----------
>  1 file changed, 46 insertions(+), 55 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
> index 26580d4aef2d..69c9693dcc8d 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> @@ -4787,11 +4787,11 @@ intel_compare_buffer(const u8 *a, const u8 *b, size_t len)
>  	return memcmp(a, b, len) == 0;
>  }
>  
> -static void __printf(4, 5)
> -pipe_config_mismatch(bool fastset, const struct intel_crtc *crtc,
> +static void __printf(5, 6)
> +pipe_config_mismatch(struct drm_printer *p, bool fastset,
> +		     const struct intel_crtc *crtc,
>  		     const char *name, const char *format, ...)
>  {
> -	struct drm_i915_private *i915 = to_i915(crtc->base.dev);
>  	struct va_format vaf;
>  	va_list args;
>  
> @@ -4800,65 +4800,55 @@ pipe_config_mismatch(bool fastset, const struct intel_crtc *crtc,
>  	vaf.va = &args;
>  
>  	if (fastset)
> -		drm_dbg_kms(&i915->drm,
> -			    "[CRTC:%d:%s] fastset requirement not met in %s %pV\n",
> -			    crtc->base.base.id, crtc->base.name, name, &vaf);
> +		drm_printf(p, "[CRTC:%d:%s] fastset requirement not met in %s %pV\n",
> +			   crtc->base.base.id, crtc->base.name, name, &vaf);
>  	else
> -		drm_err(&i915->drm, "[CRTC:%d:%s] mismatch in %s %pV\n",
> -			crtc->base.base.id, crtc->base.name, name, &vaf);
> +		drm_printf(p, "[CRTC:%d:%s] mismatch in %s %pV\n",
> +			   crtc->base.base.id, crtc->base.name, name, &vaf);
>  
>  	va_end(args);
>  }
>  
>  static void
> -pipe_config_infoframe_mismatch(bool fastset, const struct intel_crtc *crtc,
> +pipe_config_infoframe_mismatch(struct drm_printer *p, bool fastset,
> +			       const struct intel_crtc *crtc,
>  			       const char *name,
>  			       const union hdmi_infoframe *a,
>  			       const union hdmi_infoframe *b)
>  {
>  	struct drm_i915_private *i915 = to_i915(crtc->base.dev);
> -	struct drm_printer p;
>  	const char *loglevel;
>  
>  	if (fastset) {
>  		if (!drm_debug_enabled(DRM_UT_KMS))
>  			return;
>  
> -		p = drm_dbg_printer(&i915->drm, DRM_UT_KMS, NULL);
>  		loglevel = KERN_DEBUG;
>  	} else {
> -		p = drm_err_printer(&i915->drm, NULL);
>  		loglevel = KERN_ERR;
>  	}
>  
> -	pipe_config_mismatch(fastset, crtc, name, "infoframe");
> +	pipe_config_mismatch(p, fastset, crtc, name, "infoframe");
>  
> -	drm_printf(&p, "expected:\n");
> +	drm_printf(p, "expected:\n");
>  	hdmi_infoframe_log(loglevel, i915->drm.dev, a);
> -	drm_printf(&p, "found:\n");
> +	drm_printf(p, "found:\n");
>  	hdmi_infoframe_log(loglevel, i915->drm.dev, b);
>  }
>  
>  static void
> -pipe_config_dp_vsc_sdp_mismatch(bool fastset, const struct intel_crtc *crtc,
> +pipe_config_dp_vsc_sdp_mismatch(struct drm_printer *p, bool fastset,
> +				const struct intel_crtc *crtc,
>  				const char *name,
>  				const struct drm_dp_vsc_sdp *a,
>  				const struct drm_dp_vsc_sdp *b)
>  {
> -	struct drm_i915_private *i915 = to_i915(crtc->base.dev);
> -	struct drm_printer p;
> +	pipe_config_mismatch(p, fastset, crtc, name, "dp sdp");
>  
> -	if (fastset)
> -		p = drm_dbg_printer(&i915->drm, DRM_UT_KMS, NULL);
> -	else
> -		p = drm_err_printer(&i915->drm, NULL);
> -
> -	pipe_config_mismatch(fastset, crtc, name, "dp sdp");
> -
> -	drm_printf(&p, "expected:\n");
> -	drm_dp_vsc_sdp_log(&p, a);
> -	drm_printf(&p, "found:\n");
> -	drm_dp_vsc_sdp_log(&p, b);
> +	drm_printf(p, "expected:\n");
> +	drm_dp_vsc_sdp_log(p, a);
> +	drm_printf(p, "found:\n");
> +	drm_dp_vsc_sdp_log(p, b);
>  }
>  
>  /* Returns the length up to and including the last differing byte */
> @@ -4876,7 +4866,8 @@ memcmp_diff_len(const u8 *a, const u8 *b, size_t len)
>  }
>  
>  static void
> -pipe_config_buffer_mismatch(bool fastset, const struct intel_crtc *crtc,
> +pipe_config_buffer_mismatch(struct drm_printer *p, bool fastset,
> +			    const struct intel_crtc *crtc,
>  			    const char *name,
>  			    const u8 *a, const u8 *b, size_t len)
>  {
> @@ -4891,7 +4882,7 @@ pipe_config_buffer_mismatch(bool fastset, const struct intel_crtc *crtc,
>  		loglevel = KERN_ERR;
>  	}
>  
> -	pipe_config_mismatch(fastset, crtc, name, "buffer");
> +	pipe_config_mismatch(p, fastset, crtc, name, "buffer");
>  
>  	/* only dump up to the last difference */
>  	len = memcmp_diff_len(a, b, len);
> @@ -4903,26 +4894,20 @@ pipe_config_buffer_mismatch(bool fastset, const struct intel_crtc *crtc,
>  }
>  
>  static void
> -pipe_config_pll_mismatch(bool fastset,
> +pipe_config_pll_mismatch(struct drm_printer *p, bool fastset,
>  			 const struct intel_crtc *crtc,
>  			 const char *name,
>  			 const struct intel_dpll_hw_state *a,
>  			 const struct intel_dpll_hw_state *b)
>  {
>  	struct drm_i915_private *i915 = to_i915(crtc->base.dev);
> -	struct drm_printer p;
>  
> -	if (fastset)
> -		p = drm_dbg_printer(&i915->drm, DRM_UT_KMS, NULL);
> -	else
> -		p = drm_err_printer(&i915->drm, NULL);
> +	pipe_config_mismatch(p, fastset, crtc, name, " "); /* stupid -Werror=format-zero-length */
>  
> -	pipe_config_mismatch(fastset, crtc, name, " "); /* stupid -Werror=format-zero-length */
> -
> -	drm_dbg_kms(&i915->drm, "expected:\n");
> -	intel_dpll_dump_hw_state(i915, &p, a);
> -	drm_dbg_kms(&i915->drm, "found:\n");
> -	intel_dpll_dump_hw_state(i915, &p, b);
> +	drm_printf(p, "expected:\n");
> +	intel_dpll_dump_hw_state(i915, p, a);
> +	drm_printf(p, "found:\n");
> +	intel_dpll_dump_hw_state(i915, p, b);
>  }
>  
>  bool
> @@ -4932,13 +4917,19 @@ intel_pipe_config_compare(const struct intel_crtc_state *current_config,
>  {
>  	struct drm_i915_private *dev_priv = to_i915(current_config->uapi.crtc->dev);
>  	struct intel_crtc *crtc = to_intel_crtc(pipe_config->uapi.crtc);
> +	struct drm_printer p;
>  	bool ret = true;
>  
> +	if (fastset)
> +		p = drm_dbg_printer(&dev_priv->drm, DRM_UT_KMS, NULL);
> +	else
> +		p = drm_err_printer(&dev_priv->drm, NULL);
> +
>  #define PIPE_CONF_CHECK_X(name) do { \
>  	if (current_config->name != pipe_config->name) { \
>  		BUILD_BUG_ON_MSG(__same_type(current_config->name, bool), \
>  				 __stringify(name) " is bool");	\
> -		pipe_config_mismatch(fastset, crtc, __stringify(name), \
> +		pipe_config_mismatch(&p, fastset, crtc, __stringify(name), \
>  				     "(expected 0x%08x, found 0x%08x)", \
>  				     current_config->name, \
>  				     pipe_config->name); \
> @@ -4950,7 +4941,7 @@ intel_pipe_config_compare(const struct intel_crtc_state *current_config,
>  	if ((current_config->name & (mask)) != (pipe_config->name & (mask))) { \
>  		BUILD_BUG_ON_MSG(__same_type(current_config->name, bool), \
>  				 __stringify(name) " is bool");	\
> -		pipe_config_mismatch(fastset, crtc, __stringify(name), \
> +		pipe_config_mismatch(&p, fastset, crtc, __stringify(name), \
>  				     "(expected 0x%08x, found 0x%08x)", \
>  				     current_config->name & (mask), \
>  				     pipe_config->name & (mask)); \
> @@ -4962,7 +4953,7 @@ intel_pipe_config_compare(const struct intel_crtc_state *current_config,
>  	if (current_config->name != pipe_config->name) { \
>  		BUILD_BUG_ON_MSG(__same_type(current_config->name, bool), \
>  				 __stringify(name) " is bool");	\
> -		pipe_config_mismatch(fastset, crtc, __stringify(name), \
> +		pipe_config_mismatch(&p, fastset, crtc, __stringify(name), \
>  				     "(expected %i, found %i)", \
>  				     current_config->name, \
>  				     pipe_config->name); \
> @@ -4974,7 +4965,7 @@ intel_pipe_config_compare(const struct intel_crtc_state *current_config,
>  	if (current_config->name != pipe_config->name) { \
>  		BUILD_BUG_ON_MSG(!__same_type(current_config->name, bool), \
>  				 __stringify(name) " is not bool");	\
> -		pipe_config_mismatch(fastset, crtc,  __stringify(name), \
> +		pipe_config_mismatch(&p, fastset, crtc,  __stringify(name), \
>  				     "(expected %s, found %s)", \
>  				     str_yes_no(current_config->name), \
>  				     str_yes_no(pipe_config->name)); \
> @@ -4984,7 +4975,7 @@ intel_pipe_config_compare(const struct intel_crtc_state *current_config,
>  
>  #define PIPE_CONF_CHECK_P(name) do { \
>  	if (current_config->name != pipe_config->name) { \
> -		pipe_config_mismatch(fastset, crtc, __stringify(name), \
> +		pipe_config_mismatch(&p, fastset, crtc, __stringify(name), \
>  				     "(expected %p, found %p)", \
>  				     current_config->name, \
>  				     pipe_config->name); \
> @@ -4995,7 +4986,7 @@ intel_pipe_config_compare(const struct intel_crtc_state *current_config,
>  #define PIPE_CONF_CHECK_M_N(name) do { \
>  	if (!intel_compare_link_m_n(&current_config->name, \
>  				    &pipe_config->name)) { \
> -		pipe_config_mismatch(fastset, crtc, __stringify(name), \
> +		pipe_config_mismatch(&p, fastset, crtc, __stringify(name), \
>  				     "(expected tu %i data %i/%i link %i/%i, " \
>  				     "found tu %i, data %i/%i link %i/%i)", \
>  				     current_config->name.tu, \
> @@ -5015,7 +5006,7 @@ intel_pipe_config_compare(const struct intel_crtc_state *current_config,
>  #define PIPE_CONF_CHECK_PLL(name) do { \
>  	if (!intel_dpll_compare_hw_state(dev_priv, &current_config->name, \
>  					 &pipe_config->name)) { \
> -		pipe_config_pll_mismatch(fastset, crtc, __stringify(name), \
> +		pipe_config_pll_mismatch(&p, fastset, crtc, __stringify(name), \
>  					 &current_config->name, \
>  					 &pipe_config->name); \
>  		ret = false; \
> @@ -5048,7 +5039,7 @@ intel_pipe_config_compare(const struct intel_crtc_state *current_config,
>  
>  #define PIPE_CONF_CHECK_FLAGS(name, mask) do { \
>  	if ((current_config->name ^ pipe_config->name) & (mask)) { \
> -		pipe_config_mismatch(fastset, crtc, __stringify(name), \
> +		pipe_config_mismatch(&p, fastset, crtc, __stringify(name), \
>  				     "(%x) (expected %i, found %i)", \
>  				     (mask), \
>  				     current_config->name & (mask), \
> @@ -5060,7 +5051,7 @@ intel_pipe_config_compare(const struct intel_crtc_state *current_config,
>  #define PIPE_CONF_CHECK_INFOFRAME(name) do { \
>  	if (!intel_compare_infoframe(&current_config->infoframes.name, \
>  				     &pipe_config->infoframes.name)) { \
> -		pipe_config_infoframe_mismatch(fastset, crtc, __stringify(name), \
> +		pipe_config_infoframe_mismatch(&p, fastset, crtc, __stringify(name), \
>  					       &current_config->infoframes.name, \
>  					       &pipe_config->infoframes.name); \
>  		ret = false; \
> @@ -5070,7 +5061,7 @@ intel_pipe_config_compare(const struct intel_crtc_state *current_config,
>  #define PIPE_CONF_CHECK_DP_VSC_SDP(name) do { \
>  	if (!intel_compare_dp_vsc_sdp(&current_config->infoframes.name, \
>  				      &pipe_config->infoframes.name)) { \
> -		pipe_config_dp_vsc_sdp_mismatch(fastset, crtc, __stringify(name), \
> +		pipe_config_dp_vsc_sdp_mismatch(&p, fastset, crtc, __stringify(name), \
>  						&current_config->infoframes.name, \
>  						&pipe_config->infoframes.name); \
>  		ret = false; \
> @@ -5081,7 +5072,7 @@ intel_pipe_config_compare(const struct intel_crtc_state *current_config,
>  	BUILD_BUG_ON(sizeof(current_config->name) != (len)); \
>  	BUILD_BUG_ON(sizeof(pipe_config->name) != (len)); \
>  	if (!intel_compare_buffer(current_config->name, pipe_config->name, (len))) { \
> -		pipe_config_buffer_mismatch(fastset, crtc, __stringify(name), \
> +		pipe_config_buffer_mismatch(&p, fastset, crtc, __stringify(name), \
>  					    current_config->name, \
>  					    pipe_config->name, \
>  					    (len)); \
> @@ -5094,7 +5085,7 @@ intel_pipe_config_compare(const struct intel_crtc_state *current_config,
>  	    !intel_color_lut_equal(current_config, \
>  				   current_config->lut, pipe_config->lut, \
>  				   is_pre_csc_lut)) {	\
> -		pipe_config_mismatch(fastset, crtc, __stringify(lut), \
> +		pipe_config_mismatch(&p, fastset, crtc, __stringify(lut), \
>  				     "hw_state doesn't match sw_state"); \
>  		ret = false; \
>  	} \

-- 
Jani Nikula, Intel

  reply	other threads:[~2024-02-29 15:29 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-15 16:40 [PATCH 00/12] drm/i915: Use drm_printer more Ville Syrjala
2024-02-15 16:40 ` [PATCH 01/12] drm/i915: Indicate which pipe failed the fastset check overall Ville Syrjala
2024-02-22 21:46   ` Rodrigo Vivi
2024-02-23 19:47     ` Ville Syrjälä
2024-02-26 14:57       ` Jani Nikula
2024-02-26 15:10         ` Andy Shevchenko
2024-02-26 15:35           ` Jani Nikula
2024-02-26 16:30             ` Andy Shevchenko
2024-02-26 16:35             ` Ville Syrjälä
2024-02-27  9:38         ` Rasmus Villemoes
2024-02-27 18:32           ` Ville Syrjälä
2024-02-28  8:32             ` Rasmus Villemoes
2024-02-28  9:55               ` Petr Mladek
2024-02-15 16:40 ` [PATCH 02/12] drm/i915: Include CRTC info in infoframe mismatch prints Ville Syrjala
2024-02-22 21:47   ` Rodrigo Vivi
2024-02-23 19:50     ` Ville Syrjälä
2024-02-15 16:40 ` [PATCH 03/12] drm/i915: Include CRTC info in VSC SDP " Ville Syrjala
2024-02-22 21:48   ` Rodrigo Vivi
2024-02-15 16:40 ` [PATCH 04/12] drm/i915: Convert pipe_config_infoframe_mismatch() to drm_printer Ville Syrjala
2024-02-22 21:50   ` Rodrigo Vivi
2024-02-15 16:40 ` [PATCH 05/12] drm/i915: Convert pipe_config_buffer_mismatch() " Ville Syrjala
2024-02-22 21:51   ` Rodrigo Vivi
2024-02-15 16:40 ` [PATCH 06/12] drm/i915: Convert intel_dpll_dump_hw_state() " Ville Syrjala
2024-02-22 21:54   ` Rodrigo Vivi
2024-02-23 19:57     ` Ville Syrjälä
2024-02-29 18:40   ` [PATCH v2 " Ville Syrjala
2024-02-29 19:43     ` Jani Nikula
2024-02-15 16:40 ` [PATCH 07/12] drm/i915: Use drm_printer more extensively in intel_crtc_state_dump() Ville Syrjala
2024-02-22 21:57   ` Rodrigo Vivi
2024-02-23 19:59     ` Ville Syrjälä
2024-02-15 16:40 ` [PATCH 08/12] drm/i915: Convert the remaining state dump to drm_printer Ville Syrjala
2024-03-05  9:12   ` Jani Nikula
2024-02-15 16:40 ` [PATCH 09/12] drm/i915: Skip intel_crtc_state_dump() if debugs aren't enabled Ville Syrjala
2024-02-29 15:20   ` Jani Nikula
2024-02-29 15:21     ` Jani Nikula
2024-02-15 16:40 ` [PATCH 10/12] drm/i915: Relocate pipe_config_mismatch() Ville Syrjala
2024-02-29 15:21   ` Jani Nikula
2024-02-15 16:40 ` [PATCH 11/12] drm/i915: Reuse pipe_config_mismatch() more Ville Syrjala
2024-02-29 15:28   ` Jani Nikula
2024-02-29 18:42   ` [PATCH v2 " Ville Syrjala
2024-02-15 16:40 ` [PATCH 12/12] drm/i915: Create the printer only once in intel_pipe_config_compare() Ville Syrjala
2024-02-29 15:29   ` Jani Nikula [this message]
2024-02-29 18:42   ` [PATCH v2 " Ville Syrjala
2024-02-16 18:03 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Use drm_printer more Patchwork
2024-02-16 18:03 ` ✗ Fi.CI.SPARSE: " Patchwork
2024-02-16 18:15 ` ✓ Fi.CI.BAT: success " Patchwork
2024-02-17  7:24 ` ✗ Fi.CI.IGT: failure " Patchwork
2024-02-29 12:08 ` [PATCH 00/12] " Jani Nikula
2024-02-29 23:02 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Use drm_printer more (rev4) Patchwork
2024-02-29 23:02 ` ✗ Fi.CI.SPARSE: " Patchwork
2024-02-29 23:19 ` ✗ Fi.CI.BAT: failure " Patchwork
2024-03-05 21:28 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Use drm_printer more (rev5) Patchwork
2024-03-05 21:28 ` ✗ Fi.CI.SPARSE: " Patchwork
2024-03-05 21:46 ` ✗ Fi.CI.BAT: failure " Patchwork
2024-03-06 12:07 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Use drm_printer more (rev6) Patchwork
2024-03-06 12:07 ` ✗ Fi.CI.SPARSE: " Patchwork
2024-03-06 12:13 ` ✗ Fi.CI.BAT: failure " Patchwork
2024-03-08  8:37 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Use drm_printer more (rev7) Patchwork
2024-03-08  8:37 ` ✗ Fi.CI.SPARSE: " Patchwork
2024-03-08  8:52 ` ✗ Fi.CI.BAT: failure " Patchwork
2024-03-13 19:41 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Use drm_printer more (rev8) Patchwork
2024-03-13 19:41 ` ✗ Fi.CI.SPARSE: " Patchwork
2024-03-13 19:54 ` ✓ Fi.CI.BAT: success " Patchwork
2024-03-14  2:49 ` ✗ Fi.CI.IGT: failure " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87h6hr70hc.fsf@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=ville.syrjala@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).