All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Maxime Ripard <mripard@kernel.org>
Cc: Jani Nikula <jani.nikula@linux.intel.com>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Tvrtko Ursulin <tursulin@ursulin.net>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
	Rodrigo Vivi <rodrigo.vivi@intel.com>,
	intel-xe@lists.freedesktop.org, intel-gfx@lists.freedesktop.org,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 6/6] drm/i915: Carry the current state over created states
Date: Tue, 24 Nov 2026 15:29:15 +0200	[thread overview]
Message-ID: <awWRK6MkcmPNAdUy@intel.com> (raw)
In-Reply-To: <20261124-drm-i915-conversion-state-readout-v1-6-b7132f72644d@kernel.org>

On Tue, Nov 24, 2026 at 11:59:56AM +0100, Maxime Ripard wrote:
> The states of an atomic commit usually come from
> intel_crtc_duplicate_state(), which carries the whole current state
> over. The upcoming DRM_MODE_ATOMIC_RESET flag of the atomic ioctl
> builds its commits out of states created through atomic_create_state()
> instead: those come pristine, with only the uapi properties userspace
> applied on top of the defaults.
> 
> A CRTC that stays enabled across such a commit, because userspace
> re-applies the same configuration, takes the nomodeset path of
> intel_atomic_check(): that path only updates the color management
> part of the hw state and relies on everything else having been carried
> over by the duplicate. Without the carry-over, the pipe mode, the
> transcoder, the DPLL, the scaler bookkeeping and all the other derived
> state would be zeroed on a CRTC the hardware keeps driving, and the
> scaler staging would fail to find a free scaler for the planes still
> using one.

I think you'll just want to force a full state recomputation for
a commit that resets everything.

> 
> Carry the current state over the created ones like a duplicate would,
> keeping the uapi state userspace just configured. A created state is
> told apart from a duplicated one through its invalid transcoder: the
> state of an active CRTC always holds a valid one, a duplicate carries
> it over, and a created state comes reset.
> 
> The planes get the same treatment for their scaler assignment: the
> scaler staging frees the scaler of a plane through the new state, and
> assigns it one when it still needs scaling, both of which need the
> assignment the current state holds. Carry the scaler id over when the
> current state has one and the new state doesn't.
> 
> Signed-off-by: Maxime Ripard <mripard@kernel.org>
> ---
>  drivers/gpu/drm/i915/display/intel_display.c | 114 +++++++++++++++++++++++++++
>  1 file changed, 114 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
> index 1172e48daf23..d645203104a7 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> @@ -6517,10 +6517,120 @@ static int intel_atomic_check_config_and_link(struct intel_atomic_state *state)
>  			break;
>  	}
>  
>  	return ret;
>  }
> +/*
> + * intel_atomic_carry_over_state - carry the current state over created states
> + * @state: atomic state
> + *
> + * The states of a commit usually come from intel_crtc_duplicate_state(),
> + * which carries the whole current state over. The upcoming
> + * DRM_MODE_ATOMIC_RESET flag of the atomic ioctl builds its commits out
> + * of states created through atomic_create_state() instead: those come
> + * pristine, with only the uapi properties userspace applied on top of
> + * the defaults.
> + *
> + * A CRTC that stays enabled across such a commit, because userspace
> + * re-applies the same configuration, takes the nomodeset path of
> + * intel_atomic_check(): that path only updates the color management
> + * part of the hw state and relies on everything else having been
> + * carried over by the duplicate. Take the current state over like a
> + * duplicate would, keeping the uapi state userspace just configured:
> + * without it, the pipe mode, the transcoder, the DPLL, the scaler
> + * bookkeeping and all the other derived state would be zeroed on a
> + * CRTC the hardware keeps driving.
> + *
> + * A created state is told apart from a duplicated one through its
> + * invalid transcoder: the state of an active CRTC always holds a valid
> + * one, a duplicate carries it over, and a created state comes reset.
> + *
> + * The planes need the same for their scaler assignment: the scaler
> + * staging frees the scaler of a plane through the new state, and
> + * assigns it one when it still needs scaling, both of which need the
> + * assignment the current state holds. A created plane state comes with
> + * none, and with the scaler still marked in use in the carried CRTC
> + * state, it could neither be freed nor replaced.
> + */
> +static int intel_atomic_carry_over_state(struct intel_atomic_state *state)
> +{
> +	struct intel_crtc_state *old_crtc_state, *new_crtc_state;
> +	struct intel_plane_state *old_plane_state, *new_plane_state;
> +	struct intel_crtc *crtc;
> +	struct intel_plane *plane;
> +	int i;
> +
> +	for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state,
> +					    new_crtc_state) {
> +		struct intel_crtc_state *carried_state;
> +
> +		if (new_crtc_state->cpu_transcoder != INVALID_TRANSCODER ||
> +		    !old_crtc_state->hw.active)
> +			continue;
> +
> +		carried_state = kmemdup(old_crtc_state, sizeof(*carried_state),
> +					GFP_KERNEL);
> +		if (!carried_state)
> +			return -ENOMEM;
> +
> +		/* Keep the uapi state userspace just configured. */
> +		carried_state->uapi = new_crtc_state->uapi;
> +
> +		intel_crtc_free_hw_state(new_crtc_state);
> +		if (new_crtc_state->dp_tunnel_ref.tunnel)
> +			drm_dp_tunnel_ref_put(&new_crtc_state->dp_tunnel_ref);
> +
> +		memcpy(new_crtc_state, carried_state, sizeof(*new_crtc_state));
> +		kfree(carried_state);
> +
> +		/* Take the references a duplicated state would carry. */
> +		if (new_crtc_state->hw.degamma_lut)
> +			drm_property_blob_get(new_crtc_state->hw.degamma_lut);
> +		if (new_crtc_state->hw.ctm)
> +			drm_property_blob_get(new_crtc_state->hw.ctm);
> +		if (new_crtc_state->hw.gamma_lut)
> +			drm_property_blob_get(new_crtc_state->hw.gamma_lut);
> +
> +		if (new_crtc_state->pre_csc_lut)
> +			drm_property_blob_get(new_crtc_state->pre_csc_lut);
> +		if (new_crtc_state->post_csc_lut)
> +			drm_property_blob_get(new_crtc_state->post_csc_lut);
> +
> +		if (new_crtc_state->dp_tunnel_ref.tunnel)
> +			drm_dp_tunnel_ref_get(new_crtc_state->dp_tunnel_ref.tunnel,
> +					      &new_crtc_state->dp_tunnel_ref);
> +
> +		/* Clear the transient flags, like a duplicate would. */
> +		new_crtc_state->update_pipe = false;
> +		new_crtc_state->update_m_n = false;
> +		new_crtc_state->update_lrr = false;
> +		new_crtc_state->disable_cxsr = false;
> +		new_crtc_state->update_wm_pre = false;
> +		new_crtc_state->update_wm_post = false;
> +		new_crtc_state->fifo_changed = false;
> +		new_crtc_state->preload_luts = false;
> +		new_crtc_state->wm.need_postvbl_update = false;
> +		new_crtc_state->do_async_flip = false;
> +		new_crtc_state->fb_bits = 0;
> +		new_crtc_state->update_planes = 0;
> +		new_crtc_state->dsb_color = NULL;
> +		new_crtc_state->dsb_commit = NULL;
> +		new_crtc_state->use_dsb = false;
> +		new_crtc_state->use_flipq = false;
> +	}
> +
> +	for_each_oldnew_intel_plane_in_state(state, plane, old_plane_state,
> +					      new_plane_state, i) {
> +		if (new_plane_state->scaler_id < 0 &&
> +		    old_plane_state->scaler_id >= 0)
> +			new_plane_state->scaler_id =
> +				old_plane_state->scaler_id;
> +	}
> +
> +	return 0;
> +}
> +
>  /**
>   * intel_atomic_check - validate state object
>   * @dev: drm device
>   * @_state: state to validate
>   */
> @@ -6534,10 +6644,14 @@ int intel_atomic_check(struct drm_device *dev,
>  	int ret;
>  
>  	if (!intel_display_driver_check_access(display))
>  		return -ENODEV;
>  
> +	ret = intel_atomic_carry_over_state(state);
> +	if (ret)
> +		goto fail;
> +
>  	for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state) {
>  		/*
>  		 * crtc's state no longer considered to be inherited
>  		 * after the first userspace/client initiated commit.
>  		 */
> 
> -- 
> 2.56.1

-- 
Ville Syrjälä
Intel

      parent reply	other threads:[~2026-11-24 13:29 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 10:59 [PATCH 0/6] drm/i915: Support DRM_MODE_ATOMIC_RESET Maxime Ripard
2026-11-24 10:59 ` [PATCH 1/6] drm/atomic-state-helper: Provide more STATE_CHECK_* variants Maxime Ripard
2026-11-24 10:59 ` [PATCH 2/6] drm/i915: Use the STATE_CHECK_* macros in the pipe config comparison Maxime Ripard
2026-11-24 11:23   ` Jani Nikula
2026-11-24 13:18     ` Maxime Ripard
2026-11-24 10:59 ` [PATCH 3/6] drm/i915: Implement CRTC atomic_create_state Maxime Ripard
2026-11-24 11:26   ` sashiko-bot
2026-11-24 10:59 ` [PATCH 4/6] drm/i915: Implement plane atomic_create_state Maxime Ripard
2026-11-24 11:19   ` sashiko-bot
2026-11-24 10:59 ` [PATCH 5/6] drm/i915: Implement connector atomic_create_state Maxime Ripard
2026-11-24 11:21   ` sashiko-bot
2026-11-24 10:59 ` [PATCH 6/6] drm/i915: Carry the current state over created states Maxime Ripard
2026-11-24 11:40   ` sashiko-bot
2026-11-24 13:29   ` Ville Syrjälä [this message]

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=awWRK6MkcmPNAdUy@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=airlied@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=joonas.lahtinen@linux.intel.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=rodrigo.vivi@intel.com \
    --cc=simona@ffwll.ch \
    --cc=tursulin@ursulin.net \
    --cc=tzimmermann@suse.de \
    /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.