Re: [PATCH] drm/i915/display: Pass crtc->pipe to intel_pmdemand_update_port_clock()

From: Jani Nikula

Date: Fri Nov 20 2026 - 04:14:02 EST


On Thu, 19 Nov 2026, Ian Rogers <irogers@xxxxxxxxxx> 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@xxxxxxxxxx>

Cc: <stable@xxxxxxxxxxxxxxx> # v6.5+
Cc: Mika Kahola <mika.kahola@xxxxxxxxx>
Reviewed-by: Jani Nikula <jani.nikula@xxxxxxxxx>

> ---
> 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