dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: Maxime Ripard <mripard@kernel.org>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org,
	Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Subject: Re: [PATCH v4 02/15] drm/atomic: Add new atomic_create_state callback to drm_private_obj
Date: Mon, 9 Feb 2026 09:29:19 +0100	[thread overview]
Message-ID: <3d62d7de-692b-43fc-9f58-ce79b8d0f4ee@suse.de> (raw)
In-Reply-To: <20260128-drm-private-obj-reset-v4-2-90891fa3d3b0@redhat.com>



Am 28.01.26 um 13:43 schrieb Maxime Ripard:
> The drm_private_obj initialization was inconsistent with the rest of the
> KMS objects. Indeed, it required to pass a preallocated state in
> drm_private_obj_init(), while all the others objects would have a reset
> callback that would be called later on to create the state.
>
> However, reset really is meant to reset the hardware and software state.
> That it creates an initial state is a side-effect that has been used in
> all objects but drm_private_obj. This is made more complex since some
> drm_private_obj, the DisplayPort ones in particular, need to be
> persistent across and suspend/resume cycle, and such a cycle would call
> drm_mode_config_reset().
>
> Thus, we need to add a new callback to allocate a pristine state for a
> given private object.
>
> This discussion has also came up during the atomic state readout
> discussion, so it might be introduced into the other objects later on.
>
> Until all drivers are converted to that new allocation pattern, we will
> only call it if the passed state is NULL. This will be removed
> eventually.
>
> Signed-off-by: Maxime Ripard <mripard@kernel.org>
> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>

> ---
>   drivers/gpu/drm/drm_atomic.c | 18 ++++++++++++++++--
>   include/drm/drm_atomic.h     | 13 +++++++++++++
>   2 files changed, 29 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index 4191a8333fc4ebdfc10f664c837a3f1693eff022..e3029c8f02e5a3698781117bcc80eff98407cf16 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -939,15 +939,29 @@ int drm_atomic_private_obj_init(struct drm_device *dev,
>   	memset(obj, 0, sizeof(*obj));
>   
>   	drm_modeset_lock_init(&obj->lock);
>   
>   	obj->dev = dev;
> -	obj->state = state;
>   	obj->funcs = funcs;
>   	list_add_tail(&obj->head, &dev->mode_config.privobj_list);
>   
> -	state->obj = obj;
> +	/*
> +	 * Not all users of drm_atomic_private_obj_init have been
> +	 * converted to using &drm_private_obj_funcs.atomic_create_state yet.
> +	 * For the time being, let's only call reset if the passed state is
> +	 * NULL. Otherwise, we will fallback to the previous behaviour.
> +	 */
> +	if (!state) {
> +		state = obj->funcs->atomic_create_state(obj);
> +		if (IS_ERR(state))
> +			return PTR_ERR(state);
> +
> +		obj->state = state;
> +	} else {
> +		obj->state = state;
> +		state->obj = obj;
> +	}
>   
>   	return 0;
>   }
>   EXPORT_SYMBOL(drm_atomic_private_obj_init);
>   
> diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
> index 712f5fb977bff8a15592a3949444d9ac306e6c54..0b1b32bcd2bda1b92299fd369ba7c23b1c2d3dfa 100644
> --- a/include/drm/drm_atomic.h
> +++ b/include/drm/drm_atomic.h
> @@ -259,10 +259,23 @@ struct drm_private_state;
>    * added to the atomic states is expected to have an implementation of these
>    * hooks and pass a pointer to its drm_private_state_funcs struct to
>    * drm_atomic_get_private_obj_state().
>    */
>   struct drm_private_state_funcs {
> +	/**
> +	 * @atomic_create_state:
> +	 *
> +	 * Allocates a pristine, initialized, state for the private
> +	 * object and returns it.
> +	 *
> +	 * RETURNS:
> +	 *
> +	 * A new, pristine, private state instance or an error pointer
> +	 * on failure.
> +	 */
> +	struct drm_private_state *(*atomic_create_state)(struct drm_private_obj *obj);
> +
>   	/**
>   	 * @atomic_duplicate_state:
>   	 *
>   	 * Duplicate the current state of the private object and return it. It
>   	 * is an error to call this before obj->state has been initialized.
>

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)



  reply	other threads:[~2026-02-09  8:29 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-28 12:43 [PATCH v4 00/15] drm/atomic: Allocate drm_private_state through a callback Maxime Ripard
2026-01-28 12:43 ` [PATCH v4 01/15] drm/atomic: Make drm_atomic_private_obj_init fallible Maxime Ripard
2026-02-09  8:29   ` Thomas Zimmermann
2026-02-10  9:11   ` (subset) " Maxime Ripard
2026-01-28 12:43 ` [PATCH v4 02/15] drm/atomic: Add new atomic_create_state callback to drm_private_obj Maxime Ripard
2026-02-09  8:29   ` Thomas Zimmermann [this message]
2026-02-10  9:11   ` (subset) " Maxime Ripard
2026-01-28 12:43 ` [PATCH v4 03/15] drm/atomic-helper: Add private_obj atomic_create_state helper Maxime Ripard
2026-02-09  8:29   ` Thomas Zimmermann
2026-02-10  9:11   ` (subset) " Maxime Ripard
2026-01-28 12:43 ` [PATCH v4 04/15] drm/bridge: Switch private_obj initialization to atomic_create_state Maxime Ripard
2026-02-09  8:30   ` Thomas Zimmermann
2026-02-10  9:11   ` (subset) " Maxime Ripard
2026-01-28 12:43 ` [PATCH v4 05/15] drm/dp_mst: " Maxime Ripard
2026-02-10  9:11   ` (subset) " Maxime Ripard
2026-01-28 12:43 ` [PATCH v4 06/15] drm/dp_tunnel: " Maxime Ripard
2026-02-10  9:11   ` (subset) " Maxime Ripard
2026-01-28 12:43 ` [PATCH v4 07/15] drm/amdgpu: " Maxime Ripard
2026-01-28 12:43 ` [PATCH v4 08/15] drm/arm: komeda: " Maxime Ripard
2026-02-10  9:11   ` (subset) " Maxime Ripard
2026-01-28 12:43 ` [PATCH v4 09/15] drm/ingenic: " Maxime Ripard
2026-02-10  9:11   ` (subset) " Maxime Ripard
2026-01-28 12:43 ` [PATCH v4 10/15] drm/msm: mdp5: " Maxime Ripard
2026-02-10  9:11   ` (subset) " Maxime Ripard
2026-01-28 12:43 ` [PATCH v4 11/15] drm/msm: dpu1: " Maxime Ripard
2026-02-10  9:11   ` (subset) " Maxime Ripard
2026-01-28 12:43 ` [PATCH v4 12/15] drm/omapdrm: " Maxime Ripard
2026-01-28 12:43 ` [PATCH v4 13/15] drm/tegra: " Maxime Ripard
2026-01-28 12:43 ` [PATCH v4 14/15] drm/vc4: " Maxime Ripard
2026-02-07 20:34   ` Maíra Canal
2026-02-10  9:13     ` Maxime Ripard
2026-02-10  9:11   ` (subset) " Maxime Ripard
2026-01-28 12:43 ` [PATCH v4 15/15] drm/atomic: Remove state argument to drm_atomic_private_obj_init Maxime Ripard
2026-02-07 20:37   ` Maíra Canal

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=3d62d7de-692b-43fc-9f58-ce79b8d0f4ee@suse.de \
    --to=tzimmermann@suse.de \
    --cc=airlied@gmail.com \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox