All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: "Michał Grzelak" <michal.grzelak@linux.intel.com>
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()
Date: Sat, 5 Dec 2026 01:41:15 +0200	[thread overview]
Message-ID: <axNPm2B3tLtA6Lpi@intel.com> (raw)
In-Reply-To: <7qisebhjww4jknaafuchto4byxn3dr3xxpraihzgx2dcovxtex@oas4l2hevg5a>

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ä <ville.syrjala@linux.intel.com>
> > 
> > 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ä <ville.syrjala@linux.intel.com>
> > ---
> >  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 <michal.grzelak@linux.intel.com>
> 
> 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

  reply	other threads:[~2026-12-04 23:41 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 22:51 [PATCH 0/9] drm/i915: Eliminate foo_state->state pointer usage Ville Syrjala
2026-11-23 22:51 ` [PATCH 1/9] drm/i915/ddi: Pass the atomic state to intel_ddi_port_sync_transcoders() Ville Syrjala
2026-12-03 20:00   ` Michał Grzelak
2026-11-23 22:51 ` [PATCH 2/9] drm/i915/mst: Pass the full atomic state to intel_dp_mtp_tu_compute_config() Ville Syrjala
2026-12-03 20:01   ` Michał Grzelak
2026-11-23 22:51 ` [PATCH 3/9] drm/i915/hdmi: Pass the full atomic state to intel_hdmi_bpc_possible() Ville Syrjala
2026-12-03 20:02   ` Michał Grzelak
2026-11-23 22:51 ` [PATCH 4/9] drm/i915/fdi: Pass the full atomic state to ilk_check_fdi_lanes() Ville Syrjala
2026-12-03 20:03   ` Michał Grzelak
2026-12-04 23:41     ` Ville Syrjälä [this message]
2026-11-23 22:51 ` [PATCH 5/9] drm/i915/hdcp: Pass the full atomic state to intel_hdcp_atomic_check() Ville Syrjala
2026-12-03 20:04   ` Michał Grzelak
2026-12-04 23:45     ` Ville Syrjälä
2026-11-23 22:51 ` [PATCH 6/9] drm/i915/global_state: Pass the full atomic state into intel_atomic_{lock, serialize}_global_state() Ville Syrjala
2026-12-03 20:05   ` Michał Grzelak
2026-11-23 22:51 ` [PATCH 7/9] drm/i915/global_state: Store the display in the global object and use it Ville Syrjala
2026-12-03 20:06   ` Michał Grzelak
2026-11-23 22:51 ` [PATCH 8/9] drm/i915/global_state: Remove the obj_state->state footgun Ville Syrjala
2026-12-03 20:06   ` Michał Grzelak
2026-11-23 22:51 ` [PATCH 9/9] drm/i915/sdvo: Add a FIXME about the connector_state->state footgun Ville Syrjala
2026-12-03 20:07   ` Michał Grzelak
2026-11-23 23:03 ` [PATCH 0/9] drm/i915: Eliminate foo_state->state pointer usage Ville Syrjälä
2026-12-03 20:07   ` Michał Grzelak
2026-11-23 23:04 ` ✗ CI.KUnit: failure for " Patchwork
2026-11-24  1:29 ` ✓ i915.CI.BAT: success " Patchwork
2026-11-24  9:39 ` ✗ i915.CI.Full: failure " Patchwork
2026-12-03 20:10 ` [PATCH 0/9] " Jani Nikula

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=axNPm2B3tLtA6Lpi@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=g@dev-417 \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=michal.grzelak@linux.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.