From: Jonathan Cavitt <jonathan.cavitt@intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: saurabhg.gupta@intel.com, alex.zuo@intel.com, jonathan.cavitt@intel.com
Subject: [PATCH] drm/i915/display: Check some INVALID_TRANSCODER cases
Date: Thu, 9 Apr 2026 21:00:02 +0000 [thread overview]
Message-ID: <20260409210001.64901-2-jonathan.cavitt@intel.com> (raw)
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);
}
return 0;
--
2.43.0
next reply other threads:[~2026-04-09 21:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-09 21:00 Jonathan Cavitt [this message]
2026-04-09 21:11 ` [PATCH] drm/i915/display: Check some INVALID_TRANSCODER cases Ville Syrjälä
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=20260409210001.64901-2-jonathan.cavitt@intel.com \
--to=jonathan.cavitt@intel.com \
--cc=alex.zuo@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox