[Intel-gfx] [PATCH] drm/i915: Reduce ELD hex dumps a bit
Jani Nikula
jani.nikula at linux.intel.com
Wed Feb 15 14:17:21 UTC 2023
On Wed, 15 Feb 2023, Ville Syrjälä <ville.syrjala at linux.intel.com> wrote:
> On Wed, Feb 15, 2023 at 03:15:41PM +0200, Jani Nikula wrote:
>> On Wed, 15 Feb 2023, Ville Syrjala <ville.syrjala at linux.intel.com> wrote:
>> > From: Ville Syrjälä <ville.syrjala at linux.intel.com>
>> >
>> > Do the ELD hexdumps only up to the last differing byte.
>> > The rest is typically all zeroes anyway so not much point
>> > in dumping it.
>>
>> Arguably part of the reason for big dumps is that we use MAX_ELD_BYTES
>> for the size instead of drm_eld_size(). Granted, using drm_eld_size()
>> brings other complications, so maybe this is better anyway.
>>
>> > Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
>> > ---
>> > drivers/gpu/drm/i915/display/intel_display.c | 23 ++++++++++++++++++++
>> > 1 file changed, 23 insertions(+)
>> >
>> > diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
>> > index 3479125fbda6..d73aea9040e0 100644
>> > --- a/drivers/gpu/drm/i915/display/intel_display.c
>> > +++ b/drivers/gpu/drm/i915/display/intel_display.c
>> > @@ -5348,6 +5348,23 @@ pipe_config_dp_vsc_sdp_mismatch(struct drm_i915_private *dev_priv,
>> > }
>> > }
>> >
>> > +/*
>> > + * Like a revese memcmp(), but returns the
>> > + * position of the last differing byte.
>> > + */
>> > +static int
>> > +memcmp_pos_reverse(const u8 *a, const u8 *b, size_t len)
>> > +{
>> > + int i;
>> > +
>> > + for (i = len - 1; i >= 0; i--) {
>> > + if (a[i] != b[i])
>> > + return i;
>> > + }
>> > +
>> > + return len;
>> > +}
>>
>> Maybe make the function return "length of differing prefix" instead?
>>
>> If the buffers are identical, you now return len, and the caller dumps
>> len + 1, overflowing the buffer. This shouldn't happen, because we've
>> checked before that the buffers do differ, but it's a trap for anyone
>> who just picks this up for some other use case.
>>
>> The fix is simple, return "i + 1" if there's a difference, return 0 at
>> the end if there's not, and drop the + 1 from the caller side.
>>
>> Renaming the function is the hard part. ;)
>
> memcmp_len_reverse()?
memcmp_diff_len()?
>
>>
>>
>> BR,
>> Jani.
>>
>>
>> > +
>> > static void
>> > pipe_config_buffer_mismatch(struct drm_i915_private *dev_priv,
>> > bool fastset, const char *name,
>> > @@ -5357,6 +5374,9 @@ pipe_config_buffer_mismatch(struct drm_i915_private *dev_priv,
>> > if (!drm_debug_enabled(DRM_UT_KMS))
>> > return;
>> >
>> > + /* only dump up to the last difference */
>> > + len = memcmp_pos_reverse(a, b, len) + 1;
>> > +
>> > drm_dbg_kms(&dev_priv->drm,
>> > "fastset mismatch in %s buffer\n", name);
>> > print_hex_dump(KERN_DEBUG, "expected: ", DUMP_PREFIX_NONE,
>> > @@ -5364,6 +5384,9 @@ pipe_config_buffer_mismatch(struct drm_i915_private *dev_priv,
>> > print_hex_dump(KERN_DEBUG, "found: ", DUMP_PREFIX_NONE,
>> > 16, 0, b, len, false);
>> > } else {
>> > + /* only dump up to the last difference */
>> > + len = memcmp_pos_reverse(a, b, len) + 1;
>> > +
>> > drm_err(&dev_priv->drm, "mismatch in %s buffer\n", name);
>> > print_hex_dump(KERN_ERR, "expected: ", DUMP_PREFIX_NONE,
>> > 16, 0, a, len, false);
>>
>> --
>> Jani Nikula, Intel Open Source Graphics Center
--
Jani Nikula, Intel Open Source Graphics Center
More information about the Intel-gfx
mailing list