From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Jonathan Cavitt <jonathan.cavitt@intel.com>
Cc: intel-gfx@lists.freedesktop.org, saurabhg.gupta@intel.com,
alex.zuo@intel.com
Subject: Re: [PATCH] drm/i915/display: Check some INVALID_TRANSCODER cases
Date: Fri, 10 Apr 2026 00:11:33 +0300 [thread overview]
Message-ID: <adgWBSCegY8YvRxV@intel.com> (raw)
In-Reply-To: <20260409210001.64901-2-jonathan.cavitt@intel.com>
On Thu, Apr 09, 2026 at 09:00:02PM +0000, Jonathan Cavitt wrote:
> There are some cases in intel_ddi.c, such as in intel_ddi_is_audio_enabled
> and intel_ddi_compute_config_late, where we attempt to perform a BIT
> shift using a passed transcoder enum value. This value may be -1,
> INVALID_TRANSCODER, which can result in undefined behavior if this
> occurs.
>
> In the former case, we can simply return false if this is the transcoder
> passed (as audio is not enabled on an invalid transcoder).
>
> In the latter case, the likely expected behavior is to set the
> crtc_state->sync_mode_slaves_mask to zero, so just do that directly and
> avoid a risky bit shift.
>
> The likelihood of either case occurring during normal execution is
> unknown and possibly very low. Regardless, this covers a static analyis
> issue.
>
> Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
> ---
> drivers/gpu/drm/i915/display/intel_ddi.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_ddi.c b/drivers/gpu/drm/i915/display/intel_ddi.c
> index 178074316a2c..7abeb60779e5 100644
> --- a/drivers/gpu/drm/i915/display/intel_ddi.c
> +++ b/drivers/gpu/drm/i915/display/intel_ddi.c
> @@ -3875,7 +3875,8 @@ static void intel_ddi_set_idle_link_train(struct intel_dp *intel_dp,
> static bool intel_ddi_is_audio_enabled(struct intel_display *display,
> enum transcoder cpu_transcoder)
> {
> - if (cpu_transcoder == TRANSCODER_EDP)
> + if (cpu_transcoder == TRANSCODER_EDP ||
> + cpu_transcoder == INVALID_TRANSCODER)
> return false;
>
> if (!intel_display_power_is_enabled(display, POWER_DOMAIN_AUDIO_MMIO))
> @@ -4637,8 +4638,13 @@ static int intel_ddi_compute_config_late(struct intel_encoder *encoder,
>
> if (crtc_state->master_transcoder == crtc_state->cpu_transcoder) {
> crtc_state->master_transcoder = INVALID_TRANSCODER;
> - crtc_state->sync_mode_slaves_mask =
> - port_sync_transcoders & ~BIT(crtc_state->cpu_transcoder);
> + if (crtc_state->cpu_transcoder == INVALID_TRANSCODER ||
> + !port_sync_transcoders)
> + crtc_state->sync_mode_slaves_mask = 0;
> + else
> +
> + crtc_state->sync_mode_slaves_mask =
> + port_sync_transcoders & ~BIT(crtc_state->cpu_transcoder);
Making the code convoluted just to satisfy some dumb static
analysis tool is not great.
If we really need to care about this crap then I think it'd be better
to introduce some kind of intel_transcoder_mask() function that
explicitly deals with INVALID_TRANSCODER.
> }
>
> return 0;
> --
> 2.43.0
--
Ville Syrjälä
Intel
next prev parent reply other threads:[~2026-04-09 21:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-09 21:00 [PATCH] drm/i915/display: Check some INVALID_TRANSCODER cases Jonathan Cavitt
2026-04-09 21:11 ` Ville Syrjälä [this message]
2026-04-09 21:23 ` Cavitt, Jonathan
2026-04-09 22:45 ` ✗ i915.CI.BAT: failure for " 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=adgWBSCegY8YvRxV@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=alex.zuo@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jonathan.cavitt@intel.com \
--cc=saurabhg.gupta@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.