diff mbox series

[v3,01/11] drm/atomic: Pass the full state to planes async atomic check and update

Message ID 20210219120032.260676-1-maxime@cerno.tech (mailing list archive)
State New, archived
Headers show
Series [v3,01/11] drm/atomic: Pass the full state to planes async atomic check and update | expand

Commit Message

Maxime Ripard Feb. 19, 2021, noon UTC
The current atomic helpers have either their object state being passed as
an argument or the full atomic state.

The former is the pattern that was done at first, before switching to the
latter for new hooks or when it was needed.

Let's start convert all the remaining helpers to provide a consistent
interface, starting with the planes atomic_async_check and
atomic_async_update.

The conversion was done using the coccinelle script below, built tested on
all the drivers.

@@
identifier plane, plane_state;
symbol state;
@@

 struct drm_plane_helper_funcs {
 	...
	int (*atomic_async_check)(struct drm_plane *plane,
-				  struct drm_plane_state *plane_state);
+				  struct drm_atomic_state *state);
	...
 }

@@
identifier plane, plane_state;
symbol state;
@@
 struct drm_plane_helper_funcs {
 	...
	void (*atomic_async_update)(struct drm_plane *plane,
-				    struct drm_plane_state *plane_state);
+				    struct drm_atomic_state *state);
	...
 }

@ plane_atomic_func @
identifier helpers;
identifier func;
@@

(
 static const struct drm_plane_helper_funcs helpers = {
	...,
 	.atomic_async_check = func,
	...,
 };
|
 static const struct drm_plane_helper_funcs helpers = {
 	...,
 	.atomic_async_update = func,
 	...,
 };
)

@@
struct drm_plane_helper_funcs *FUNCS;
identifier f;
identifier dev;
identifier plane, plane_state, state;
@@

 f(struct drm_device *dev, struct drm_atomic_state *state)
 {
 	<+...
-	FUNCS->atomic_async_check(plane, plane_state)
+	FUNCS->atomic_async_check(plane, state)
 	...+>
 }

@@
struct drm_plane_helper_funcs *FUNCS;
identifier f;
identifier dev;
identifier plane, plane_state, state;
@@

 f(struct drm_device *dev, struct drm_atomic_state *state)
 {
 	<+...
-	FUNCS->atomic_async_update(plane, plane_state)
+	FUNCS->atomic_async_update(plane, state)
 	...+>
 }

@@
identifier mtk_plane_atomic_async_update;
identifier plane;
symbol new_state, state;
expression e;
@@

  void mtk_plane_atomic_async_update(struct drm_plane *plane, struct drm_plane_state *new_state)
{
  ...
- struct mtk_plane_state *state = e;
+ struct mtk_plane_state *new_plane_state = e;
  <+...
-       state
+       new_plane_state
  ...+>
  }

@@
identifier plane_atomic_func.func;
identifier plane;
symbol state;
@@

 func(struct drm_plane *plane,
-    struct drm_plane_state *state)
+    struct drm_plane_state *new_plane_state)
 {
	<...
-	state
+	new_plane_state
	...>
 }

@ ignores_new_state @
identifier plane_atomic_func.func;
identifier plane, new_plane_state;
@@

 func(struct drm_plane *plane, struct drm_plane_state *new_plane_state)
 {
	... when != new_plane_state
 }

@ adds_new_state depends on plane_atomic_func && !ignores_new_state @
identifier plane_atomic_func.func;
identifier plane, new_plane_state;
@@

 func(struct drm_plane *plane, struct drm_plane_state *new_plane_state)
 {
+	struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state, plane);
 	...
 }

@ depends on plane_atomic_func @
identifier plane_atomic_func.func;
identifier plane, plane_state;
@@

 func(struct drm_plane *plane,
-     struct drm_plane_state *plane_state
+     struct drm_atomic_state *state
     )
 { ... }

@ include depends on adds_new_state @
@@

 #include <drm/drm_atomic.h>

@ no_include depends on !include && adds_new_state @
@@

+ #include <drm/drm_atomic.h>
  #include <drm/...>

@@
identifier plane_atomic_func.func;
identifier plane, state;
identifier plane_state;
@@

 func(struct drm_plane *plane, struct drm_atomic_state *state) {
        ...
        struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane);
        <+...
-       plane_state->state
+       state
        ...+>
 }

Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>

---

Changes from v1:
  - Updated the comment according to Thomas suggestions
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  8 ++-
 drivers/gpu/drm/drm_atomic_helper.c           |  4 +-
 drivers/gpu/drm/mediatek/mtk_drm_plane.c      | 26 +++++----
 drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c    | 33 ++++++-----
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c   | 16 ++++--
 drivers/gpu/drm/vc4/vc4_plane.c               | 56 ++++++++++---------
 include/drm/drm_modeset_helper_vtables.h      | 18 +++---
 7 files changed, 89 insertions(+), 72 deletions(-)

Comments

Thomas Zimmermann Feb. 22, 2021, 9:05 a.m. UTC | #1
Am 19.02.21 um 13:00 schrieb Maxime Ripard:
> Now that atomic_check takes the global atomic state as a parameter, we
> don't need to go through the pointer in the plane state.
> 
> This was done using the following coccinelle script:
> 
> @ plane_atomic_func @
> identifier helpers;
> identifier func;
> @@
> 
> static struct drm_plane_helper_funcs helpers = {
> 	...,
> 	.atomic_check = func,
> 	...,
> };
> 
> @@
> identifier plane_atomic_func.func;
> identifier plane, state;
> identifier plane_state;
> @@
> 
>    func(struct drm_plane *plane, struct drm_atomic_state *state) {
>    ...
> - struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane);
>    <... when != plane_state
> - plane_state->state
> + state
>    ...>
>   }
> 
> @@
> identifier plane_atomic_func.func;
> identifier plane, state;
> identifier plane_state;
> @@
> 
>    func(struct drm_plane *plane, struct drm_atomic_state *state) {
>    ...
>    struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane);
>    <...
> - plane_state->state
> + state
>    ...>
>   }
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>

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

> 
> ---
> 
> Changes from v1:
>    - Fixed the formatting in zynqmp_disp
> ---
>   drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +-
>   drivers/gpu/drm/arm/display/komeda/komeda_plane.c | 2 +-
>   drivers/gpu/drm/arm/hdlcd_crtc.c                  | 2 +-
>   drivers/gpu/drm/armada/armada_plane.c             | 4 ++--
>   drivers/gpu/drm/ast/ast_mode.c                    | 4 ++--
>   drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c   | 2 +-
>   drivers/gpu/drm/drm_simple_kms_helper.c           | 2 +-
>   drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c    | 2 +-
>   drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c   | 2 +-
>   drivers/gpu/drm/imx/dcss/dcss-plane.c             | 2 +-
>   drivers/gpu/drm/imx/ipuv3-plane.c                 | 2 +-
>   drivers/gpu/drm/ingenic/ingenic-drm-drv.c         | 2 +-
>   drivers/gpu/drm/ingenic/ingenic-ipu.c             | 2 +-
>   drivers/gpu/drm/kmb/kmb_plane.c                   | 2 +-
>   drivers/gpu/drm/mediatek/mtk_drm_plane.c          | 2 +-
>   drivers/gpu/drm/meson/meson_overlay.c             | 2 +-
>   drivers/gpu/drm/meson/meson_plane.c               | 2 +-
>   drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c         | 2 +-
>   drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c        | 2 +-
>   drivers/gpu/drm/mxsfb/mxsfb_kms.c                 | 2 +-
>   drivers/gpu/drm/omapdrm/omap_plane.c              | 2 +-
>   drivers/gpu/drm/rockchip/rockchip_drm_vop.c       | 2 +-
>   drivers/gpu/drm/sti/sti_cursor.c                  | 2 +-
>   drivers/gpu/drm/sti/sti_gdp.c                     | 2 +-
>   drivers/gpu/drm/sti/sti_hqvdp.c                   | 2 +-
>   drivers/gpu/drm/sun4i/sun8i_ui_layer.c            | 2 +-
>   drivers/gpu/drm/sun4i/sun8i_vi_layer.c            | 2 +-
>   drivers/gpu/drm/tidss/tidss_plane.c               | 2 +-
>   drivers/gpu/drm/tilcdc/tilcdc_plane.c             | 2 +-
>   drivers/gpu/drm/vboxvideo/vbox_mode.c             | 8 ++++----
>   drivers/gpu/drm/virtio/virtgpu_plane.c            | 2 +-
>   drivers/gpu/drm/vkms/vkms_plane.c                 | 2 +-
>   drivers/gpu/drm/vmwgfx/vmwgfx_kms.c               | 2 +-
>   drivers/gpu/drm/xlnx/zynqmp_disp.c                | 3 +--
>   drivers/gpu/drm/zte/zx_plane.c                    | 4 ++--
>   35 files changed, 41 insertions(+), 42 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index 1cdff048b0c0..22124f76d0b5 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -6451,7 +6451,7 @@ static int dm_plane_atomic_check(struct drm_plane *plane,
>   		return 0;
>   
>   	new_crtc_state =
> -		drm_atomic_get_new_crtc_state(new_plane_state->state,
> +		drm_atomic_get_new_crtc_state(state,
>   					      new_plane_state->crtc);
>   	if (!new_crtc_state)
>   		return -EINVAL;
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_plane.c b/drivers/gpu/drm/arm/display/komeda/komeda_plane.c
> index 96a6fe95a4e7..13582c174bbb 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_plane.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_plane.c
> @@ -84,7 +84,7 @@ komeda_plane_atomic_check(struct drm_plane *plane,
>   	if (!new_plane_state->crtc || !new_plane_state->fb)
>   		return 0;
>   
> -	crtc_st = drm_atomic_get_crtc_state(new_plane_state->state,
> +	crtc_st = drm_atomic_get_crtc_state(state,
>   					    new_plane_state->crtc);
>   	if (IS_ERR(crtc_st) || !crtc_st->enable) {
>   		DRM_DEBUG_ATOMIC("Cannot update plane on a disabled CRTC.\n");
> diff --git a/drivers/gpu/drm/arm/hdlcd_crtc.c b/drivers/gpu/drm/arm/hdlcd_crtc.c
> index 9da9d0581ce9..028ec39c8484 100644
> --- a/drivers/gpu/drm/arm/hdlcd_crtc.c
> +++ b/drivers/gpu/drm/arm/hdlcd_crtc.c
> @@ -244,7 +244,7 @@ static int hdlcd_plane_atomic_check(struct drm_plane *plane,
>   		return -EINVAL;
>   	}
>   
> -	for_each_new_crtc_in_state(new_plane_state->state, crtc, crtc_state,
> +	for_each_new_crtc_in_state(state, crtc, crtc_state,
>   				   i) {
>   		/* we cannot disable the plane while the CRTC is active */
>   		if (!new_plane_state->fb && crtc_state->active)
> diff --git a/drivers/gpu/drm/armada/armada_plane.c b/drivers/gpu/drm/armada/armada_plane.c
> index b1266c588102..51f33c689df3 100644
> --- a/drivers/gpu/drm/armada/armada_plane.c
> +++ b/drivers/gpu/drm/armada/armada_plane.c
> @@ -121,8 +121,8 @@ int armada_drm_plane_atomic_check(struct drm_plane *plane,
>   		return 0;
>   	}
>   
> -	if (new_plane_state->state)
> -		crtc_state = drm_atomic_get_existing_crtc_state(new_plane_state->state,
> +	if (state)
> +		crtc_state = drm_atomic_get_existing_crtc_state(state,
>   								crtc);
>   	else
>   		crtc_state = crtc->state;
> diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
> index cb8650142f13..d3c4a1f6aede 100644
> --- a/drivers/gpu/drm/ast/ast_mode.c
> +++ b/drivers/gpu/drm/ast/ast_mode.c
> @@ -547,7 +547,7 @@ static int ast_primary_plane_helper_atomic_check(struct drm_plane *plane,
>   	if (!new_plane_state->crtc)
>   		return 0;
>   
> -	crtc_state = drm_atomic_get_new_crtc_state(new_plane_state->state,
> +	crtc_state = drm_atomic_get_new_crtc_state(state,
>   						   new_plane_state->crtc);
>   
>   	ret = drm_atomic_helper_check_plane_state(new_plane_state, crtc_state,
> @@ -769,7 +769,7 @@ static int ast_cursor_plane_helper_atomic_check(struct drm_plane *plane,
>   	if (!new_plane_state->crtc)
>   		return 0;
>   
> -	crtc_state = drm_atomic_get_new_crtc_state(new_plane_state->state,
> +	crtc_state = drm_atomic_get_new_crtc_state(state,
>   						   new_plane_state->crtc);
>   
>   	ret = drm_atomic_helper_check_plane_state(new_plane_state, crtc_state,
> diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
> index 445105e75a97..a32d45bcc386 100644
> --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
> +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
> @@ -609,7 +609,7 @@ static int atmel_hlcdc_plane_atomic_check(struct drm_plane *p,
>   	if (!hstate->base.crtc || WARN_ON(!fb))
>   		return 0;
>   
> -	crtc_state = drm_atomic_get_existing_crtc_state(s->state, s->crtc);
> +	crtc_state = drm_atomic_get_existing_crtc_state(state, s->crtc);
>   	mode = &crtc_state->adjusted_mode;
>   
>   	ret = drm_atomic_helper_check_plane_state(s, crtc_state,
> diff --git a/drivers/gpu/drm/drm_simple_kms_helper.c b/drivers/gpu/drm/drm_simple_kms_helper.c
> index a43e34e04d6b..7f3d90e776a3 100644
> --- a/drivers/gpu/drm/drm_simple_kms_helper.c
> +++ b/drivers/gpu/drm/drm_simple_kms_helper.c
> @@ -186,7 +186,7 @@ static int drm_simple_kms_plane_atomic_check(struct drm_plane *plane,
>   	int ret;
>   
>   	pipe = container_of(plane, struct drm_simple_display_pipe, plane);
> -	crtc_state = drm_atomic_get_new_crtc_state(plane_state->state,
> +	crtc_state = drm_atomic_get_new_crtc_state(state,
>   						   &pipe->crtc);
>   
>   	ret = drm_atomic_helper_check_plane_state(plane_state, crtc_state,
> diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
> index ddcf121af542..3f7027e40c79 100644
> --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
> +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
> @@ -66,7 +66,7 @@ static int hibmc_plane_atomic_check(struct drm_plane *plane,
>   	if (!crtc || !fb)
>   		return 0;
>   
> -	crtc_state = drm_atomic_get_crtc_state(new_plane_state->state, crtc);
> +	crtc_state = drm_atomic_get_crtc_state(state, crtc);
>   	if (IS_ERR(crtc_state))
>   		return PTR_ERR(crtc_state);
>   
> diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
> index fab083380ef7..320631cb7034 100644
> --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
> +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
> @@ -781,7 +781,7 @@ static int ade_plane_atomic_check(struct drm_plane *plane,
>   	if (fmt == ADE_FORMAT_UNSUPPORT)
>   		return -EINVAL;
>   
> -	crtc_state = drm_atomic_get_crtc_state(new_plane_state->state, crtc);
> +	crtc_state = drm_atomic_get_crtc_state(state, crtc);
>   	if (IS_ERR(crtc_state))
>   		return PTR_ERR(crtc_state);
>   
> diff --git a/drivers/gpu/drm/imx/dcss/dcss-plane.c b/drivers/gpu/drm/imx/dcss/dcss-plane.c
> index 0e68d295bd60..35a7b23060b3 100644
> --- a/drivers/gpu/drm/imx/dcss/dcss-plane.c
> +++ b/drivers/gpu/drm/imx/dcss/dcss-plane.c
> @@ -157,7 +157,7 @@ static int dcss_plane_atomic_check(struct drm_plane *plane,
>   	cma_obj = drm_fb_cma_get_gem_obj(fb, 0);
>   	WARN_ON(!cma_obj);
>   
> -	crtc_state = drm_atomic_get_existing_crtc_state(new_plane_state->state,
> +	crtc_state = drm_atomic_get_existing_crtc_state(state,
>   							new_plane_state->crtc);
>   
>   	hdisplay = crtc_state->adjusted_mode.hdisplay;
> diff --git a/drivers/gpu/drm/imx/ipuv3-plane.c b/drivers/gpu/drm/imx/ipuv3-plane.c
> index 28571091ff1c..b5f6123850bb 100644
> --- a/drivers/gpu/drm/imx/ipuv3-plane.c
> +++ b/drivers/gpu/drm/imx/ipuv3-plane.c
> @@ -358,7 +358,7 @@ static int ipu_plane_atomic_check(struct drm_plane *plane,
>   		return -EINVAL;
>   
>   	crtc_state =
> -		drm_atomic_get_existing_crtc_state(new_state->state,
> +		drm_atomic_get_existing_crtc_state(state,
>   						   new_state->crtc);
>   	if (WARN_ON(!crtc_state))
>   		return -EINVAL;
> diff --git a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
> index 8232104e598f..e6d7d0a04ddb 100644
> --- a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
> +++ b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
> @@ -371,7 +371,7 @@ static int ingenic_drm_plane_atomic_check(struct drm_plane *plane,
>   	if (!crtc)
>   		return 0;
>   
> -	crtc_state = drm_atomic_get_existing_crtc_state(new_plane_state->state,
> +	crtc_state = drm_atomic_get_existing_crtc_state(state,
>   							crtc);
>   	if (WARN_ON(!crtc_state))
>   		return -EINVAL;
> diff --git a/drivers/gpu/drm/ingenic/ingenic-ipu.c b/drivers/gpu/drm/ingenic/ingenic-ipu.c
> index 7394b0af1259..1e1b0fe095bd 100644
> --- a/drivers/gpu/drm/ingenic/ingenic-ipu.c
> +++ b/drivers/gpu/drm/ingenic/ingenic-ipu.c
> @@ -526,7 +526,7 @@ static int ingenic_ipu_plane_atomic_check(struct drm_plane *plane,
>   	if (!crtc)
>   		return 0;
>   
> -	crtc_state = drm_atomic_get_existing_crtc_state(new_plane_state->state, crtc);
> +	crtc_state = drm_atomic_get_existing_crtc_state(state, crtc);
>   	if (WARN_ON(!crtc_state))
>   		return -EINVAL;
>   
> diff --git a/drivers/gpu/drm/kmb/kmb_plane.c b/drivers/gpu/drm/kmb/kmb_plane.c
> index 909045b67b28..9a8cf2991fb4 100644
> --- a/drivers/gpu/drm/kmb/kmb_plane.c
> +++ b/drivers/gpu/drm/kmb/kmb_plane.c
> @@ -100,7 +100,7 @@ static int kmb_plane_atomic_check(struct drm_plane *plane,
>   		return -EINVAL;
>   	can_position = (plane->type == DRM_PLANE_TYPE_OVERLAY);
>   	crtc_state =
> -		drm_atomic_get_existing_crtc_state(new_plane_state->state,
> +		drm_atomic_get_existing_crtc_state(state,
>   						   new_plane_state->crtc);
>   	return drm_atomic_helper_check_plane_state(new_plane_state,
>   						   crtc_state,
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> index 31f1cc2085c7..37489a086ca8 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> @@ -160,7 +160,7 @@ static int mtk_plane_atomic_check(struct drm_plane *plane,
>   	if (ret)
>   		return ret;
>   
> -	crtc_state = drm_atomic_get_crtc_state(new_plane_state->state,
> +	crtc_state = drm_atomic_get_crtc_state(state,
>   					       new_plane_state->crtc);
>   	if (IS_ERR(crtc_state))
>   		return PTR_ERR(crtc_state);
> diff --git a/drivers/gpu/drm/meson/meson_overlay.c b/drivers/gpu/drm/meson/meson_overlay.c
> index 629ca303af25..93ba785de396 100644
> --- a/drivers/gpu/drm/meson/meson_overlay.c
> +++ b/drivers/gpu/drm/meson/meson_overlay.c
> @@ -174,7 +174,7 @@ static int meson_overlay_atomic_check(struct drm_plane *plane,
>   	if (!new_plane_state->crtc)
>   		return 0;
>   
> -	crtc_state = drm_atomic_get_crtc_state(new_plane_state->state,
> +	crtc_state = drm_atomic_get_crtc_state(state,
>   					       new_plane_state->crtc);
>   	if (IS_ERR(crtc_state))
>   		return PTR_ERR(crtc_state);
> diff --git a/drivers/gpu/drm/meson/meson_plane.c b/drivers/gpu/drm/meson/meson_plane.c
> index f8355cb2a2e1..e5d05b725ed6 100644
> --- a/drivers/gpu/drm/meson/meson_plane.c
> +++ b/drivers/gpu/drm/meson/meson_plane.c
> @@ -80,7 +80,7 @@ static int meson_plane_atomic_check(struct drm_plane *plane,
>   	if (!new_plane_state->crtc)
>   		return 0;
>   
> -	crtc_state = drm_atomic_get_crtc_state(new_plane_state->state,
> +	crtc_state = drm_atomic_get_crtc_state(state,
>   					       new_plane_state->crtc);
>   	if (IS_ERR(crtc_state))
>   		return PTR_ERR(crtc_state);
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
> index 9945d11bb6ed..d644044a2bbb 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
> @@ -964,7 +964,7 @@ static int dpu_plane_atomic_check(struct drm_plane *plane,
>   	uint32_t min_src_size, max_linewidth;
>   
>   	if (new_plane_state->crtc)
> -		crtc_state = drm_atomic_get_new_crtc_state(new_plane_state->state,
> +		crtc_state = drm_atomic_get_new_crtc_state(state,
>   							   new_plane_state->crtc);
>   
>   	min_scale = FRAC_16_16(1, pdpu->pipe_sblk->maxupscale);
> diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c b/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c
> index 45f7780da901..4aac6217a5ad 100644
> --- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c
> +++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c
> @@ -415,7 +415,7 @@ static int mdp5_plane_atomic_check(struct drm_plane *plane,
>   	if (!crtc)
>   		return 0;
>   
> -	crtc_state = drm_atomic_get_existing_crtc_state(new_plane_state->state,
> +	crtc_state = drm_atomic_get_existing_crtc_state(state,
>   							crtc);
>   	if (WARN_ON(!crtc_state))
>   		return -EINVAL;
> diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
> index 85b547dcf86d..18c0c0d7b4b6 100644
> --- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c
> +++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
> @@ -409,7 +409,7 @@ static int mxsfb_plane_atomic_check(struct drm_plane *plane,
>   	struct mxsfb_drm_private *mxsfb = to_mxsfb_drm_private(plane->dev);
>   	struct drm_crtc_state *crtc_state;
>   
> -	crtc_state = drm_atomic_get_new_crtc_state(plane_state->state,
> +	crtc_state = drm_atomic_get_new_crtc_state(state,
>   						   &mxsfb->crtc);
>   
>   	return drm_atomic_helper_check_plane_state(plane_state, crtc_state,
> diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c b/drivers/gpu/drm/omapdrm/omap_plane.c
> index 6bd384c79324..0df1d35504ad 100644
> --- a/drivers/gpu/drm/omapdrm/omap_plane.c
> +++ b/drivers/gpu/drm/omapdrm/omap_plane.c
> @@ -112,7 +112,7 @@ static int omap_plane_atomic_check(struct drm_plane *plane,
>   	if (WARN_ON(!new_plane_state->crtc))
>   		return 0;
>   
> -	crtc_state = drm_atomic_get_existing_crtc_state(new_plane_state->state,
> +	crtc_state = drm_atomic_get_existing_crtc_state(state,
>   							new_plane_state->crtc);
>   	/* we should have a crtc state if the plane is attached to a crtc */
>   	if (WARN_ON(!crtc_state))
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> index d96d42dfc6c7..01f6cb99e8ea 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> @@ -796,7 +796,7 @@ static int vop_plane_atomic_check(struct drm_plane *plane,
>   	if (!crtc || WARN_ON(!fb))
>   		return 0;
>   
> -	crtc_state = drm_atomic_get_existing_crtc_state(new_plane_state->state,
> +	crtc_state = drm_atomic_get_existing_crtc_state(state,
>   							crtc);
>   	if (WARN_ON(!crtc_state))
>   		return -EINVAL;
> diff --git a/drivers/gpu/drm/sti/sti_cursor.c b/drivers/gpu/drm/sti/sti_cursor.c
> index ceb30d545ab9..e34ab8317f6d 100644
> --- a/drivers/gpu/drm/sti/sti_cursor.c
> +++ b/drivers/gpu/drm/sti/sti_cursor.c
> @@ -198,7 +198,7 @@ static int sti_cursor_atomic_check(struct drm_plane *drm_plane,
>   	if (!crtc || !fb)
>   		return 0;
>   
> -	crtc_state = drm_atomic_get_crtc_state(new_plane_state->state, crtc);
> +	crtc_state = drm_atomic_get_crtc_state(state, crtc);
>   	mode = &crtc_state->mode;
>   	dst_x = new_plane_state->crtc_x;
>   	dst_y = new_plane_state->crtc_y;
> diff --git a/drivers/gpu/drm/sti/sti_gdp.c b/drivers/gpu/drm/sti/sti_gdp.c
> index 63823827417c..f64eef90dc58 100644
> --- a/drivers/gpu/drm/sti/sti_gdp.c
> +++ b/drivers/gpu/drm/sti/sti_gdp.c
> @@ -635,7 +635,7 @@ static int sti_gdp_atomic_check(struct drm_plane *drm_plane,
>   		return 0;
>   
>   	mixer = to_sti_mixer(crtc);
> -	crtc_state = drm_atomic_get_crtc_state(new_plane_state->state, crtc);
> +	crtc_state = drm_atomic_get_crtc_state(state, crtc);
>   	mode = &crtc_state->mode;
>   	dst_x = new_plane_state->crtc_x;
>   	dst_y = new_plane_state->crtc_y;
> diff --git a/drivers/gpu/drm/sti/sti_hqvdp.c b/drivers/gpu/drm/sti/sti_hqvdp.c
> index b3b10ee96bb2..c1a2450beed4 100644
> --- a/drivers/gpu/drm/sti/sti_hqvdp.c
> +++ b/drivers/gpu/drm/sti/sti_hqvdp.c
> @@ -1034,7 +1034,7 @@ static int sti_hqvdp_atomic_check(struct drm_plane *drm_plane,
>   	if (!crtc || !fb)
>   		return 0;
>   
> -	crtc_state = drm_atomic_get_crtc_state(new_plane_state->state, crtc);
> +	crtc_state = drm_atomic_get_crtc_state(state, crtc);
>   	mode = &crtc_state->mode;
>   	dst_x = new_plane_state->crtc_x;
>   	dst_y = new_plane_state->crtc_y;
> diff --git a/drivers/gpu/drm/sun4i/sun8i_ui_layer.c b/drivers/gpu/drm/sun4i/sun8i_ui_layer.c
> index b5fb50e72868..bb60419868f9 100644
> --- a/drivers/gpu/drm/sun4i/sun8i_ui_layer.c
> +++ b/drivers/gpu/drm/sun4i/sun8i_ui_layer.c
> @@ -269,7 +269,7 @@ static int sun8i_ui_layer_atomic_check(struct drm_plane *plane,
>   	if (!crtc)
>   		return 0;
>   
> -	crtc_state = drm_atomic_get_existing_crtc_state(new_plane_state->state,
> +	crtc_state = drm_atomic_get_existing_crtc_state(state,
>   							crtc);
>   	if (WARN_ON(!crtc_state))
>   		return -EINVAL;
> diff --git a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c b/drivers/gpu/drm/sun4i/sun8i_vi_layer.c
> index 85c2927755a4..0c7bb36f1bce 100644
> --- a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c
> +++ b/drivers/gpu/drm/sun4i/sun8i_vi_layer.c
> @@ -373,7 +373,7 @@ static int sun8i_vi_layer_atomic_check(struct drm_plane *plane,
>   	if (!crtc)
>   		return 0;
>   
> -	crtc_state = drm_atomic_get_existing_crtc_state(new_plane_state->state,
> +	crtc_state = drm_atomic_get_existing_crtc_state(state,
>   							crtc);
>   	if (WARN_ON(!crtc_state))
>   		return -EINVAL;
> diff --git a/drivers/gpu/drm/tidss/tidss_plane.c b/drivers/gpu/drm/tidss/tidss_plane.c
> index 980b65725d66..9b531e625ec9 100644
> --- a/drivers/gpu/drm/tidss/tidss_plane.c
> +++ b/drivers/gpu/drm/tidss/tidss_plane.c
> @@ -44,7 +44,7 @@ static int tidss_plane_atomic_check(struct drm_plane *plane,
>   		return 0;
>   	}
>   
> -	crtc_state = drm_atomic_get_crtc_state(new_plane_state->state,
> +	crtc_state = drm_atomic_get_crtc_state(state,
>   					       new_plane_state->crtc);
>   	if (IS_ERR(crtc_state))
>   		return PTR_ERR(crtc_state);
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_plane.c b/drivers/gpu/drm/tilcdc/tilcdc_plane.c
> index f43670aff5ad..ebdd42dcaf82 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_plane.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_plane.c
> @@ -41,7 +41,7 @@ static int tilcdc_plane_atomic_check(struct drm_plane *plane,
>   		return -EINVAL;
>   	}
>   
> -	crtc_state = drm_atomic_get_existing_crtc_state(new_state->state,
> +	crtc_state = drm_atomic_get_existing_crtc_state(state,
>   							new_state->crtc);
>   	/* we should have a crtc state if the plane is attached to a crtc */
>   	if (WARN_ON(!crtc_state))
> diff --git a/drivers/gpu/drm/vboxvideo/vbox_mode.c b/drivers/gpu/drm/vboxvideo/vbox_mode.c
> index 7140086d8308..c8e1a37e839c 100644
> --- a/drivers/gpu/drm/vboxvideo/vbox_mode.c
> +++ b/drivers/gpu/drm/vboxvideo/vbox_mode.c
> @@ -260,8 +260,8 @@ static int vbox_primary_atomic_check(struct drm_plane *plane,
>   	struct drm_crtc_state *crtc_state = NULL;
>   
>   	if (new_state->crtc) {
> -		crtc_state = drm_atomic_get_existing_crtc_state(
> -					    new_state->state, new_state->crtc);
> +		crtc_state = drm_atomic_get_existing_crtc_state(state,
> +								new_state->crtc);
>   		if (WARN_ON(!crtc_state))
>   			return -EINVAL;
>   	}
> @@ -338,8 +338,8 @@ static int vbox_cursor_atomic_check(struct drm_plane *plane,
>   	int ret;
>   
>   	if (new_state->crtc) {
> -		crtc_state = drm_atomic_get_existing_crtc_state(
> -					    new_state->state, new_state->crtc);
> +		crtc_state = drm_atomic_get_existing_crtc_state(state,
> +								new_state->crtc);
>   		if (WARN_ON(!crtc_state))
>   			return -EINVAL;
>   	}
> diff --git a/drivers/gpu/drm/virtio/virtgpu_plane.c b/drivers/gpu/drm/virtio/virtgpu_plane.c
> index 0f4fdd8c28f9..9419aa611af9 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_plane.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_plane.c
> @@ -94,7 +94,7 @@ static int virtio_gpu_plane_atomic_check(struct drm_plane *plane,
>   	if (!new_plane_state->fb || WARN_ON(!new_plane_state->crtc))
>   		return 0;
>   
> -	crtc_state = drm_atomic_get_crtc_state(new_plane_state->state,
> +	crtc_state = drm_atomic_get_crtc_state(state,
>   					       new_plane_state->crtc);
>   	if (IS_ERR(crtc_state))
>                   return PTR_ERR(crtc_state);
> diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c
> index 751695a76e26..2f2ab3c01bf9 100644
> --- a/drivers/gpu/drm/vkms/vkms_plane.c
> +++ b/drivers/gpu/drm/vkms/vkms_plane.c
> @@ -125,7 +125,7 @@ static int vkms_plane_atomic_check(struct drm_plane *plane,
>   	if (!new_plane_state->fb || WARN_ON(!new_plane_state->crtc))
>   		return 0;
>   
> -	crtc_state = drm_atomic_get_crtc_state(new_plane_state->state,
> +	crtc_state = drm_atomic_get_crtc_state(state,
>   					       new_plane_state->crtc);
>   	if (IS_ERR(crtc_state))
>   		return PTR_ERR(crtc_state);
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> index 5be1e4bd8a5f..d6487376838f 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> @@ -446,7 +446,7 @@ int vmw_du_primary_plane_atomic_check(struct drm_plane *plane,
>   	int ret;
>   
>   	if (new_state->crtc)
> -		crtc_state = drm_atomic_get_new_crtc_state(new_state->state,
> +		crtc_state = drm_atomic_get_new_crtc_state(state,
>   							   new_state->crtc);
>   
>   	ret = drm_atomic_helper_check_plane_state(new_state, crtc_state,
> diff --git a/drivers/gpu/drm/xlnx/zynqmp_disp.c b/drivers/gpu/drm/xlnx/zynqmp_disp.c
> index b0a3ba528718..27c0b849598b 100644
> --- a/drivers/gpu/drm/xlnx/zynqmp_disp.c
> +++ b/drivers/gpu/drm/xlnx/zynqmp_disp.c
> @@ -1152,8 +1152,7 @@ zynqmp_disp_plane_atomic_check(struct drm_plane *plane,
>   	if (!new_plane_state->crtc)
>   		return 0;
>   
> -	crtc_state = drm_atomic_get_crtc_state(new_plane_state->state,
> -					       new_plane_state->crtc);
> +	crtc_state = drm_atomic_get_crtc_state(state, new_plane_state->crtc);
>   	if (IS_ERR(crtc_state))
>   		return PTR_ERR(crtc_state);
>   
> diff --git a/drivers/gpu/drm/zte/zx_plane.c b/drivers/gpu/drm/zte/zx_plane.c
> index 20ac29212991..1d5d35bda249 100644
> --- a/drivers/gpu/drm/zte/zx_plane.c
> +++ b/drivers/gpu/drm/zte/zx_plane.c
> @@ -59,7 +59,7 @@ static int zx_vl_plane_atomic_check(struct drm_plane *plane,
>   	if (!crtc || WARN_ON(!fb))
>   		return 0;
>   
> -	crtc_state = drm_atomic_get_existing_crtc_state(plane_state->state,
> +	crtc_state = drm_atomic_get_existing_crtc_state(state,
>   							crtc);
>   	if (WARN_ON(!crtc_state))
>   		return -EINVAL;
> @@ -288,7 +288,7 @@ static int zx_gl_plane_atomic_check(struct drm_plane *plane,
>   	if (!crtc || WARN_ON(!fb))
>   		return 0;
>   
> -	crtc_state = drm_atomic_get_existing_crtc_state(plane_state->state,
> +	crtc_state = drm_atomic_get_existing_crtc_state(state,
>   							crtc);
>   	if (WARN_ON(!crtc_state))
>   		return -EINVAL;
>
Thomas Zimmermann Feb. 24, 2021, 11:33 a.m. UTC | #2
Hi Maxime,

for the whole series:

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

Am 19.02.21 um 13:00 schrieb Maxime Ripard:
> The current atomic helpers have either their object state being passed as
> an argument or the full atomic state.
> 
> The former is the pattern that was done at first, before switching to the
> latter for new hooks or when it was needed.
> 
> Let's start convert all the remaining helpers to provide a consistent
> interface, starting with the planes atomic_async_check and
> atomic_async_update.
> 
> The conversion was done using the coccinelle script below, built tested on
> all the drivers.
> 
> @@
> identifier plane, plane_state;
> symbol state;
> @@
> 
>   struct drm_plane_helper_funcs {
>   	...
> 	int (*atomic_async_check)(struct drm_plane *plane,
> -				  struct drm_plane_state *plane_state);
> +				  struct drm_atomic_state *state);
> 	...
>   }
> 
> @@
> identifier plane, plane_state;
> symbol state;
> @@
>   struct drm_plane_helper_funcs {
>   	...
> 	void (*atomic_async_update)(struct drm_plane *plane,
> -				    struct drm_plane_state *plane_state);
> +				    struct drm_atomic_state *state);
> 	...
>   }
> 
> @ plane_atomic_func @
> identifier helpers;
> identifier func;
> @@
> 
> (
>   static const struct drm_plane_helper_funcs helpers = {
> 	...,
>   	.atomic_async_check = func,
> 	...,
>   };
> |
>   static const struct drm_plane_helper_funcs helpers = {
>   	...,
>   	.atomic_async_update = func,
>   	...,
>   };
> )
> 
> @@
> struct drm_plane_helper_funcs *FUNCS;
> identifier f;
> identifier dev;
> identifier plane, plane_state, state;
> @@
> 
>   f(struct drm_device *dev, struct drm_atomic_state *state)
>   {
>   	<+...
> -	FUNCS->atomic_async_check(plane, plane_state)
> +	FUNCS->atomic_async_check(plane, state)
>   	...+>
>   }
> 
> @@
> struct drm_plane_helper_funcs *FUNCS;
> identifier f;
> identifier dev;
> identifier plane, plane_state, state;
> @@
> 
>   f(struct drm_device *dev, struct drm_atomic_state *state)
>   {
>   	<+...
> -	FUNCS->atomic_async_update(plane, plane_state)
> +	FUNCS->atomic_async_update(plane, state)
>   	...+>
>   }
> 
> @@
> identifier mtk_plane_atomic_async_update;
> identifier plane;
> symbol new_state, state;
> expression e;
> @@
> 
>    void mtk_plane_atomic_async_update(struct drm_plane *plane, struct drm_plane_state *new_state)
> {
>    ...
> - struct mtk_plane_state *state = e;
> + struct mtk_plane_state *new_plane_state = e;
>    <+...
> -       state
> +       new_plane_state
>    ...+>
>    }
> 
> @@
> identifier plane_atomic_func.func;
> identifier plane;
> symbol state;
> @@
> 
>   func(struct drm_plane *plane,
> -    struct drm_plane_state *state)
> +    struct drm_plane_state *new_plane_state)
>   {
> 	<...
> -	state
> +	new_plane_state
> 	...>
>   }
> 
> @ ignores_new_state @
> identifier plane_atomic_func.func;
> identifier plane, new_plane_state;
> @@
> 
>   func(struct drm_plane *plane, struct drm_plane_state *new_plane_state)
>   {
> 	... when != new_plane_state
>   }
> 
> @ adds_new_state depends on plane_atomic_func && !ignores_new_state @
> identifier plane_atomic_func.func;
> identifier plane, new_plane_state;
> @@
> 
>   func(struct drm_plane *plane, struct drm_plane_state *new_plane_state)
>   {
> +	struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state, plane);
>   	...
>   }
> 
> @ depends on plane_atomic_func @
> identifier plane_atomic_func.func;
> identifier plane, plane_state;
> @@
> 
>   func(struct drm_plane *plane,
> -     struct drm_plane_state *plane_state
> +     struct drm_atomic_state *state
>       )
>   { ... }
> 
> @ include depends on adds_new_state @
> @@
> 
>   #include <drm/drm_atomic.h>
> 
> @ no_include depends on !include && adds_new_state @
> @@
> 
> + #include <drm/drm_atomic.h>
>    #include <drm/...>
> 
> @@
> identifier plane_atomic_func.func;
> identifier plane, state;
> identifier plane_state;
> @@
> 
>   func(struct drm_plane *plane, struct drm_atomic_state *state) {
>          ...
>          struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane);
>          <+...
> -       plane_state->state
> +       state
>          ...+>
>   }
> 
> Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> 
> ---
> 
> Changes from v1:
>    - Updated the comment according to Thomas suggestions
> ---
>   .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  8 ++-
>   drivers/gpu/drm/drm_atomic_helper.c           |  4 +-
>   drivers/gpu/drm/mediatek/mtk_drm_plane.c      | 26 +++++----
>   drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c    | 33 ++++++-----
>   drivers/gpu/drm/rockchip/rockchip_drm_vop.c   | 16 ++++--
>   drivers/gpu/drm/vc4/vc4_plane.c               | 56 ++++++++++---------
>   include/drm/drm_modeset_helper_vtables.h      | 18 +++---
>   7 files changed, 89 insertions(+), 72 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index 6ed96633425f..63f839679a0a 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -6468,7 +6468,7 @@ static int dm_plane_atomic_check(struct drm_plane *plane,
>   }
>   
>   static int dm_plane_atomic_async_check(struct drm_plane *plane,
> -				       struct drm_plane_state *new_plane_state)
> +				       struct drm_atomic_state *state)
>   {
>   	/* Only support async updates on cursor planes. */
>   	if (plane->type != DRM_PLANE_TYPE_CURSOR)
> @@ -6478,10 +6478,12 @@ static int dm_plane_atomic_async_check(struct drm_plane *plane,
>   }
>   
>   static void dm_plane_atomic_async_update(struct drm_plane *plane,
> -					 struct drm_plane_state *new_state)
> +					 struct drm_atomic_state *state)
>   {
> +	struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
> +									   plane);
>   	struct drm_plane_state *old_state =
> -		drm_atomic_get_old_plane_state(new_state->state, plane);
> +		drm_atomic_get_old_plane_state(state, plane);
>   
>   	trace_amdgpu_dm_atomic_update_cursor(new_state);
>   
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> index 9fa3f97223a1..bd0bb74437c7 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -1742,7 +1742,7 @@ int drm_atomic_helper_async_check(struct drm_device *dev,
>   		return -EBUSY;
>   	}
>   
> -	return funcs->atomic_async_check(plane, new_plane_state);
> +	return funcs->atomic_async_check(plane, state);
>   }
>   EXPORT_SYMBOL(drm_atomic_helper_async_check);
>   
> @@ -1772,7 +1772,7 @@ void drm_atomic_helper_async_commit(struct drm_device *dev,
>   		struct drm_framebuffer *old_fb = plane->state->fb;
>   
>   		funcs = plane->helper_private;
> -		funcs->atomic_async_update(plane, plane_state);
> +		funcs->atomic_async_update(plane, state);
>   
>   		/*
>   		 * ->atomic_async_update() is supposed to update the
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> index 92141a19681b..30ebcfd8832f 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> @@ -77,12 +77,14 @@ static void mtk_drm_plane_destroy_state(struct drm_plane *plane,
>   }
>   
>   static int mtk_plane_atomic_async_check(struct drm_plane *plane,
> -					struct drm_plane_state *state)
> +					struct drm_atomic_state *state)
>   {
> +	struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
> +										 plane);
>   	struct drm_crtc_state *crtc_state;
>   	int ret;
>   
> -	if (plane != state->crtc->cursor)
> +	if (plane != new_plane_state->crtc->cursor)
>   		return -EINVAL;
>   
>   	if (!plane->state)
> @@ -91,16 +93,16 @@ static int mtk_plane_atomic_async_check(struct drm_plane *plane,
>   	if (!plane->state->fb)
>   		return -EINVAL;
>   
> -	ret = mtk_drm_crtc_plane_check(state->crtc, plane,
> -				       to_mtk_plane_state(state));
> +	ret = mtk_drm_crtc_plane_check(new_plane_state->crtc, plane,
> +				       to_mtk_plane_state(new_plane_state));
>   	if (ret)
>   		return ret;
>   
> -	if (state->state)
> -		crtc_state = drm_atomic_get_existing_crtc_state(state->state,
> -								state->crtc);
> +	if (state)
> +		crtc_state = drm_atomic_get_existing_crtc_state(state,
> +								new_plane_state->crtc);
>   	else /* Special case for asynchronous cursor updates. */
> -		crtc_state = state->crtc->state;
> +		crtc_state = new_plane_state->crtc->state;
>   
>   	return drm_atomic_helper_check_plane_state(plane->state, crtc_state,
>   						   DRM_PLANE_HELPER_NO_SCALING,
> @@ -109,9 +111,11 @@ static int mtk_plane_atomic_async_check(struct drm_plane *plane,
>   }
>   
>   static void mtk_plane_atomic_async_update(struct drm_plane *plane,
> -					  struct drm_plane_state *new_state)
> +					  struct drm_atomic_state *state)
>   {
> -	struct mtk_plane_state *state = to_mtk_plane_state(plane->state);
> +	struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
> +									   plane);
> +	struct mtk_plane_state *new_plane_state = to_mtk_plane_state(plane->state);
>   
>   	plane->state->crtc_x = new_state->crtc_x;
>   	plane->state->crtc_y = new_state->crtc_y;
> @@ -122,7 +126,7 @@ static void mtk_plane_atomic_async_update(struct drm_plane *plane,
>   	plane->state->src_h = new_state->src_h;
>   	plane->state->src_w = new_state->src_w;
>   	swap(plane->state->fb, new_state->fb);
> -	state->pending.async_dirty = true;
> +	new_plane_state->pending.async_dirty = true;
>   
>   	mtk_drm_crtc_async_update(new_state->crtc, plane, new_state);
>   }
> diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c b/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c
> index 83423092de2f..05fa8255caeb 100644
> --- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c
> +++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c
> @@ -5,6 +5,7 @@
>    * Author: Rob Clark <robdclark@gmail.com>
>    */
>   
> +#include <drm/drm_atomic.h>
>   #include <drm/drm_damage_helper.h>
>   #include <drm/drm_fourcc.h>
>   #include <drm/drm_print.h>
> @@ -438,41 +439,43 @@ static void mdp5_plane_atomic_update(struct drm_plane *plane,
>   }
>   
>   static int mdp5_plane_atomic_async_check(struct drm_plane *plane,
> -					 struct drm_plane_state *state)
> +					 struct drm_atomic_state *state)
>   {
> -	struct mdp5_plane_state *mdp5_state = to_mdp5_plane_state(state);
> +	struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
> +										 plane);
> +	struct mdp5_plane_state *mdp5_state = to_mdp5_plane_state(new_plane_state);
>   	struct drm_crtc_state *crtc_state;
>   	int min_scale, max_scale;
>   	int ret;
>   
> -	crtc_state = drm_atomic_get_existing_crtc_state(state->state,
> -							state->crtc);
> +	crtc_state = drm_atomic_get_existing_crtc_state(state,
> +							new_plane_state->crtc);
>   	if (WARN_ON(!crtc_state))
>   		return -EINVAL;
>   
>   	if (!crtc_state->active)
>   		return -EINVAL;
>   
> -	mdp5_state = to_mdp5_plane_state(state);
> +	mdp5_state = to_mdp5_plane_state(new_plane_state);
>   
>   	/* don't use fast path if we don't have a hwpipe allocated yet */
>   	if (!mdp5_state->hwpipe)
>   		return -EINVAL;
>   
>   	/* only allow changing of position(crtc x/y or src x/y) in fast path */
> -	if (plane->state->crtc != state->crtc ||
> -	    plane->state->src_w != state->src_w ||
> -	    plane->state->src_h != state->src_h ||
> -	    plane->state->crtc_w != state->crtc_w ||
> -	    plane->state->crtc_h != state->crtc_h ||
> +	if (plane->state->crtc != new_plane_state->crtc ||
> +	    plane->state->src_w != new_plane_state->src_w ||
> +	    plane->state->src_h != new_plane_state->src_h ||
> +	    plane->state->crtc_w != new_plane_state->crtc_w ||
> +	    plane->state->crtc_h != new_plane_state->crtc_h ||
>   	    !plane->state->fb ||
> -	    plane->state->fb != state->fb)
> +	    plane->state->fb != new_plane_state->fb)
>   		return -EINVAL;
>   
>   	min_scale = FRAC_16_16(1, 8);
>   	max_scale = FRAC_16_16(8, 1);
>   
> -	ret = drm_atomic_helper_check_plane_state(state, crtc_state,
> +	ret = drm_atomic_helper_check_plane_state(new_plane_state, crtc_state,
>   						  min_scale, max_scale,
>   						  true, true);
>   	if (ret)
> @@ -485,15 +488,17 @@ static int mdp5_plane_atomic_async_check(struct drm_plane *plane,
>   	 * also assign/unassign the hwpipe(s) tied to the plane. We avoid
>   	 * taking the fast path for both these reasons.
>   	 */
> -	if (state->visible != plane->state->visible)
> +	if (new_plane_state->visible != plane->state->visible)
>   		return -EINVAL;
>   
>   	return 0;
>   }
>   
>   static void mdp5_plane_atomic_async_update(struct drm_plane *plane,
> -					   struct drm_plane_state *new_state)
> +					   struct drm_atomic_state *state)
>   {
> +	struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
> +									   plane);
>   	struct drm_framebuffer *old_fb = plane->state->fb;
>   
>   	plane->state->src_x = new_state->src_x;
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> index 8d15cabdcb02..fefeab73ca27 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> @@ -1021,8 +1021,10 @@ static void vop_plane_atomic_update(struct drm_plane *plane,
>   }
>   
>   static int vop_plane_atomic_async_check(struct drm_plane *plane,
> -					struct drm_plane_state *state)
> +					struct drm_atomic_state *state)
>   {
> +	struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
> +										 plane);
>   	struct vop_win *vop_win = to_vop_win(plane);
>   	const struct vop_win_data *win = vop_win->data;
>   	int min_scale = win->phy->scl ? FRAC_16_16(1, 8) :
> @@ -1031,7 +1033,7 @@ static int vop_plane_atomic_async_check(struct drm_plane *plane,
>   					DRM_PLANE_HELPER_NO_SCALING;
>   	struct drm_crtc_state *crtc_state;
>   
> -	if (plane != state->crtc->cursor)
> +	if (plane != new_plane_state->crtc->cursor)
>   		return -EINVAL;
>   
>   	if (!plane->state)
> @@ -1040,9 +1042,9 @@ static int vop_plane_atomic_async_check(struct drm_plane *plane,
>   	if (!plane->state->fb)
>   		return -EINVAL;
>   
> -	if (state->state)
> -		crtc_state = drm_atomic_get_existing_crtc_state(state->state,
> -								state->crtc);
> +	if (state)
> +		crtc_state = drm_atomic_get_existing_crtc_state(state,
> +								new_plane_state->crtc);
>   	else /* Special case for asynchronous cursor updates. */
>   		crtc_state = plane->crtc->state;
>   
> @@ -1052,8 +1054,10 @@ static int vop_plane_atomic_async_check(struct drm_plane *plane,
>   }
>   
>   static void vop_plane_atomic_async_update(struct drm_plane *plane,
> -					  struct drm_plane_state *new_state)
> +					  struct drm_atomic_state *state)
>   {
> +	struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
> +									   plane);
>   	struct vop *vop = to_vop(plane->state->crtc);
>   	struct drm_framebuffer *old_fb = plane->state->fb;
>   
> diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c
> index 6bd8260aa9f2..ff485e58d271 100644
> --- a/drivers/gpu/drm/vc4/vc4_plane.c
> +++ b/drivers/gpu/drm/vc4/vc4_plane.c
> @@ -1118,32 +1118,34 @@ void vc4_plane_async_set_fb(struct drm_plane *plane, struct drm_framebuffer *fb)
>   }
>   
>   static void vc4_plane_atomic_async_update(struct drm_plane *plane,
> -					  struct drm_plane_state *state)
> +					  struct drm_atomic_state *state)
>   {
> +	struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
> +										 plane);
>   	struct vc4_plane_state *vc4_state, *new_vc4_state;
>   
> -	swap(plane->state->fb, state->fb);
> -	plane->state->crtc_x = state->crtc_x;
> -	plane->state->crtc_y = state->crtc_y;
> -	plane->state->crtc_w = state->crtc_w;
> -	plane->state->crtc_h = state->crtc_h;
> -	plane->state->src_x = state->src_x;
> -	plane->state->src_y = state->src_y;
> -	plane->state->src_w = state->src_w;
> -	plane->state->src_h = state->src_h;
> -	plane->state->src_h = state->src_h;
> -	plane->state->alpha = state->alpha;
> -	plane->state->pixel_blend_mode = state->pixel_blend_mode;
> -	plane->state->rotation = state->rotation;
> -	plane->state->zpos = state->zpos;
> -	plane->state->normalized_zpos = state->normalized_zpos;
> -	plane->state->color_encoding = state->color_encoding;
> -	plane->state->color_range = state->color_range;
> -	plane->state->src = state->src;
> -	plane->state->dst = state->dst;
> -	plane->state->visible = state->visible;
> +	swap(plane->state->fb, new_plane_state->fb);
> +	plane->state->crtc_x = new_plane_state->crtc_x;
> +	plane->state->crtc_y = new_plane_state->crtc_y;
> +	plane->state->crtc_w = new_plane_state->crtc_w;
> +	plane->state->crtc_h = new_plane_state->crtc_h;
> +	plane->state->src_x = new_plane_state->src_x;
> +	plane->state->src_y = new_plane_state->src_y;
> +	plane->state->src_w = new_plane_state->src_w;
> +	plane->state->src_h = new_plane_state->src_h;
> +	plane->state->src_h = new_plane_state->src_h;
> +	plane->state->alpha = new_plane_state->alpha;
> +	plane->state->pixel_blend_mode = new_plane_state->pixel_blend_mode;
> +	plane->state->rotation = new_plane_state->rotation;
> +	plane->state->zpos = new_plane_state->zpos;
> +	plane->state->normalized_zpos = new_plane_state->normalized_zpos;
> +	plane->state->color_encoding = new_plane_state->color_encoding;
> +	plane->state->color_range = new_plane_state->color_range;
> +	plane->state->src = new_plane_state->src;
> +	plane->state->dst = new_plane_state->dst;
> +	plane->state->visible = new_plane_state->visible;
>   
> -	new_vc4_state = to_vc4_plane_state(state);
> +	new_vc4_state = to_vc4_plane_state(new_plane_state);
>   	vc4_state = to_vc4_plane_state(plane->state);
>   
>   	vc4_state->crtc_x = new_vc4_state->crtc_x;
> @@ -1187,23 +1189,25 @@ static void vc4_plane_atomic_async_update(struct drm_plane *plane,
>   }
>   
>   static int vc4_plane_atomic_async_check(struct drm_plane *plane,
> -					struct drm_plane_state *state)
> +					struct drm_atomic_state *state)
>   {
> +	struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
> +										 plane);
>   	struct vc4_plane_state *old_vc4_state, *new_vc4_state;
>   	int ret;
>   	u32 i;
>   
> -	ret = vc4_plane_mode_set(plane, state);
> +	ret = vc4_plane_mode_set(plane, new_plane_state);
>   	if (ret)
>   		return ret;
>   
>   	old_vc4_state = to_vc4_plane_state(plane->state);
> -	new_vc4_state = to_vc4_plane_state(state);
> +	new_vc4_state = to_vc4_plane_state(new_plane_state);
>   	if (old_vc4_state->dlist_count != new_vc4_state->dlist_count ||
>   	    old_vc4_state->pos0_offset != new_vc4_state->pos0_offset ||
>   	    old_vc4_state->pos2_offset != new_vc4_state->pos2_offset ||
>   	    old_vc4_state->ptr0_offset != new_vc4_state->ptr0_offset ||
> -	    vc4_lbm_size(plane->state) != vc4_lbm_size(state))
> +	    vc4_lbm_size(plane->state) != vc4_lbm_size(new_plane_state))
>   		return -EINVAL;
>   
>   	/* Only pos0, pos2 and ptr0 DWORDS can be updated in an async update
> diff --git a/include/drm/drm_modeset_helper_vtables.h b/include/drm/drm_modeset_helper_vtables.h
> index eb706342861d..2b4d085da450 100644
> --- a/include/drm/drm_modeset_helper_vtables.h
> +++ b/include/drm/drm_modeset_helper_vtables.h
> @@ -1292,9 +1292,9 @@ struct drm_plane_helper_funcs {
>   	/**
>   	 * @atomic_async_check:
>   	 *
> -	 * Drivers should set this function pointer to check if the plane state
> -	 * can be updated in a async fashion. Here async means "not vblank
> -	 * synchronized".
> +	 * Drivers should set this function pointer to check if the plane's
> +	 * atomic state can be updated in a async fashion. Here async means
> +	 * "not vblank synchronized".
>   	 *
>   	 * This hook is called by drm_atomic_async_check() to establish if a
>   	 * given update can be committed asynchronously, that is, if it can
> @@ -1306,7 +1306,7 @@ struct drm_plane_helper_funcs {
>   	 * can not be applied in asynchronous manner.
>   	 */
>   	int (*atomic_async_check)(struct drm_plane *plane,
> -				  struct drm_plane_state *state);
> +				  struct drm_atomic_state *state);
>   
>   	/**
>   	 * @atomic_async_update:
> @@ -1322,11 +1322,9 @@ struct drm_plane_helper_funcs {
>   	 * update won't happen if there is an outstanding commit modifying
>   	 * the same plane.
>   	 *
> -	 * Note that unlike &drm_plane_helper_funcs.atomic_update this hook
> -	 * takes the new &drm_plane_state as parameter. When doing async_update
> -	 * drivers shouldn't replace the &drm_plane_state but update the
> -	 * current one with the new plane configurations in the new
> -	 * plane_state.
> +	 * When doing async_update drivers shouldn't replace the
> +	 * &drm_plane_state but update the current one with the new plane
> +	 * configurations in the new plane_state.
>   	 *
>   	 * Drivers should also swap the framebuffers between current plane
>   	 * state (&drm_plane.state) and new_state.
> @@ -1345,7 +1343,7 @@ struct drm_plane_helper_funcs {
>   	 *    for deferring if needed, until a common solution is created.
>   	 */
>   	void (*atomic_async_update)(struct drm_plane *plane,
> -				    struct drm_plane_state *new_state);
> +				    struct drm_atomic_state *state);
>   };
>   
>   /**
>
Maxime Ripard Feb. 25, 2021, 7:08 a.m. UTC | #3
Hi,

On Wed, Feb 24, 2021 at 12:33:45PM +0100, Thomas Zimmermann wrote:
> Hi Maxime,
> 
> for the whole series:
> 
> Acked-by: Thomas Zimmermann <tzimmermann@suse.de>

Applied the whole series, thanks to everyone involved in the review,
it's been a pretty daunting one :)

Maxime
diff mbox series

Patch

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 6ed96633425f..63f839679a0a 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -6468,7 +6468,7 @@  static int dm_plane_atomic_check(struct drm_plane *plane,
 }
 
 static int dm_plane_atomic_async_check(struct drm_plane *plane,
-				       struct drm_plane_state *new_plane_state)
+				       struct drm_atomic_state *state)
 {
 	/* Only support async updates on cursor planes. */
 	if (plane->type != DRM_PLANE_TYPE_CURSOR)
@@ -6478,10 +6478,12 @@  static int dm_plane_atomic_async_check(struct drm_plane *plane,
 }
 
 static void dm_plane_atomic_async_update(struct drm_plane *plane,
-					 struct drm_plane_state *new_state)
+					 struct drm_atomic_state *state)
 {
+	struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+									   plane);
 	struct drm_plane_state *old_state =
-		drm_atomic_get_old_plane_state(new_state->state, plane);
+		drm_atomic_get_old_plane_state(state, plane);
 
 	trace_amdgpu_dm_atomic_update_cursor(new_state);
 
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index 9fa3f97223a1..bd0bb74437c7 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -1742,7 +1742,7 @@  int drm_atomic_helper_async_check(struct drm_device *dev,
 		return -EBUSY;
 	}
 
-	return funcs->atomic_async_check(plane, new_plane_state);
+	return funcs->atomic_async_check(plane, state);
 }
 EXPORT_SYMBOL(drm_atomic_helper_async_check);
 
@@ -1772,7 +1772,7 @@  void drm_atomic_helper_async_commit(struct drm_device *dev,
 		struct drm_framebuffer *old_fb = plane->state->fb;
 
 		funcs = plane->helper_private;
-		funcs->atomic_async_update(plane, plane_state);
+		funcs->atomic_async_update(plane, state);
 
 		/*
 		 * ->atomic_async_update() is supposed to update the
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
index 92141a19681b..30ebcfd8832f 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
@@ -77,12 +77,14 @@  static void mtk_drm_plane_destroy_state(struct drm_plane *plane,
 }
 
 static int mtk_plane_atomic_async_check(struct drm_plane *plane,
-					struct drm_plane_state *state)
+					struct drm_atomic_state *state)
 {
+	struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
+										 plane);
 	struct drm_crtc_state *crtc_state;
 	int ret;
 
-	if (plane != state->crtc->cursor)
+	if (plane != new_plane_state->crtc->cursor)
 		return -EINVAL;
 
 	if (!plane->state)
@@ -91,16 +93,16 @@  static int mtk_plane_atomic_async_check(struct drm_plane *plane,
 	if (!plane->state->fb)
 		return -EINVAL;
 
-	ret = mtk_drm_crtc_plane_check(state->crtc, plane,
-				       to_mtk_plane_state(state));
+	ret = mtk_drm_crtc_plane_check(new_plane_state->crtc, plane,
+				       to_mtk_plane_state(new_plane_state));
 	if (ret)
 		return ret;
 
-	if (state->state)
-		crtc_state = drm_atomic_get_existing_crtc_state(state->state,
-								state->crtc);
+	if (state)
+		crtc_state = drm_atomic_get_existing_crtc_state(state,
+								new_plane_state->crtc);
 	else /* Special case for asynchronous cursor updates. */
-		crtc_state = state->crtc->state;
+		crtc_state = new_plane_state->crtc->state;
 
 	return drm_atomic_helper_check_plane_state(plane->state, crtc_state,
 						   DRM_PLANE_HELPER_NO_SCALING,
@@ -109,9 +111,11 @@  static int mtk_plane_atomic_async_check(struct drm_plane *plane,
 }
 
 static void mtk_plane_atomic_async_update(struct drm_plane *plane,
-					  struct drm_plane_state *new_state)
+					  struct drm_atomic_state *state)
 {
-	struct mtk_plane_state *state = to_mtk_plane_state(plane->state);
+	struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+									   plane);
+	struct mtk_plane_state *new_plane_state = to_mtk_plane_state(plane->state);
 
 	plane->state->crtc_x = new_state->crtc_x;
 	plane->state->crtc_y = new_state->crtc_y;
@@ -122,7 +126,7 @@  static void mtk_plane_atomic_async_update(struct drm_plane *plane,
 	plane->state->src_h = new_state->src_h;
 	plane->state->src_w = new_state->src_w;
 	swap(plane->state->fb, new_state->fb);
-	state->pending.async_dirty = true;
+	new_plane_state->pending.async_dirty = true;
 
 	mtk_drm_crtc_async_update(new_state->crtc, plane, new_state);
 }
diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c b/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c
index 83423092de2f..05fa8255caeb 100644
--- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c
+++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c
@@ -5,6 +5,7 @@ 
  * Author: Rob Clark <robdclark@gmail.com>
  */
 
+#include <drm/drm_atomic.h>
 #include <drm/drm_damage_helper.h>
 #include <drm/drm_fourcc.h>
 #include <drm/drm_print.h>
@@ -438,41 +439,43 @@  static void mdp5_plane_atomic_update(struct drm_plane *plane,
 }
 
 static int mdp5_plane_atomic_async_check(struct drm_plane *plane,
-					 struct drm_plane_state *state)
+					 struct drm_atomic_state *state)
 {
-	struct mdp5_plane_state *mdp5_state = to_mdp5_plane_state(state);
+	struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
+										 plane);
+	struct mdp5_plane_state *mdp5_state = to_mdp5_plane_state(new_plane_state);
 	struct drm_crtc_state *crtc_state;
 	int min_scale, max_scale;
 	int ret;
 
-	crtc_state = drm_atomic_get_existing_crtc_state(state->state,
-							state->crtc);
+	crtc_state = drm_atomic_get_existing_crtc_state(state,
+							new_plane_state->crtc);
 	if (WARN_ON(!crtc_state))
 		return -EINVAL;
 
 	if (!crtc_state->active)
 		return -EINVAL;
 
-	mdp5_state = to_mdp5_plane_state(state);
+	mdp5_state = to_mdp5_plane_state(new_plane_state);
 
 	/* don't use fast path if we don't have a hwpipe allocated yet */
 	if (!mdp5_state->hwpipe)
 		return -EINVAL;
 
 	/* only allow changing of position(crtc x/y or src x/y) in fast path */
-	if (plane->state->crtc != state->crtc ||
-	    plane->state->src_w != state->src_w ||
-	    plane->state->src_h != state->src_h ||
-	    plane->state->crtc_w != state->crtc_w ||
-	    plane->state->crtc_h != state->crtc_h ||
+	if (plane->state->crtc != new_plane_state->crtc ||
+	    plane->state->src_w != new_plane_state->src_w ||
+	    plane->state->src_h != new_plane_state->src_h ||
+	    plane->state->crtc_w != new_plane_state->crtc_w ||
+	    plane->state->crtc_h != new_plane_state->crtc_h ||
 	    !plane->state->fb ||
-	    plane->state->fb != state->fb)
+	    plane->state->fb != new_plane_state->fb)
 		return -EINVAL;
 
 	min_scale = FRAC_16_16(1, 8);
 	max_scale = FRAC_16_16(8, 1);
 
-	ret = drm_atomic_helper_check_plane_state(state, crtc_state,
+	ret = drm_atomic_helper_check_plane_state(new_plane_state, crtc_state,
 						  min_scale, max_scale,
 						  true, true);
 	if (ret)
@@ -485,15 +488,17 @@  static int mdp5_plane_atomic_async_check(struct drm_plane *plane,
 	 * also assign/unassign the hwpipe(s) tied to the plane. We avoid
 	 * taking the fast path for both these reasons.
 	 */
-	if (state->visible != plane->state->visible)
+	if (new_plane_state->visible != plane->state->visible)
 		return -EINVAL;
 
 	return 0;
 }
 
 static void mdp5_plane_atomic_async_update(struct drm_plane *plane,
-					   struct drm_plane_state *new_state)
+					   struct drm_atomic_state *state)
 {
+	struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+									   plane);
 	struct drm_framebuffer *old_fb = plane->state->fb;
 
 	plane->state->src_x = new_state->src_x;
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
index 8d15cabdcb02..fefeab73ca27 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -1021,8 +1021,10 @@  static void vop_plane_atomic_update(struct drm_plane *plane,
 }
 
 static int vop_plane_atomic_async_check(struct drm_plane *plane,
-					struct drm_plane_state *state)
+					struct drm_atomic_state *state)
 {
+	struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
+										 plane);
 	struct vop_win *vop_win = to_vop_win(plane);
 	const struct vop_win_data *win = vop_win->data;
 	int min_scale = win->phy->scl ? FRAC_16_16(1, 8) :
@@ -1031,7 +1033,7 @@  static int vop_plane_atomic_async_check(struct drm_plane *plane,
 					DRM_PLANE_HELPER_NO_SCALING;
 	struct drm_crtc_state *crtc_state;
 
-	if (plane != state->crtc->cursor)
+	if (plane != new_plane_state->crtc->cursor)
 		return -EINVAL;
 
 	if (!plane->state)
@@ -1040,9 +1042,9 @@  static int vop_plane_atomic_async_check(struct drm_plane *plane,
 	if (!plane->state->fb)
 		return -EINVAL;
 
-	if (state->state)
-		crtc_state = drm_atomic_get_existing_crtc_state(state->state,
-								state->crtc);
+	if (state)
+		crtc_state = drm_atomic_get_existing_crtc_state(state,
+								new_plane_state->crtc);
 	else /* Special case for asynchronous cursor updates. */
 		crtc_state = plane->crtc->state;
 
@@ -1052,8 +1054,10 @@  static int vop_plane_atomic_async_check(struct drm_plane *plane,
 }
 
 static void vop_plane_atomic_async_update(struct drm_plane *plane,
-					  struct drm_plane_state *new_state)
+					  struct drm_atomic_state *state)
 {
+	struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
+									   plane);
 	struct vop *vop = to_vop(plane->state->crtc);
 	struct drm_framebuffer *old_fb = plane->state->fb;
 
diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c
index 6bd8260aa9f2..ff485e58d271 100644
--- a/drivers/gpu/drm/vc4/vc4_plane.c
+++ b/drivers/gpu/drm/vc4/vc4_plane.c
@@ -1118,32 +1118,34 @@  void vc4_plane_async_set_fb(struct drm_plane *plane, struct drm_framebuffer *fb)
 }
 
 static void vc4_plane_atomic_async_update(struct drm_plane *plane,
-					  struct drm_plane_state *state)
+					  struct drm_atomic_state *state)
 {
+	struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
+										 plane);
 	struct vc4_plane_state *vc4_state, *new_vc4_state;
 
-	swap(plane->state->fb, state->fb);
-	plane->state->crtc_x = state->crtc_x;
-	plane->state->crtc_y = state->crtc_y;
-	plane->state->crtc_w = state->crtc_w;
-	plane->state->crtc_h = state->crtc_h;
-	plane->state->src_x = state->src_x;
-	plane->state->src_y = state->src_y;
-	plane->state->src_w = state->src_w;
-	plane->state->src_h = state->src_h;
-	plane->state->src_h = state->src_h;
-	plane->state->alpha = state->alpha;
-	plane->state->pixel_blend_mode = state->pixel_blend_mode;
-	plane->state->rotation = state->rotation;
-	plane->state->zpos = state->zpos;
-	plane->state->normalized_zpos = state->normalized_zpos;
-	plane->state->color_encoding = state->color_encoding;
-	plane->state->color_range = state->color_range;
-	plane->state->src = state->src;
-	plane->state->dst = state->dst;
-	plane->state->visible = state->visible;
+	swap(plane->state->fb, new_plane_state->fb);
+	plane->state->crtc_x = new_plane_state->crtc_x;
+	plane->state->crtc_y = new_plane_state->crtc_y;
+	plane->state->crtc_w = new_plane_state->crtc_w;
+	plane->state->crtc_h = new_plane_state->crtc_h;
+	plane->state->src_x = new_plane_state->src_x;
+	plane->state->src_y = new_plane_state->src_y;
+	plane->state->src_w = new_plane_state->src_w;
+	plane->state->src_h = new_plane_state->src_h;
+	plane->state->src_h = new_plane_state->src_h;
+	plane->state->alpha = new_plane_state->alpha;
+	plane->state->pixel_blend_mode = new_plane_state->pixel_blend_mode;
+	plane->state->rotation = new_plane_state->rotation;
+	plane->state->zpos = new_plane_state->zpos;
+	plane->state->normalized_zpos = new_plane_state->normalized_zpos;
+	plane->state->color_encoding = new_plane_state->color_encoding;
+	plane->state->color_range = new_plane_state->color_range;
+	plane->state->src = new_plane_state->src;
+	plane->state->dst = new_plane_state->dst;
+	plane->state->visible = new_plane_state->visible;
 
-	new_vc4_state = to_vc4_plane_state(state);
+	new_vc4_state = to_vc4_plane_state(new_plane_state);
 	vc4_state = to_vc4_plane_state(plane->state);
 
 	vc4_state->crtc_x = new_vc4_state->crtc_x;
@@ -1187,23 +1189,25 @@  static void vc4_plane_atomic_async_update(struct drm_plane *plane,
 }
 
 static int vc4_plane_atomic_async_check(struct drm_plane *plane,
-					struct drm_plane_state *state)
+					struct drm_atomic_state *state)
 {
+	struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
+										 plane);
 	struct vc4_plane_state *old_vc4_state, *new_vc4_state;
 	int ret;
 	u32 i;
 
-	ret = vc4_plane_mode_set(plane, state);
+	ret = vc4_plane_mode_set(plane, new_plane_state);
 	if (ret)
 		return ret;
 
 	old_vc4_state = to_vc4_plane_state(plane->state);
-	new_vc4_state = to_vc4_plane_state(state);
+	new_vc4_state = to_vc4_plane_state(new_plane_state);
 	if (old_vc4_state->dlist_count != new_vc4_state->dlist_count ||
 	    old_vc4_state->pos0_offset != new_vc4_state->pos0_offset ||
 	    old_vc4_state->pos2_offset != new_vc4_state->pos2_offset ||
 	    old_vc4_state->ptr0_offset != new_vc4_state->ptr0_offset ||
-	    vc4_lbm_size(plane->state) != vc4_lbm_size(state))
+	    vc4_lbm_size(plane->state) != vc4_lbm_size(new_plane_state))
 		return -EINVAL;
 
 	/* Only pos0, pos2 and ptr0 DWORDS can be updated in an async update
diff --git a/include/drm/drm_modeset_helper_vtables.h b/include/drm/drm_modeset_helper_vtables.h
index eb706342861d..2b4d085da450 100644
--- a/include/drm/drm_modeset_helper_vtables.h
+++ b/include/drm/drm_modeset_helper_vtables.h
@@ -1292,9 +1292,9 @@  struct drm_plane_helper_funcs {
 	/**
 	 * @atomic_async_check:
 	 *
-	 * Drivers should set this function pointer to check if the plane state
-	 * can be updated in a async fashion. Here async means "not vblank
-	 * synchronized".
+	 * Drivers should set this function pointer to check if the plane's
+	 * atomic state can be updated in a async fashion. Here async means
+	 * "not vblank synchronized".
 	 *
 	 * This hook is called by drm_atomic_async_check() to establish if a
 	 * given update can be committed asynchronously, that is, if it can
@@ -1306,7 +1306,7 @@  struct drm_plane_helper_funcs {
 	 * can not be applied in asynchronous manner.
 	 */
 	int (*atomic_async_check)(struct drm_plane *plane,
-				  struct drm_plane_state *state);
+				  struct drm_atomic_state *state);
 
 	/**
 	 * @atomic_async_update:
@@ -1322,11 +1322,9 @@  struct drm_plane_helper_funcs {
 	 * update won't happen if there is an outstanding commit modifying
 	 * the same plane.
 	 *
-	 * Note that unlike &drm_plane_helper_funcs.atomic_update this hook
-	 * takes the new &drm_plane_state as parameter. When doing async_update
-	 * drivers shouldn't replace the &drm_plane_state but update the
-	 * current one with the new plane configurations in the new
-	 * plane_state.
+	 * When doing async_update drivers shouldn't replace the
+	 * &drm_plane_state but update the current one with the new plane
+	 * configurations in the new plane_state.
 	 *
 	 * Drivers should also swap the framebuffers between current plane
 	 * state (&drm_plane.state) and new_state.
@@ -1345,7 +1343,7 @@  struct drm_plane_helper_funcs {
 	 *    for deferring if needed, until a common solution is created.
 	 */
 	void (*atomic_async_update)(struct drm_plane *plane,
-				    struct drm_plane_state *new_state);
+				    struct drm_atomic_state *state);
 };
 
 /**