From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 47036606A32C for ; Fri, 4 Dec 2026 23:41:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=HdfT32cV Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CD6FE10ECFD; Fri, 4 Dec 2026 23:41:26 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by gabe.freedesktop.org (Postfix) with ESMTPS id E7C0610ECF0; Fri, 4 Dec 2026 23:41:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796427681; x=1827963681; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=WCMujbkyIDIsmZ0jGQxXHGDdL56RvYZiusoaM+PfWZ8=; b=HdfT32cVVRY6M57GZX3FUxFgoIzHHCYlc1HbylG94vKI2SEosoLUln7N 4UXLtMIPn0SaLLg2rt8K1o4FQrieRRq6XnvTx8XBW09yVRzxsVxBU1jkg kfvkdchvmslGJThgTTcLEtY5H4nxBPEsXcUVj4O9yQjWWvMoIcbcTw1F+ EvdRZ0wXCNoijrEZ+ZiCCwDnz5ONVmrrT5WoK6zNOfiP0kaCnzskWX6YL fZXxdsBnciiS0llMLe1/V9EllE3zvMKlm9vza3QCLJgqR7dGCCagBVpmQ 7RbkzD1xG4O6Tdf1hR7RKzPn1SW8YWQXV0yb4xWApgwmapiCqcuHnd4jt g==; X-CSE-ConnectionGUID: QnB2yqx1TZmSkEcQXXA0uw== X-CSE-MsgGUID: ZgEq1ZkjQNWYkXbg8/NQTw== X-IronPort-AV: E=McAfee;i="6800,10657,11986"; a="5436769" X-IronPort-AV: E=Sophos;i="6.29,79,1794902400"; d="scan'208";a="5436769" Received: from fmviesa012.fm.intel.com ([10.60.135.152]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2026 15:41:20 -0800 X-CSE-ConnectionGUID: igZIISzQSzC1Vj4zMygo7A== X-CSE-MsgGUID: 7xQZ1GNLRm+R1fegn0OQRA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.29,79,1794902400"; d="scan'208";a="15840600" Received: from amilburn-desk.amilburn-desk (HELO localhost) ([10.245.245.100]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2026 15:41:19 -0800 Date: Sat, 5 Dec 2026 01:41:15 +0200 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= To: =?utf-8?Q?Micha=C5=82?= Grzelak Cc: g@dev-417, intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org Subject: Re: [PATCH 4/9] drm/i915/fdi: Pass the full atomic state to ilk_check_fdi_lanes() Message-ID: References: <20261123225139.23087-1-ville.syrjala@linux.intel.com> <20261123225139.23087-5-ville.syrjala@linux.intel.com> <7qisebhjww4jknaafuchto4byxn3dr3xxpraihzgx2dcovxtex@oas4l2hevg5a> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <7qisebhjww4jknaafuchto4byxn3dr3xxpraihzgx2dcovxtex@oas4l2hevg5a> X-Patchwork-Hint: comment Organization: Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs Bertel Jungin Aukio 5, 02600 Espoo, Finland X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Intel-gfx" X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Thu, Dec 03, 2026 at 09:03:21PM +0100, Michał Grzelak wrote: > On Tue, Nov 24, 2026 at 12:51:34AM GMT, Ville Syrjala wrote: > > From: Ville Syrjälä > > > > ilk_check_fdi_lanes() is currently using the crtc_state_uapi.state > > footgun. Get rid of it by passing the full atomic state all the > > way from the top. > > > > The crtc_state->uapi.state pointer is only valid up to > > swap_state() after which it becomes NULL. Thus any code > > using it cannot be reused between atomic_check() and > > atomic_commit(). It's best if people just forget that > > the pointer even exists. Then they are forced to pass in > > the atomic state explicitly, thus guaranteeing its existence. > > > > And while there, let's also eliminate all the redundant function > > parameters. All we need is the overall state, the crtc, and the > > one output parameter. > > > > Signed-off-by: Ville Syrjälä > > --- > > drivers/gpu/drm/i915/display/intel_fdi.c | 22 +++++++++++----------- > > 1 file changed, 11 insertions(+), 11 deletions(-) > > > > diff --git a/drivers/gpu/drm/i915/display/intel_fdi.c b/drivers/gpu/drm/i915/display/intel_fdi.c > > index c170d3104e4c..2a823494f8b2 100644 > > --- a/drivers/gpu/drm/i915/display/intel_fdi.c > > +++ b/drivers/gpu/drm/i915/display/intel_fdi.c > > @@ -182,13 +182,16 @@ static int pipe_required_fdi_lanes(struct intel_crtc_state *crtc_state) > > return 0; > > } > > > > -static int ilk_check_fdi_lanes(struct intel_display *display, enum pipe pipe, > > - struct intel_crtc_state *pipe_config, > > +static int ilk_check_fdi_lanes(struct intel_atomic_state *state, > > + struct intel_crtc *crtc, > > enum pipe *pipe_to_reduce) > > { > > - struct drm_atomic_commit *state = pipe_config->uapi.state; > > - struct intel_crtc *other_crtc; > > + struct intel_display *display = to_intel_display(state); > > + const struct intel_crtc_state *pipe_config = > > + intel_atomic_get_new_crtc_state(state, crtc); > > struct intel_crtc_state *other_crtc_state; > > + struct intel_crtc *other_crtc; > > + enum pipe pipe = crtc->pipe; > > not part of this patch, but would it make sense to rename pipe_config > into like crtc_state? Especially that just beneath there are > other_crtc_state and other_crtc. Yeah, we should finish that rename, across the whole driver. Feel free to go at it. I think one patch per file should be a decent approach. > > also not part of this patch, but do you think it would harm to sprinkle > intel_fdi.c with a handful of newlines before return statements? I mean: > > diff --git a/drivers/gpu/drm/i915/display/intel_fdi.c b/drivers/gpu/drm/i915/display/intel_fdi.c > index eecd2ddb24a1c..4023ebb30a477 100644 > --- a/drivers/gpu/drm/i915/display/intel_fdi.c > +++ b/drivers/gpu/drm/i915/display/intel_fdi.c > @@ -202,6 +202,7 @@ static int ilk_check_fdi_lanes(struct intel_atomic_state *state, > drm_dbg_kms(display->drm, > "invalid fdi lane config on pipe %c: %i lanes\n", > pipe_name(pipe), pipe_config->fdi_lanes); > + > return -EINVAL; > } > > @@ -210,6 +211,7 @@ static int ilk_check_fdi_lanes(struct intel_atomic_state *state, > drm_dbg_kms(display->drm, > "only 2 lanes on haswell, required: %i lanes\n", > pipe_config->fdi_lanes); > + > return -EINVAL; > } else { > return 0; > @@ -237,14 +239,17 @@ static int ilk_check_fdi_lanes(struct intel_atomic_state *state, > drm_dbg_kms(display->drm, > "invalid shared fdi lane config on pipe %c: %i lanes\n", > pipe_name(pipe), pipe_config->fdi_lanes); > + > return -EINVAL; > } > + > return 0; > case PIPE_C: > if (pipe_config->fdi_lanes > 2) { > drm_dbg_kms(display->drm, > "only 2 lanes on pipe %c: required %i lanes\n", > pipe_name(pipe), pipe_config->fdi_lanes); > + > return -EINVAL; > } > > @@ -262,9 +267,11 @@ static int ilk_check_fdi_lanes(struct intel_atomic_state *state, > > return -EINVAL; > } > + > return 0; > default: > MISSING_CASE(pipe); > + > return 0; > } > } I suppose an empty line before return is the usual style. Since this code doesn't see a lot of churn it'd probably OK to do without too much risk of annoying conflicts. > > Apart from those side questions: > > Reviewed-by: Michał Grzelak > > BR, > Michał > > > > > *pipe_to_reduce = pipe; > > > > @@ -226,7 +229,7 @@ static int ilk_check_fdi_lanes(struct intel_display *display, enum pipe pipe, > > > > other_crtc = intel_crtc_for_pipe(display, PIPE_C); > > other_crtc_state = > > - intel_atomic_get_crtc_state(state, other_crtc); > > + intel_atomic_get_crtc_state(&state->base, other_crtc); > > if (IS_ERR(other_crtc_state)) > > return PTR_ERR(other_crtc_state); > > > > @@ -247,7 +250,7 @@ static int ilk_check_fdi_lanes(struct intel_display *display, enum pipe pipe, > > > > other_crtc = intel_crtc_for_pipe(display, PIPE_B); > > other_crtc_state = > > - intel_atomic_get_crtc_state(state, other_crtc); > > + intel_atomic_get_crtc_state(&state->base, other_crtc); > > if (IS_ERR(other_crtc_state)) > > return PTR_ERR(other_crtc_state); > > > > @@ -326,15 +329,12 @@ int ilk_fdi_compute_config(struct intel_crtc *crtc, > > > > static int intel_fdi_atomic_check_bw(struct intel_atomic_state *state, > > struct intel_crtc *crtc, > > - struct intel_crtc_state *pipe_config, > > struct intel_link_bw_limits *limits) > > { > > - struct intel_display *display = to_intel_display(crtc); > > enum pipe pipe_to_reduce; > > int ret; > > > > - ret = ilk_check_fdi_lanes(display, crtc->pipe, pipe_config, > > - &pipe_to_reduce); > > + ret = ilk_check_fdi_lanes(state, crtc, &pipe_to_reduce); > > if (ret != -EINVAL) > > return ret; > > > > @@ -377,7 +377,7 @@ int intel_fdi_atomic_check_link(struct intel_atomic_state *state, > > !crtc_state->hw.enable) > > continue; > > > > - ret = intel_fdi_atomic_check_bw(state, crtc, crtc_state, limits); > > + ret = intel_fdi_atomic_check_bw(state, crtc, limits); > > if (ret) > > return ret; > > } > > -- > > 2.56.1 > > -- Ville Syrjälä Intel