mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Maxime Ripard <mripard@kernel.org>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	Andrzej Hajda <andrzej.hajda@intel.com>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Robert Foss <rfoss@kernel.org>, Jonas Karlman <jonas@kwiboo.se>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Jyri Sarha <jyri.sarha@iki.fi>,
	Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>,
	Devarsh Thakkar <devarsht@ti.com>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 01/29] drm/atomic: Document atomic state lifetime
Date: Tue, 2 Sep 2025 20:59:12 +0200	[thread overview]
Message-ID: <20250902185912.GP13448@pendragon.ideasonboard.com> (raw)
In-Reply-To: <d807d181-6b14-4711-b297-72dcd49b4937@suse.de>

On Tue, Sep 02, 2025 at 03:08:12PM +0200, Thomas Zimmermann wrote:
> Am 02.09.25 um 10:32 schrieb Maxime Ripard:
> > How drm_atomic_state structures and the various entity structures are

"entity" isn't commonly used in this sense in DRM/KMS. "object" is the
best term I can think so, even if some DRM objects (in the
drm_mode_object sense) are out of scope in this context. Same below
where you use "entity".

> > allocated and freed isn't really trivial, so let's document it.
> 
> Thanks for doing this.
> 
> > Signed-off-by: Maxime Ripard <mripard@kernel.org>
> > ---
> >   Documentation/gpu/drm-kms.rst |  6 ++++++
> >   drivers/gpu/drm/drm_atomic.c  | 45 +++++++++++++++++++++++++++++++++++++++++++
> >   2 files changed, 51 insertions(+)
> >
> > diff --git a/Documentation/gpu/drm-kms.rst b/Documentation/gpu/drm-kms.rst
> > index abfe220764e1edc758a6bc6fb5ff9c8e1c7749ff..dc0f61a3d29e752889077d855a4bea381f2e2c18 100644
> > --- a/Documentation/gpu/drm-kms.rst
> > +++ b/Documentation/gpu/drm-kms.rst
> > @@ -280,10 +280,16 @@ structure, ordering of committing state changes to hardware is sequenced using
> >   :c:type:`struct drm_crtc_commit <drm_crtc_commit>`.
> >   
> >   Read on in this chapter, and also in :ref:`drm_atomic_helper` for more detailed
> >   coverage of specific topics.
> >   
> > +Atomic State Lifetime
> > +---------------------
> > +
> > +.. kernel-doc:: drivers/gpu/drm/drm_atomic.c
> > +   :doc: state lifetime
> > +
> >   Handling Driver Private State
> >   -----------------------------
> >   
> >   .. kernel-doc:: drivers/gpu/drm/drm_atomic.c
> >      :doc: handling driver private state
> > diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> > index cd15cf52f0c9144711da5879da57884674aea9e4..b356d26faad4acaa25c1fe6f9bd5043b6364ce87 100644
> > --- a/drivers/gpu/drm/drm_atomic.c
> > +++ b/drivers/gpu/drm/drm_atomic.c
> > @@ -44,10 +44,55 @@
> >   #include <drm/drm_writeback.h>
> >   
> >   #include "drm_crtc_internal.h"
> >   #include "drm_internal.h"
> >   
> > +/**
> > + * DOC: state lifetime
> > + *
> > + * &struct drm_atomic_state represents an update to video pipeline state.
> > + *
> > + * Its lifetime is:

This indicates you'll talk about the lifetime of drm_atomic_state
itself, while the text below also covers the lifetime of the state of
the individual objects. This is a bit confusing. One of the important
aspects that I think you should document is that drm_atomic_state is a
transient object that holds a state update (I once proposed renaming it
to drm_atomic_commit, and to my surprise the idea wasn't rejected right
away, but it would cause lots of churn) in the form of pointers to
individual objects' states, and only exists for the duration of an
atomic commit operation, while object states have a different lifetime.

> > + *
> > + * - at reset time, the entity reset implementation will allocate a
> > + *   new, default, state and will store it in the entity state pointer.

Strictly speaking, this isn't related to the drm_atomic_state lifetime.

> Can you somehow mention drm_mode_config_reset() here? 'Reset time' might 
> be too abstract.
> 
> > + *
> > + * - whenever a new update is needed:
> > + *
> > + *   + we allocate a new &struct drm_atomic_state using drm_atomic_state_alloc().
> > + *
> > + *   + we copy the state of each affected entity into our &struct
> > + *     drm_atomic_state using drm_atomic_get_plane_state(),
> > + *     drm_atomic_get_crtc_state(), drm_atomic_get_connector_state(), or
> > + *     drm_atomic_get_private_obj_state(). That state can then be
> > + *     modified.
> > + *
> > + *     At that point, &struct drm_atomic_state stores three state
> > + *     pointers for that particular entity: the old, new, and existing
> > + *     (called "state") states. The old state is the state currently
> > + *     active in the hardware, ie either the one initialized by reset()
> 
> 'ie' should be replaced by 'which is'. AFAIK ie is used like this: 
> (i.e., ...).
> 
> > + *     or a newer one if a commit has been made. The new state is the
> > + *     state we just allocated and we might eventually commit to the
> > + *     hardware. The existing state points to the state we'll eventually
> > + *     have to free, the new state for now.
> 
> That final sentence is confusing. What are we doing with the existing 
> state? Will the old state ever become the existing state? You also never 
> explain this below.
> 
> Maybe only focus on the old and new state for now and explain the 
> meaning of the existing state in a separate bullet point.

I agree, the documentation here is clear for someone who knows exactly
how things work, but quite confusing for a newcomer.

> > + *
> > + *   + Once we run a commit, it is first checked and if the check is
> > + *     successful, it is committed. Part of the commit is a call to

"Committing a commit" sounds weird. As you define the atomic state above
as "an update to video pipeline state", I would write

  After the state is populated, it is checked. If the check is successful, the
  state update is then committed.

> > + *     drm_atomic_helper_swap_state() which will turn the new state into
> > + *     the active state. Doing so involves updating the entity state
> > + *     pointer (&drm_crtc.state or similar) to point to the new state,
> > + *     and the existing state will now point to the old state, that used
> > + *     to be active but isn't anymore.
> > + *
> > + *   + When the commit is done, and when all references to our &struct
> > + *     drm_atomic_state are put, drm_atomic_state_clear() runs and will
> > + *     free all the old states.
> > + *
> > + *   + Now, we don't have any active &struct drm_atomic_state anymore,
> > + *     and only the entity active states remain allocated.
> > + */
> > +
> >   void __drm_crtc_commit_free(struct kref *kref)
> >   {
> >   	struct drm_crtc_commit *commit =
> >   		container_of(kref, struct drm_crtc_commit, ref);
> >   

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2025-09-02 18:59 UTC|newest]

Thread overview: 105+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-02  8:32 [PATCH 00/29] drm: Implement state readout support Maxime Ripard
2025-09-02  8:32 ` [PATCH 01/29] drm/atomic: Document atomic state lifetime Maxime Ripard
2025-09-02 13:08   ` Thomas Zimmermann
2025-09-02 18:59     ` Laurent Pinchart [this message]
2025-09-23  9:22     ` Maxime Ripard
2025-09-02  8:32 ` [PATCH 02/29] drm/atomic: Fix unused but set warning in for_each_old_plane_in_state Maxime Ripard
2025-09-02 13:10   ` Thomas Zimmermann
2025-09-02 19:25   ` Laurent Pinchart
2025-09-02  8:32 ` [PATCH 03/29] drm/atomic: Fix unused but set warning in for_each_old_private_obj_in_state Maxime Ripard
2025-09-02 13:10   ` Thomas Zimmermann
2025-09-02 19:26   ` Laurent Pinchart
2025-09-02  8:32 ` [PATCH 04/29] drm/atomic_helper: Skip over NULL private_obj pointers Maxime Ripard
2025-09-02 13:13   ` Thomas Zimmermann
2025-09-02 19:29     ` Laurent Pinchart
2025-09-23  9:23     ` Maxime Ripard
2025-09-02  8:32 ` [PATCH 05/29] drm/atomic_state_helper: Fix bridge state initialization Maxime Ripard
2025-09-02 13:18   ` Thomas Zimmermann
2025-09-15 11:27     ` Maxime Ripard
2025-09-15 13:12       ` Thomas Zimmermann
2025-09-23  9:33         ` Maxime Ripard
2025-10-01  6:45           ` Thomas Zimmermann
2025-09-15 12:54     ` Dmitry Baryshkov
2025-09-02 19:49   ` Laurent Pinchart
2025-09-02  8:32 ` [PATCH 06/29] drm/bridge: Implement atomic_print_state Maxime Ripard
2025-09-02 13:22   ` Thomas Zimmermann
2025-09-02 20:22     ` Laurent Pinchart
2025-09-15 11:28       ` Maxime Ripard
2025-09-15 12:56         ` Dmitry Baryshkov
2025-09-02  8:32 ` [PATCH 07/29] drm/atomic: Implement drm_atomic_print_old_state Maxime Ripard
2025-09-02 13:26   ` Thomas Zimmermann
2025-09-09 12:44     ` Maxime Ripard
2025-09-02 20:35   ` Laurent Pinchart
2025-09-02  8:32 ` [PATCH 08/29] drm/atomic: Only call atomic_destroy_state on a !NULL pointer Maxime Ripard
2025-09-02 13:30   ` Thomas Zimmermann
2025-09-02 20:52   ` Laurent Pinchart
2025-09-15 11:35     ` Maxime Ripard
2025-09-02  8:32 ` [PATCH 09/29] drm/modeset: Create atomic_reset hook Maxime Ripard
2025-09-02 21:04   ` Laurent Pinchart
2025-09-15 11:37     ` Maxime Ripard
2025-09-02  8:32 ` [PATCH 10/29] drm/atomic: Add atomic_state_readout infrastructure Maxime Ripard
2025-09-02 13:44   ` Thomas Zimmermann
2025-09-15  8:42     ` Maxime Ripard
2025-09-15  9:11       ` Thomas Zimmermann
2025-09-23  9:37         ` Maxime Ripard
2025-10-01  7:01           ` Thomas Zimmermann
2025-09-15 18:38       ` Dmitry Baryshkov
2025-09-23  9:38         ` Maxime Ripard
2025-09-23 10:28           ` Dmitry Baryshkov
2025-09-23 10:32             ` Laurent Pinchart
2025-09-23 10:43               ` Dmitry Baryshkov
2025-09-23 11:41                 ` Laurent Pinchart
2025-09-23 15:20                   ` Dmitry Baryshkov
2025-09-24  9:56               ` Maxime Ripard
2025-09-24  9:53             ` Maxime Ripard
2025-09-15 18:40   ` Dmitry Baryshkov
2025-09-23  9:45     ` Maxime Ripard
2025-09-23 10:30       ` Dmitry Baryshkov
2025-10-17 13:12         ` Simona Vetter
2025-10-17 13:29   ` Simona Vetter
2025-10-17 13:41   ` Simona Vetter
2025-09-02  8:32 ` [PATCH 11/29] drm/crtc: Drop no_vblank bit field Maxime Ripard
2025-09-02 13:45   ` Thomas Zimmermann
2025-09-30 10:00   ` (subset) " Maxime Ripard
2025-09-02  8:32 ` [PATCH 12/29] drm/atomic_helper: Pass nonblock to commit_tail Maxime Ripard
2025-09-02 13:46   ` Thomas Zimmermann
2025-09-02  8:32 ` [PATCH 13/29] drm/atomic_helper: Compare actual and readout states once the commit is done Maxime Ripard
2025-10-17 13:21   ` Simona Vetter
2025-10-21  9:27   ` Simona Vetter
2025-10-31 21:01   ` Simona Vetter
2025-09-02  8:32 ` [PATCH 14/29] drm/atomic_state_helper: Provide comparison macros Maxime Ripard
2025-09-02  8:32 ` [PATCH 15/29] drm/atomic_state_helper: Provide atomic_compare_state helpers Maxime Ripard
2025-09-02  8:32 ` [PATCH 16/29] drm/encoder: Create get_current_crtc hook Maxime Ripard
2025-10-17 13:19   ` Simona Vetter
2025-09-02  8:32 ` [PATCH 17/29] drm/bridge_connector: Implement hw readout for connector Maxime Ripard
2025-09-02  8:32 ` [PATCH 18/29] drm/tidss: Convert to drm logging Maxime Ripard
2025-09-02 13:49   ` Thomas Zimmermann
2025-09-30 10:00   ` (subset) " Maxime Ripard
2025-09-02  8:32 ` [PATCH 19/29] drm/tidss: Remove ftrace-like logs Maxime Ripard
2025-09-02 13:50   ` Thomas Zimmermann
2025-09-30 10:00   ` (subset) " Maxime Ripard
2025-09-02  8:32 ` [PATCH 20/29] drm/tidss: crtc: Change variable name Maxime Ripard
2025-09-02 13:51   ` Thomas Zimmermann
2025-09-30 10:00   ` (subset) " Maxime Ripard
2025-09-02  8:32 ` [PATCH 21/29] drm/tidss: crtc: Implement destroy_state Maxime Ripard
2025-09-02 13:52   ` Thomas Zimmermann
2025-09-30 10:00   ` (subset) " Maxime Ripard
2025-09-02  8:32 ` [PATCH 22/29] drm/tidss: crtc: Cleanup reset implementation Maxime Ripard
2025-09-02 13:54   ` Thomas Zimmermann
2025-09-30 10:00   ` (subset) " Maxime Ripard
2025-09-02  8:32 ` [PATCH 23/29] drm/tidss: dispc: Add format lookup by hw value Maxime Ripard
2025-10-08 12:40   ` Tomi Valkeinen
2025-09-02  8:32 ` [PATCH 24/29] drm/tidss: dispc: Improve mode checking logs Maxime Ripard
2025-09-02 14:06   ` Thomas Zimmermann
2025-09-02  8:32 ` [PATCH 25/29] drm/tidss: dispc: Move dispc_device definition to headers Maxime Ripard
2025-09-02  8:32 ` [PATCH 26/29] drm/tidss: dispc: make accessors accessible to other parts of the driver Maxime Ripard
2025-09-02  8:32 ` [PATCH 27/29] drm/tidss: Implement readout support Maxime Ripard
2025-10-08 12:44   ` Tomi Valkeinen
2025-09-02  8:32 ` [PATCH 28/29] drm/tidss: encoder: implement get_current_crtc Maxime Ripard
2025-09-02  8:32 ` [PATCH 29/29] drm/bridge: sii902x: Implement hw state readout Maxime Ripard
2025-09-02 14:13 ` [PATCH 00/29] drm: Implement state readout support Thomas Zimmermann
2025-09-23  9:15   ` Maxime Ripard
2025-10-17 13:11     ` Simona Vetter
2025-10-08 13:07 ` Tomi Valkeinen
2025-10-08 13:57   ` Maxime Ripard
2025-10-08 14:15     ` Tomi Valkeinen

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=20250902185912.GP13448@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=airlied@gmail.com \
    --cc=andrzej.hajda@intel.com \
    --cc=devarsht@ti.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jernej.skrabec@gmail.com \
    --cc=jonas@kwiboo.se \
    --cc=jyri.sarha@iki.fi \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=rfoss@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tomi.valkeinen@ideasonboard.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®