public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH v2] drm/i915/display: Check some INVALID_TRANSCODER cases
@ 2026-04-13 15:38 Jonathan Cavitt
  2026-04-13 20:48 ` ✓ i915.CI.BAT: success for drm/i915/display: Check some INVALID_TRANSCODER cases (rev2) Patchwork
  2026-04-14  1:33 ` ✗ i915.CI.Full: failure " Patchwork
  0 siblings, 2 replies; 3+ messages in thread
From: Jonathan Cavitt @ 2026-04-13 15:38 UTC (permalink / raw)
  To: intel-gfx; +Cc: saurabhg.gupta, alex.zuo, jonathan.cavitt, ville.syrjala

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.

v2: Rewrite the latter case to streamline it (Ville)

Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/display/intel_ddi.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/display/intel_ddi.c b/drivers/gpu/drm/i915/display/intel_ddi.c
index 178074316a2c..61d21fcdec95 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))
@@ -4636,6 +4637,10 @@ static int intel_ddi_compute_config_late(struct intel_encoder *encoder,
 		crtc_state->master_transcoder = ffs(port_sync_transcoders) - 1;
 
 	if (crtc_state->master_transcoder == crtc_state->cpu_transcoder) {
+		if (crtc_state->master_transcoder == INVALID_TRANSCODER) {
+			crtc_state->sync_mode_slaves_mask = 0;
+			return 0;
+		}
 		crtc_state->master_transcoder = INVALID_TRANSCODER;
 		crtc_state->sync_mode_slaves_mask =
 			port_sync_transcoders & ~BIT(crtc_state->cpu_transcoder);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-04-14  1:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-13 15:38 [PATCH v2] drm/i915/display: Check some INVALID_TRANSCODER cases Jonathan Cavitt
2026-04-13 20:48 ` ✓ i915.CI.BAT: success for drm/i915/display: Check some INVALID_TRANSCODER cases (rev2) Patchwork
2026-04-14  1:33 ` ✗ i915.CI.Full: failure " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox