From: Jani Nikula <jani.nikula@linux.intel.com>
To: Suraj Kandpal <suraj.kandpal@intel.com>,
intel-xe@lists.freedesktop.org, intel-gfx@lists.freedesktop.org
Cc: arun.r.murthy@intel.com, ankit.k.nautiyal@intel.com,
Suraj Kandpal <suraj.kandpal@intel.com>
Subject: Re: [PATCH] drm/i915/ddi: Guard reg_val against a INVALID_TRANSCODER
Date: Thu, 04 Sep 2025 15:22:22 +0300 [thread overview]
Message-ID: <b534e914db169fd3c87a2769335d4a2d80807668@intel.com> (raw)
In-Reply-To: <20250904084510.951150-1-suraj.kandpal@intel.com>
On Thu, 04 Sep 2025, Suraj Kandpal <suraj.kandpal@intel.com> wrote:
> Currently we check if the encoder is INVALID or -1 and throw a
> WARN_ON but we still end up writing the temp value which will
> overflow and corrupt the whole programmed value.
>
> Fixes: 6671c367a9bea ("drm/i915/tgl: Select master transcoder for MST stream")
> Signed-off-by: Suraj Kandpal <suraj.kandpal@intel.com>
> ---
> drivers/gpu/drm/i915/display/intel_ddi.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_ddi.c b/drivers/gpu/drm/i915/display/intel_ddi.c
> index 4e4ea3a0ff83..0a58c07a8240 100644
> --- a/drivers/gpu/drm/i915/display/intel_ddi.c
> +++ b/drivers/gpu/drm/i915/display/intel_ddi.c
> @@ -596,9 +596,9 @@ intel_ddi_transcoder_func_reg_val_get(struct intel_encoder *encoder,
> enum transcoder master;
>
> master = crtc_state->mst_master_transcoder;
> - drm_WARN_ON(display->drm,
> - master == INVALID_TRANSCODER);
> - temp |= TRANS_DDI_MST_TRANSPORT_SELECT(master);
> + if (!drm_WARN_ON(display->drm,
> + master == INVALID_TRANSCODER))
> + temp |= TRANS_DDI_MST_TRANSPORT_SELECT(master);
I really *really* hate hiding happy day scenario paths within if
statements with stuff that should never happen.
Frankly I'd rather see
if (drm_WARN_ON(display->drm, master == INVALID_TRANSCODER))
master = TRANSCODER_A; /* bogus */
because it doesn't matter, we're hosed anyway, and this shouldn't happen
in the first place.
The code should be easy to read for the happy day scenario, and it
should be quick to mentally ignore checks like this. The !drm_WARN_ON()
is not it.
BR,
Jani.
> }
> } else {
> temp |= TRANS_DDI_MODE_SELECT_DP_SST;
--
Jani Nikula, Intel
next prev parent reply other threads:[~2025-09-04 12:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-04 8:45 [PATCH] drm/i915/ddi: Guard reg_val against a INVALID_TRANSCODER Suraj Kandpal
2025-09-04 8:52 ` ✓ CI.KUnit: success for " Patchwork
2025-09-04 9:26 ` ✓ Xe.CI.BAT: " Patchwork
2025-09-04 12:22 ` Jani Nikula [this message]
2025-09-04 20:16 ` ✗ Xe.CI.Full: 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=b534e914db169fd3c87a2769335d4a2d80807668@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=ankit.k.nautiyal@intel.com \
--cc=arun.r.murthy@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=suraj.kandpal@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