From: Maxime Ripard <maxime@cerno.tech>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Thomas Zimmermann <tzimmermann@suse.de>,
Maxime Ripard <maxime@cerno.tech>,
Daniel Vetter <daniel.vetter@intel.com>,
David Airlie <airlied@linux.ie>
Cc: dri-devel@lists.freedesktop.org,
Philipp Zabel <p.zabel@pengutronix.de>,
Daniel Vetter <daniel@ffwll.ch>, Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
NXP Linux Team <linux-imx@nxp.com>,
Rob Clark <robdclark@gmail.com>, Sean Paul <sean@poorly.run>,
Jyri Sarha <jyri.sarha@iki.fi>, Tomi Valkeinen <tomba@kernel.org>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
freedreno@lists.freedesktop.org
Subject: [PATCH v2 06/11] drm: Use state helper instead of plane state pointer in atomic_check
Date: Thu, 21 Jan 2021 17:35:31 +0100 [thread overview]
Message-ID: <20210121163537.1466118-6-maxime@cerno.tech> (raw)
In-Reply-To: <20210121163537.1466118-1-maxime@cerno.tech>
Many drivers reference the plane->state pointer in order to get the
current plane state in their atomic_check hook, which would be the old
plane state in the global atomic state since _swap_state hasn't happened
when atomic_check is run.
Use the drm_atomic_get_old_plane_state helper to get that state to make
it more obvious.
This was made using the coccinelle script below:
@ plane_atomic_func @
identifier helpers;
identifier func;
@@
static struct drm_plane_helper_funcs helpers = {
...,
.atomic_check = func,
...,
};
@ replaces_old_state @
identifier plane_atomic_func.func;
identifier plane, state, plane_state;
@@
func(struct drm_plane *plane, struct drm_atomic_state *state) {
...
- struct drm_plane_state *plane_state = plane->state;
+ struct drm_plane_state *plane_state = drm_atomic_get_old_plane_state(state, plane);
...
}
@@
identifier plane_atomic_func.func;
identifier plane, state, plane_state;
@@
func(struct drm_plane *plane, struct drm_atomic_state *state) {
struct drm_plane_state *plane_state = drm_atomic_get_old_plane_state(state, plane);
...
- plane->state
+ plane_state
...
}
@ adds_old_state @
identifier plane_atomic_func.func;
identifier plane, state;
@@
func(struct drm_plane *plane, struct drm_atomic_state *state) {
+ struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state, plane);
...
- plane->state
+ old_plane_state
...
}
@ include depends on adds_old_state || replaces_old_state @
@@
#include <drm/drm_atomic.h>
@ no_include depends on !include && (adds_old_state || replaces_old_state) @
@@
+ #include <drm/drm_atomic.h>
#include <drm/...>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
drivers/gpu/drm/imx/ipuv3-plane.c | 3 ++-
drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c | 4 +++-
drivers/gpu/drm/tilcdc/tilcdc_plane.c | 3 ++-
3 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/imx/ipuv3-plane.c b/drivers/gpu/drm/imx/ipuv3-plane.c
index b5f6123850bb..6484592e3f86 100644
--- a/drivers/gpu/drm/imx/ipuv3-plane.c
+++ b/drivers/gpu/drm/imx/ipuv3-plane.c
@@ -341,7 +341,8 @@ static int ipu_plane_atomic_check(struct drm_plane *plane,
{
struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
plane);
- struct drm_plane_state *old_state = plane->state;
+ struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state,
+ plane);
struct drm_crtc_state *crtc_state;
struct device *dev = plane->dev->dev;
struct drm_framebuffer *fb = new_state->fb;
diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c b/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c
index 4aac6217a5ad..6ce6ce09fecc 100644
--- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c
+++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c
@@ -406,12 +406,14 @@ static int mdp5_plane_atomic_check_with_state(struct drm_crtc_state *crtc_state,
static int mdp5_plane_atomic_check(struct drm_plane *plane,
struct drm_atomic_state *state)
{
+ struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state,
+ plane);
struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
plane);
struct drm_crtc *crtc;
struct drm_crtc_state *crtc_state;
- crtc = new_plane_state->crtc ? new_plane_state->crtc : plane->state->crtc;
+ crtc = new_plane_state->crtc ? new_plane_state->crtc : old_plane_state->crtc;
if (!crtc)
return 0;
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_plane.c b/drivers/gpu/drm/tilcdc/tilcdc_plane.c
index ebdd42dcaf82..c86258132432 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_plane.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_plane.c
@@ -26,7 +26,8 @@ static int tilcdc_plane_atomic_check(struct drm_plane *plane,
struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
plane);
struct drm_crtc_state *crtc_state;
- struct drm_plane_state *old_state = plane->state;
+ struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state,
+ plane);
unsigned int pitch;
if (!new_state->crtc)
--
2.29.2
next prev parent reply other threads:[~2021-01-21 16:48 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-21 16:35 [PATCH v2 01/11] drm/atomic: Pass the full state to planes async atomic check and update Maxime Ripard
2021-01-21 16:35 ` [PATCH v2 02/11] drm: Rename plane atomic_check state names Maxime Ripard
2021-01-21 16:35 ` [PATCH v2 03/11] drm/atmel-hlcdc: Rename custom plane state variable Maxime Ripard
2021-01-21 16:35 ` [PATCH v2 04/11] drm/atomic: Pass the full state to planes atomic_check Maxime Ripard
2021-01-21 16:35 ` [PATCH v2 05/11] drm: Use the state pointer directly in " Maxime Ripard
2021-01-21 16:35 ` Maxime Ripard [this message]
2021-01-22 12:07 ` [PATCH v2 06/11] drm: Use state helper instead of plane state pointer in atomic_check Ville Syrjälä
2021-01-25 9:07 ` Maxime Ripard
2021-01-21 16:35 ` [PATCH v2 07/11] drm: Store new plane state in a variable for atomic_update and disable Maxime Ripard
2021-01-21 16:35 ` [PATCH v2 08/11] drm: Rename plane->state variables in atomic update " Maxime Ripard
[not found] ` <YArBy2DKdCct5cYW@intel.com>
2021-01-25 10:52 ` Maxime Ripard
2021-01-25 11:52 ` Ville Syrjälä
2021-01-21 16:35 ` [PATCH v2 09/11] drm/atomic: Pass the full state to planes atomic disable and update Maxime Ripard
2021-01-21 23:03 ` Laurent Pinchart
2021-01-21 16:35 ` [PATCH v2 10/11] drm: Use state helper instead of the plane state pointer Maxime Ripard
2021-01-26 13:24 ` Ville Syrjälä
2021-01-21 16:35 ` [PATCH v2 11/11] drm/todo: Remove the drm_atomic_state todo item Maxime Ripard
2021-01-21 18:27 ` Daniel Vetter
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=20210121163537.1466118-6-maxime@cerno.tech \
--to=maxime@cerno.tech \
--cc=airlied@linux.ie \
--cc=daniel.vetter@intel.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=festevam@gmail.com \
--cc=freedreno@lists.freedesktop.org \
--cc=jyri.sarha@iki.fi \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=p.zabel@pengutronix.de \
--cc=robdclark@gmail.com \
--cc=s.hauer@pengutronix.de \
--cc=sean@poorly.run \
--cc=shawnguo@kernel.org \
--cc=tomba@kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).