From: Simona Vetter <simona.vetter@ffwll.ch>
To: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Cc: Maxime Ripard <mripard@kernel.org>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Thomas Zimmermann <tzimmermann@suse.de>,
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>,
Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
Jonas Karlman <jonas@kwiboo.se>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Douglas Anderson <dianders@chromium.org>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 01/29] drm/atomic-helper: Fix commit_tail state variable name
Date: Thu, 16 Jan 2025 12:27:36 +0100 [thread overview]
Message-ID: <Z4jtKHY4qN3RNZNG@phenom.ffwll.local> (raw)
In-Reply-To: <w6hoxhwyrp44e6yqelxe5qtlyq643bvynmqrwzybuflhb7lkvu@bmsy3losd6t4>
On Thu, Jan 16, 2025 at 03:36:12AM +0200, Dmitry Baryshkov wrote:
> On Wed, Jan 15, 2025 at 10:05:08PM +0100, Maxime Ripard wrote:
> > Even though the commit_tail () drm_atomic_state parameter is called
> > old_state, it's actually the state being committed which is confusing.
> >
> > It's even more confusing since the atomic_commit_tail hook being called
> > by commit_tail() parameter is called state.
>
> Do you have any kind of history and/or explanation, why it's called
> old_state all over the place?
>
> I think that the renaming is correct, but I'd like to understand the
> reason behind it.
So originally drm_atomic_state only had a single set of state pointers, so
was truly just a state collection and not a state transition/commit like
it is now.
During atomic check it contained the new states, and the old ones you
could get by looking at obj->state pointers. After
drm_atomic_helper_swap_state it contained the old states, and the new ones
could be found by looking at obj->state.
This caused endless amounts of confusions, and eventually we settled on a
new design:
- Ville added both old and new state pointers to drm_atomic_state, so now
it's not just a state collection, but really a state transition/commit.
We did discuss whether we should also rename it, but for lack of time
and good name this hasn't happened yet.
- Instead of trying to pass the individual states to callbacks we've moved
over to just passing drm_atomic_state, and let the callbacks grab
whatever they need. That's also not yet done everywhere yet, but I think
we're pretty close.
But one of the interim attempts at reducing the confusion was to rename
the drm_atomic_state argument to old_state anywhere after we've called
swap_states(). Didn't really help, and not it's just adding to the
confusion.
If we haven't yet I guess we should document the above two design
principles in the drm_atomic_state kerneldoc.
Cheers, Sima
>
> > Let's rename the variable from old_state to state to make it less
> > confusing.
> >
> > Signed-off-by: Maxime Ripard <mripard@kernel.org>
> > ---
> > drivers/gpu/drm/drm_atomic_helper.c | 20 ++++++++++----------
> > 1 file changed, 10 insertions(+), 10 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> > index 40e4e1b6c9110677c1c4981eeb15dc93966f4cf6..913d94d664d885323ad7e41a6424633c28c787e1 100644
> > --- a/drivers/gpu/drm/drm_atomic_helper.c
> > +++ b/drivers/gpu/drm/drm_atomic_helper.c
> > @@ -1818,13 +1818,13 @@ void drm_atomic_helper_commit_tail_rpm(struct drm_atomic_state *old_state)
> >
> > drm_atomic_helper_cleanup_planes(dev, old_state);
> > }
> > EXPORT_SYMBOL(drm_atomic_helper_commit_tail_rpm);
> >
> > -static void commit_tail(struct drm_atomic_state *old_state)
> > +static void commit_tail(struct drm_atomic_state *state)
> > {
> > - struct drm_device *dev = old_state->dev;
> > + struct drm_device *dev = state->dev;
> > const struct drm_mode_config_helper_funcs *funcs;
> > struct drm_crtc_state *new_crtc_state;
> > struct drm_crtc *crtc;
> > ktime_t start;
> > s64 commit_time_ms;
> > @@ -1842,37 +1842,37 @@ static void commit_tail(struct drm_atomic_state *old_state)
> > * These times will be averaged out in the self refresh helpers to avoid
> > * overreacting over one outlier frame
> > */
> > start = ktime_get();
> >
> > - drm_atomic_helper_wait_for_fences(dev, old_state, false);
> > + drm_atomic_helper_wait_for_fences(dev, state, false);
> >
> > - drm_atomic_helper_wait_for_dependencies(old_state);
> > + drm_atomic_helper_wait_for_dependencies(state);
> >
> > /*
> > * We cannot safely access new_crtc_state after
> > * drm_atomic_helper_commit_hw_done() so figure out which crtc's have
> > * self-refresh active beforehand:
> > */
> > - for_each_new_crtc_in_state(old_state, crtc, new_crtc_state, i)
> > + for_each_new_crtc_in_state(state, crtc, new_crtc_state, i)
> > if (new_crtc_state->self_refresh_active)
> > new_self_refresh_mask |= BIT(i);
> >
> > if (funcs && funcs->atomic_commit_tail)
> > - funcs->atomic_commit_tail(old_state);
> > + funcs->atomic_commit_tail(state);
> > else
> > - drm_atomic_helper_commit_tail(old_state);
> > + drm_atomic_helper_commit_tail(state);
> >
> > commit_time_ms = ktime_ms_delta(ktime_get(), start);
> > if (commit_time_ms > 0)
> > - drm_self_refresh_helper_update_avg_times(old_state,
> > + drm_self_refresh_helper_update_avg_times(state,
> > (unsigned long)commit_time_ms,
> > new_self_refresh_mask);
> >
> > - drm_atomic_helper_commit_cleanup_done(old_state);
> > + drm_atomic_helper_commit_cleanup_done(state);
> >
> > - drm_atomic_state_put(old_state);
> > + drm_atomic_state_put(state);
> > }
> >
> > static void commit_work(struct work_struct *work)
> > {
> > struct drm_atomic_state *state = container_of(work,
> >
> > --
> > 2.47.1
> >
>
> --
> With best wishes
> Dmitry
--
Simona Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
next prev parent reply other threads:[~2025-01-16 11:27 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-15 21:05 [PATCH 00/29] drm/bridge: Various quality of life improvements Maxime Ripard
2025-01-15 21:05 ` [PATCH 01/29] drm/atomic-helper: Fix commit_tail state variable name Maxime Ripard
2025-01-16 1:36 ` Dmitry Baryshkov
2025-01-16 11:27 ` Simona Vetter [this message]
2025-01-15 21:05 ` [PATCH 02/29] drm/atomic-helper: Change parameter name of drm_atomic_helper_wait_for_dependencies() Maxime Ripard
2025-01-15 21:05 ` [PATCH 03/29] drm/atomic-helper: Change parameter name of drm_atomic_helper_commit_tail() Maxime Ripard
2025-01-15 21:05 ` [PATCH 04/29] drm/atomic-helper: Change parameter name of drm_atomic_helper_commit_tail_rpm() Maxime Ripard
2025-01-15 21:05 ` [PATCH 05/29] drm/atomic-helper: Change parameter name of drm_atomic_helper_modeset_disables() Maxime Ripard
2025-01-15 21:05 ` [PATCH 06/29] drm/atomic-helper: Change parameter name of disable_outputs() Maxime Ripard
2025-01-15 21:05 ` [PATCH 07/29] drm/bridge: Change parameter name of drm_atomic_bridge_chain_disable() Maxime Ripard
2025-01-15 21:05 ` [PATCH 08/29] drm/bridge: Change parameter name of drm_atomic_bridge_chain_post_disable() Maxime Ripard
2025-01-15 21:05 ` [PATCH 09/29] drm/atomic-helper: Change parameter name of drm_atomic_helper_update_legacy_modeset_state() Maxime Ripard
2025-01-15 21:05 ` [PATCH 10/29] drm/atomic-helper: Change parameter name of crtc_set_mode() Maxime Ripard
2025-01-15 21:05 ` [PATCH 11/29] drm/atomic-helper: Change parameter name of drm_atomic_helper_commit_planes() Maxime Ripard
2025-01-15 21:05 ` [PATCH 12/29] drm/atomic-helper: Change parameter name of drm_atomic_helper_commit_modeset_enables() Maxime Ripard
2025-01-15 21:05 ` [PATCH 13/29] drm/bridge: Change parameter name of drm_atomic_bridge_chain_pre_enable() Maxime Ripard
2025-01-15 21:05 ` [PATCH 14/29] drm/bridge: Change parameter name of drm_atomic_bridge_chain_enable() Maxime Ripard
2025-01-15 21:05 ` [PATCH 15/29] drm/atomic-helper: Change parameter name of drm_atomic_helper_commit_writebacks() Maxime Ripard
2025-01-15 21:05 ` [PATCH 16/29] drm/atomic-helper: Change parameter name of drm_atomic_helper_fake_vblank() Maxime Ripard
2025-01-15 21:05 ` [PATCH 17/29] drm/atomic-helper: Change parameter name of drm_atomic_helper_commit_hw_done() Maxime Ripard
2025-01-15 21:05 ` [PATCH 18/29] drm/atomic-helper: Change parameter name of drm_atomic_helper_wait_for_vblanks() Maxime Ripard
2025-01-15 21:05 ` [PATCH 19/29] drm/atomic-helper: Change parameter name of drm_atomic_helper_cleanup_planes() Maxime Ripard
2025-01-15 21:05 ` [PATCH 20/29] drm/atomic-helper: Change parameter name of drm_atomic_helper_commit_cleanup_done() Maxime Ripard
2025-01-15 21:05 ` [PATCH 21/29] drm/atomic-helper: Change parameter name of drm_atomic_helper_wait_for_flip_done() Maxime Ripard
2025-01-15 21:05 ` [PATCH 22/29] drm/bridge: Rename atomic hooks parameters to drop old prefix Maxime Ripard
2025-01-16 11:34 ` Simona Vetter
2025-01-17 14:50 ` Maxime Ripard
2025-01-17 15:32 ` Simona Vetter
2025-01-15 21:05 ` [PATCH 23/29] drm/bridge: Provide a helper to retrieve current bridge state Maxime Ripard
2025-01-16 0:43 ` Dmitry Baryshkov
2025-01-16 8:30 ` Maxime Ripard
2025-01-16 11:35 ` Simona Vetter
2025-01-15 21:05 ` [PATCH 24/29] drm/bridge: Provide a helper to get the global state from a " Maxime Ripard
2025-01-16 11:31 ` Simona Vetter
2025-01-15 21:05 ` [PATCH 25/29] drm/bridge: Provide pointers to the connector and crtc in " Maxime Ripard
2025-01-16 1:04 ` Dmitry Baryshkov
2025-01-16 8:42 ` Maxime Ripard
2025-01-16 9:53 ` Dmitry Baryshkov
2025-01-15 21:05 ` [PATCH 26/29] drm/bridge: cdns-csi: Switch to atomic helpers Maxime Ripard
2025-01-16 1:06 ` Dmitry Baryshkov
2025-01-15 21:05 ` [PATCH 27/29] drm/bridge: tc358775: Switch to atomic commit Maxime Ripard
2025-01-16 1:06 ` Dmitry Baryshkov
2025-01-15 21:05 ` [PATCH 28/29] drm/bridge: tc358768: Convert to atomic helpers Maxime Ripard
2025-01-15 21:05 ` [PATCH 29/29] drm/bridge: ti-sn65dsi86: Use bridge_state crtc pointer Maxime Ripard
2025-01-16 1:08 ` Dmitry Baryshkov
2025-02-03 10:01 ` Maxime Ripard
2025-02-03 17:49 ` Dmitry Baryshkov
2025-02-04 8:23 ` Maxime Ripard
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=Z4jtKHY4qN3RNZNG@phenom.ffwll.local \
--to=simona.vetter@ffwll.ch \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=airlied@gmail.com \
--cc=andrzej.hajda@intel.com \
--cc=dianders@chromium.org \
--cc=dmitry.baryshkov@linaro.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=jernej.skrabec@gmail.com \
--cc=jonas@kwiboo.se \
--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=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.