From: Daniel Vetter <daniel@ffwll.ch>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 3/4] drm/atomic: Add macros to access existing old/new state
Date: Wed, 28 Dec 2016 15:25:10 +0100 [thread overview]
Message-ID: <20161228142510.GP347@dvetter-linux.ger.corp.intel.com> (raw)
In-Reply-To: <1479304688-24010-4-git-send-email-maarten.lankhorst@linux.intel.com>
On Wed, Nov 16, 2016 at 02:58:07PM +0100, Maarten Lankhorst wrote:
> During atomic check/commit, these macros should be used in place of
> get_existing_state.
>
> We also ban the use of get_xx_state after atomic check, because at that
> point no new locks should be taken and get_new/old_state should be used
> instead.
>
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
So one slightly annoying thing with the new/old split is that const-ness
of these changes. In atomic_check the old state should be const, in
atomic_commit the new state. By going to the new/old split we're losing
that safeguard. Otoh we have lots and lots of exceptions to that rule ...
not sure how much aiming for const correctness is worth it.
-Daniel
> ---
> include/drm/drm_atomic.h | 100 +++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 100 insertions(+)
>
> diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
> index 462408a2d1b8..7be178264732 100644
> --- a/include/drm/drm_atomic.h
> +++ b/include/drm/drm_atomic.h
> @@ -264,6 +264,36 @@ drm_atomic_get_existing_crtc_state(struct drm_atomic_state *state,
> }
>
> /**
> + * drm_atomic_get_old_crtc_state - get old crtc state, if it exists
> + * @state: global atomic state object
> + * @crtc: crtc to grab
> + *
> + * This function returns the old crtc state for the given crtc, or
> + * NULL if the crtc is not part of the global atomic state.
> + */
> +static inline struct drm_crtc_state *
> +drm_atomic_get_old_crtc_state(struct drm_atomic_state *state,
> + struct drm_crtc *crtc)
> +{
> + return state->crtcs[drm_crtc_index(crtc)].old_state;
> +}
> +
> +/**
> + * drm_atomic_get_new_crtc_state - get new crtc state, if it exists
> + * @state: global atomic state object
> + * @crtc: crtc to grab
> + *
> + * This function returns the new crtc state for the given crtc, or
> + * NULL if the crtc is not part of the global atomic state.
> + */
> +static inline struct drm_crtc_state *
> +drm_atomic_get_new_crtc_state(struct drm_atomic_state *state,
> + struct drm_crtc *crtc)
> +{
> + return state->crtcs[drm_crtc_index(crtc)].new_state;
> +}
> +
> +/**
> * drm_atomic_get_existing_plane_state - get plane state, if it exists
> * @state: global atomic state object
> * @plane: plane to grab
> @@ -279,6 +309,36 @@ drm_atomic_get_existing_plane_state(struct drm_atomic_state *state,
> }
>
> /**
> + * drm_atomic_get_old_plane_state - get plane state, if it exists
> + * @state: global atomic state object
> + * @plane: plane to grab
> + *
> + * This function returns the old plane state for the given plane, or
> + * NULL if the plane is not part of the global atomic state.
> + */
> +static inline struct drm_plane_state *
> +drm_atomic_get_old_plane_state(struct drm_atomic_state *state,
> + struct drm_plane *plane)
> +{
> + return state->planes[drm_plane_index(plane)].old_state;
> +}
> +
> +/**
> + * drm_atomic_get_new_plane_state - get plane state, if it exists
> + * @state: global atomic state object
> + * @plane: plane to grab
> + *
> + * This function returns the new plane state for the given plane, or
> + * NULL if the plane is not part of the global atomic state.
> + */
> +static inline struct drm_plane_state *
> +drm_atomic_get_new_plane_state(struct drm_atomic_state *state,
> + struct drm_plane *plane)
> +{
> + return state->planes[drm_plane_index(plane)].new_state;
> +}
> +
> +/**
> * drm_atomic_get_existing_connector_state - get connector state, if it exists
> * @state: global atomic state object
> * @connector: connector to grab
> @@ -299,6 +359,46 @@ drm_atomic_get_existing_connector_state(struct drm_atomic_state *state,
> }
>
> /**
> + * drm_atomic_get_old_connector_state - get connector state, if it exists
> + * @state: global atomic state object
> + * @connector: connector to grab
> + *
> + * This function returns the old connector state for the given connector,
> + * or NULL if the connector is not part of the global atomic state.
> + */
> +static inline struct drm_connector_state *
> +drm_atomic_get_old_connector_state(struct drm_atomic_state *state,
> + struct drm_connector *connector)
> +{
> + int index = drm_connector_index(connector);
> +
> + if (index >= state->num_connector)
> + return NULL;
> +
> + return state->connectors[index].old_state;
> +}
> +
> +/**
> + * drm_atomic_get_new_connector_state - get connector state, if it exists
> + * @state: global atomic state object
> + * @connector: connector to grab
> + *
> + * This function returns the new connector state for the given connector,
> + * or NULL if the connector is not part of the global atomic state.
> + */
> +static inline struct drm_connector_state *
> +drm_atomic_get_new_connector_state(struct drm_atomic_state *state,
> + struct drm_connector *connector)
> +{
> + int index = drm_connector_index(connector);
> +
> + if (index >= state->num_connector)
> + return NULL;
> +
> + return state->connectors[index].new_state;
> +}
> +
> +/**
> * __drm_atomic_get_current_plane_state - get current plane state
> * @state: global atomic state object
> * @plane: plane to grab
> --
> 2.7.4
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2016-12-28 14:25 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-16 13:58 [PATCH v2 0/4] drm/atomic: Add accessor macros for all atomic state Maarten Lankhorst
2016-11-16 13:58 ` [PATCH v2 1/4] drm/atomic: Add new iterators over all state, v2 Maarten Lankhorst
2016-11-16 13:58 ` [PATCH v2 2/4] drm/atomic: Add accessor macros for the current state Maarten Lankhorst
2016-11-16 14:35 ` Ville Syrjälä
2016-11-16 15:04 ` Daniel Vetter
2016-11-16 16:11 ` Maarten Lankhorst
2016-11-16 16:26 ` Daniel Vetter
2016-11-16 16:32 ` Ville Syrjälä
2016-11-17 11:58 ` Maarten Lankhorst
2016-11-17 12:26 ` Ville Syrjälä
2016-11-17 12:42 ` Maarten Lankhorst
2016-11-17 12:50 ` Ville Syrjälä
2016-11-17 13:20 ` [PATCH v2.1 2/4] drm/atomic: Add accessor macros for the current state, v2 Maarten Lankhorst
2016-12-09 22:27 ` Daniel Vetter
2016-12-14 13:15 ` Daniel Vetter
2016-12-15 10:24 ` [PATCH v2.2 2/4] drm/atomic: Add accessor macros for the current state, v3 Maarten Lankhorst
2016-11-16 13:58 ` [PATCH v2 3/4] drm/atomic: Add macros to access existing old/new state Maarten Lankhorst
2016-12-28 14:25 ` Daniel Vetter [this message]
2016-11-16 13:58 ` [PATCH v2 4/4] drm/atomic: Add checks to ensure get_state is not called after swapping Maarten Lankhorst
2016-11-16 14:18 ` [PATCH v2 0/4] drm/atomic: Add accessor macros for all atomic state Daniel Vetter
2016-11-16 16:11 ` Maarten Lankhorst
2016-11-16 16:27 ` Daniel Vetter
2016-12-14 13:17 ` Daniel Vetter
2016-12-15 9:19 ` Maarten Lankhorst
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=20161228142510.GP347@dvetter-linux.ger.corp.intel.com \
--to=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=maarten.lankhorst@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.