Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
* [PATCH] drm/i915/display: Pass crtc->pipe to intel_pmdemand_update_port_clock()
@ 2026-11-19 17:06 Ian Rogers
  2026-11-20  9:13 ` Jani Nikula
  0 siblings, 1 reply; 2+ messages in thread
From: Ian Rogers @ 2026-11-19 17:06 UTC (permalink / raw)
  To: Jani Nikula, Rodrigo Vivi, Joonas Lahtinen, Tvrtko Ursulin,
	David Airlie, Simona Vetter
  Cc: intel-gfx, intel-xe, dri-devel, linux-kernel, llvm, Elkin Cruz,
	Ian Rogers

In intel_modeset_readout_hw_state(), 'pipe' is only populated inside the
earlier for_each_intel_encoder() loop. Later, inside
for_each_intel_crtc(), intel_pmdemand_update_port_clock() is called with
'pipe' instead of 'crtc->pipe'.

When the encoder list is empty (for example on headless SKUs or VBT
configurations with all display outputs disabled), 'pipe' is completely
uninitialized and indexes out-of-bounds into pmdemand_state->ddi_clocks[].
Even when encoders are present, every CRTC iteration overwrites the slot
for the last encoder's pipe rather than updating crtc->pipe.

Scope 'pipe' locally to for_each_intel_encoder() and pass crtc->pipe to
intel_pmdemand_update_port_clock().

Found via an x86_64 LLVM=1 (Clang 21.1.8) allyesconfig audit with
-Wconditional-uninitialized enabled; fix and changelog drafted with an AI
coding assistant. Build-tested for both i915 and xe under LLVM=1 W=1
(-Werror) and -Wconditional-uninitialized; not runtime-tested on Intel
Xe_LPD+ hardware.

Fixes: 4c4cc7ac207f ("drm/i915/mtl: Add support for PM DEMAND")
Signed-off-by: Ian Rogers <irogers@google.com>
---
 drivers/gpu/drm/i915/display/intel_modeset_setup.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_modeset_setup.c b/drivers/gpu/drm/i915/display/intel_modeset_setup.c
index 6aed88173770..e5d7c05e006a 100644
--- a/drivers/gpu/drm/i915/display/intel_modeset_setup.c
+++ b/drivers/gpu/drm/i915/display/intel_modeset_setup.c
@@ -695,7 +695,6 @@ static void intel_modeset_readout_hw_state(struct intel_display *display)
 {
 	struct intel_pmdemand_state *pmdemand_state =
 		to_intel_pmdemand_state(display->pmdemand.obj.state);
-	enum pipe pipe;
 	struct intel_crtc *crtc;
 	struct intel_encoder *encoder;
 	struct intel_connector *connector;
@@ -726,8 +725,7 @@ static void intel_modeset_readout_hw_state(struct intel_display *display)
 
 	for_each_intel_encoder(display->drm, encoder) {
 		struct intel_crtc_state *crtc_state = NULL;
-
-		pipe = 0;
+		enum pipe pipe = PIPE_A;
 
 		if (encoder->get_hw_state(encoder, &pipe)) {
 			crtc = intel_crtc_for_pipe(display, pipe);
@@ -869,7 +867,8 @@ static void intel_modeset_readout_hw_state(struct intel_display *display)
 		drm_dbg_kms(display->drm, "[CRTC:%d:%s] min_cdclk %d kHz\n",
 			    crtc->base.base.id, crtc->base.name, crtc_state->min_cdclk);
 
-		intel_pmdemand_update_port_clock(display, pmdemand_state, pipe,
+		intel_pmdemand_update_port_clock(display, pmdemand_state,
+						 crtc->pipe,
 						 crtc_state->port_clock);
 	}
 
-- 
2.56.1.708.g77570a6a1d-goog


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

* Re: [PATCH] drm/i915/display: Pass crtc->pipe to intel_pmdemand_update_port_clock()
  2026-11-19 17:06 [PATCH] drm/i915/display: Pass crtc->pipe to intel_pmdemand_update_port_clock() Ian Rogers
@ 2026-11-20  9:13 ` Jani Nikula
  0 siblings, 0 replies; 2+ messages in thread
From: Jani Nikula @ 2026-11-20  9:13 UTC (permalink / raw)
  To: Ian Rogers, Rodrigo Vivi, Joonas Lahtinen, Tvrtko Ursulin,
	David Airlie, Simona Vetter
  Cc: intel-gfx, intel-xe, dri-devel, linux-kernel, llvm, Elkin Cruz,
	Ian Rogers, Mika Kahola

On Thu, 19 Nov 2026, Ian Rogers <irogers@google.com> wrote:
> In intel_modeset_readout_hw_state(), 'pipe' is only populated inside the
> earlier for_each_intel_encoder() loop. Later, inside
> for_each_intel_crtc(), intel_pmdemand_update_port_clock() is called with
> 'pipe' instead of 'crtc->pipe'.
>
> When the encoder list is empty (for example on headless SKUs or VBT
> configurations with all display outputs disabled), 'pipe' is completely
> uninitialized and indexes out-of-bounds into pmdemand_state->ddi_clocks[].
> Even when encoders are present, every CRTC iteration overwrites the slot
> for the last encoder's pipe rather than updating crtc->pipe.
>
> Scope 'pipe' locally to for_each_intel_encoder() and pass crtc->pipe to
> intel_pmdemand_update_port_clock().
>
> Found via an x86_64 LLVM=1 (Clang 21.1.8) allyesconfig audit with
> -Wconditional-uninitialized enabled; fix and changelog drafted with an AI
> coding assistant. Build-tested for both i915 and xe under LLVM=1 W=1
> (-Werror) and -Wconditional-uninitialized; not runtime-tested on Intel
> Xe_LPD+ hardware.
>
> Fixes: 4c4cc7ac207f ("drm/i915/mtl: Add support for PM DEMAND")
> Signed-off-by: Ian Rogers <irogers@google.com>

Cc: <stable@vger.kernel.org> # v6.5+
Cc: Mika Kahola <mika.kahola@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>

> ---
>  drivers/gpu/drm/i915/display/intel_modeset_setup.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_modeset_setup.c b/drivers/gpu/drm/i915/display/intel_modeset_setup.c
> index 6aed88173770..e5d7c05e006a 100644
> --- a/drivers/gpu/drm/i915/display/intel_modeset_setup.c
> +++ b/drivers/gpu/drm/i915/display/intel_modeset_setup.c
> @@ -695,7 +695,6 @@ static void intel_modeset_readout_hw_state(struct intel_display *display)
>  {
>  	struct intel_pmdemand_state *pmdemand_state =
>  		to_intel_pmdemand_state(display->pmdemand.obj.state);
> -	enum pipe pipe;
>  	struct intel_crtc *crtc;
>  	struct intel_encoder *encoder;
>  	struct intel_connector *connector;
> @@ -726,8 +725,7 @@ static void intel_modeset_readout_hw_state(struct intel_display *display)
>  
>  	for_each_intel_encoder(display->drm, encoder) {
>  		struct intel_crtc_state *crtc_state = NULL;
> -
> -		pipe = 0;
> +		enum pipe pipe = PIPE_A;
>  
>  		if (encoder->get_hw_state(encoder, &pipe)) {
>  			crtc = intel_crtc_for_pipe(display, pipe);
> @@ -869,7 +867,8 @@ static void intel_modeset_readout_hw_state(struct intel_display *display)
>  		drm_dbg_kms(display->drm, "[CRTC:%d:%s] min_cdclk %d kHz\n",
>  			    crtc->base.base.id, crtc->base.name, crtc_state->min_cdclk);
>  
> -		intel_pmdemand_update_port_clock(display, pmdemand_state, pipe,
> +		intel_pmdemand_update_port_clock(display, pmdemand_state,
> +						 crtc->pipe,
>  						 crtc_state->port_clock);
>  	}

-- 
Jani Nikula, Intel

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

end of thread, other threads:[~2026-11-20  9:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 17:06 [PATCH] drm/i915/display: Pass crtc->pipe to intel_pmdemand_update_port_clock() Ian Rogers
2026-11-20  9:13 ` Jani Nikula

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