Skip to contentSkip to conversation

drm/atomic: Pass the full state to planes async atomic check and update

PATCH In review Maxime Ripard 5 participants 26 messages Feb 19, 2021 – May 4, 2021 Page 2 of 2

Subsystems (53)
lore
Share & tools
lore
#21 lore raw

Re: [PATCH v3 10/11] drm: Use state helper instead of the plane state pointer

In reply to Maxime Ripard
Quoted 27 lines · Maxime Ripard

Hi Stephen,

Quoted 14 lines · Stephen Boyd

Quoting Maxime Ripard (2021-03-30 08:35:27)

Quoted 13 lines

Hi Stephen,

Quoted 9 lines · Stephen Boyd

Trimming Cc list way down, sorry if that's too much.

Quoting Maxime Ripard (2021-02-19 04:00:30)

Quoted 4 lines

Many drivers reference the plane->state pointer in order to get the current plane state in their atomic_update or atomic_disable hooks, which would be the new plane state in the global atomic state since _swap_state happened when those hooks are run.

Does this mean drm_atomic_helper_swap_state()?

Quoted 8 lines
Quoted 6 lines

Yep. Previous to that call in drm_atomic_helper_commit, plane->state is the state currently programmed in the hardware, so the old state (that's the case you have with atomic_check for example)

Once drm_atomic_helper_swap_state has run, plane->state is now the state that needs to be programmed into the hardware, so the new state.

Ok, and I suppose that is called by drm_atomic_helper_commit()?

Quoted 8 lines

Yep :)

Quoted 3 lines

So presumably a modeset is causing this? I get the NULL pointer around the time we switch from the splash screen to the login screen. I think there's a modeset during that transition.

It's very likely yeah. I really don't get how that pointer could be null though :/

So I think I see what is going on.. the issue is the CRTC has changed, but not the plane, so there is no new-state for the plane.

But dpu_crtc_atomic_flush() iterates over all the attached planes, calling dpu_plane_restore() which leads into dpu_plane_atomic_update().. this is kinda dpu breaking the rules..

BR,
-R

#22 lore raw

Re: [PATCH v3 10/11] drm: Use state helper instead of the plane state pointer

Quoted 34 lines · Rob Clark
Quoted 33 lines · Maxime Ripard

Hi Stephen,

Quoted 14 lines · Stephen Boyd

Quoting Maxime Ripard (2021-03-30 08:35:27)

Quoted 13 lines

Hi Stephen,

Quoted 9 lines · Stephen Boyd

Trimming Cc list way down, sorry if that's too much.

Quoting Maxime Ripard (2021-02-19 04:00:30)

Quoted 4 lines

Many drivers reference the plane->state pointer in order to get the current plane state in their atomic_update or atomic_disable hooks, which would be the new plane state in the global atomic state since _swap_state happened when those hooks are run.

Does this mean drm_atomic_helper_swap_state()?

Quoted 8 lines
Quoted 6 lines

Yep. Previous to that call in drm_atomic_helper_commit, plane->state is the state currently programmed in the hardware, so the old state (that's the case you have with atomic_check for example)

Once drm_atomic_helper_swap_state has run, plane->state is now the state that needs to be programmed into the hardware, so the new state.

Ok, and I suppose that is called by drm_atomic_helper_commit()?

Yep :)

Quoted 3 lines

So presumably a modeset is causing this? I get the NULL pointer around the time we switch from the splash screen to the login screen. I think there's a modeset during that transition.

Quoted 5 lines
Quoted 2 lines

It's very likely yeah. I really don't get how that pointer could be null though :/

So I think I see what is going on.. the issue is the CRTC has changed, but not the plane, so there is no new-state for the plane.

Yeah you're not allowed to touch an object's hw state in ->atomic_commit without acquiring it's state in atomic_check. Otherwise the synchronization across commits that atomic helpers provides goes boom.

Quoted 3 lines

But dpu_crtc_atomic_flush() iterates over all the attached planes, calling dpu_plane_restore() which leads into dpu_plane_atomic_update().. this is kinda dpu breaking the rules..

You're probably missing a drm_atomic_add_affected_planes() somewhere. Without looking at the code at least, it might be that if you just blindly do that you take too many states by default and oversynchronize across multiple crtc, which isn't great. But better than getting the rules wrong :-)

Cheers, Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#23 lore raw

PATCH v3 11/11 drm/todo: Remove the drm_atomic_state todo item

In reply to Maxime Ripard

Only planes' prepare_fb and cleanup_fb, and encoders' atomic_check and atomic_mode_set hooks remain with an object state and not the global drm_atomic_state.

prepare_fb and cleanup_fb operate by design on a given state and depending on the calling site can operate on either the old or new state, so it doesn't really make much sense to convert them.

The encoders' atomic_check and atomic_mode_set operate on the CRTC and connector state connected to them since encoders don't have a state of their own. Without those state pointers, we would need to get the CRTC through the drm_connector_state crtc pointer.

However, in order to get the drm_connector_state pointer, we would need to get the connector itself and while usually we have a single connector connected to the encoder, we can't really get it from the encoder at the moment since it could be behind any number of bridges.

While this could be addressed by (for example) listing all the connectors and finding the one that has the encoder as its source, it feels like an unnecessary rework for something that is slowly getting replaced by bridges.

Since all the users that matter have been converted, let's remove the TODO item.

---

Changes from v1:
- New patch

---
 Documentation/gpu/todo.rst | 46 --------------------------------------
 1 file changed, 46 deletions(-)
Documentation/gpu/todo.rst +0 -46
index f872d3d33218..0631b9b323d5 100644
@@ -459,52 +459,6 @@ Contact: Emil Velikov, respective driver maintainers
 
 Level: Intermediate
 
-Plumb drm_atomic_state all over
--------------------------------
-
-Currently various atomic functions take just a single or a handful of
-object states (eg. plane state). While that single object state can
-suffice for some simple cases, we often have to dig out additional
-object states for dealing with various dependencies between the individual
-objects or the hardware they represent. The process of digging out the
-additional states is rather non-intuitive and error prone.
-
-To fix that most functions should rather take the overall
-drm_atomic_state as one of their parameters. The other parameters
-would generally be the object(s) we mainly want to interact with.
-
-For example, instead of
-
-.. code-block:: c
-
-   int (*atomic_check)(struct drm_plane *plane, struct drm_plane_state *state);
-
-we would have something like
-
-.. code-block:: c
-
-   int (*atomic_check)(struct drm_plane *plane, struct drm_atomic_state *state);
-
-The implementation can then trivially gain access to any required object
-state(s) via drm_atomic_get_plane_state(), drm_atomic_get_new_plane_state(),
-drm_atomic_get_old_plane_state(), and their equivalents for
-other object types.
-
-Additionally many drivers currently access the object->state pointer
-directly in their commit functions. That is not going to work if we
-eg. want to allow deeper commit pipelines as those pointers could
-then point to the states corresponding to a future commit instead of
-the current commit we're trying to process. Also non-blocking commits
-execute locklessly so there are serious concerns with dereferencing
-the object->state pointers without holding the locks that protect them.
-Use of drm_atomic_get_new_plane_state(), drm_atomic_get_old_plane_state(),
-etc. avoids these problems as well since they relate to a specific
-commit via the passed in drm_atomic_state.
-
-Contact: Ville Syrjälä, Daniel Vetter
-
-Level: Intermediate
-
 Use struct dma_buf_map throughout codebase
 ------------------------------------------
 
Signature · 6 lines
2.29.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
maintainer Acked-by on v3 1/11
#24 lore raw
In reply to Maxime Ripard

Hi Maxime,

for the whole series:

Am 19.02.21 um 13:00 schrieb Maxime Ripard:

Quoted 593 lines

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,

(quoted diff) +1 -1
-				  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,

(quoted diff) +1 -1
-				    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)
  {
  	<+...
(quoted diff) +1 -1
-	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)
  {
  	<+...
(quoted diff) +1 -1
-	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;
   <+...
(quoted diff) +1 -1
-       state
+       new_plane_state
   ...+>
   }

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

func(struct drm_plane *plane,

drivers/gpu/drm/mediatek/mtk_drm_plane.c +1 -1
-    struct drm_plane_state *state)
+    struct drm_plane_state *new_plane_state)
  {
	<...
(quoted diff) +1 -1
-	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)
  {
(quoted diff) +1 -0
+	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,

(quoted diff) +1 -1
-     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);
         <+...
(quoted diff) +1 -1
-       plane_state->state
+       state
         ...+>
  }

---

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(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +5 -3
index 6ed96633425f..63f839679a0a 100644
@@ -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);
 
drivers/gpu/drm/drm_atomic_helper.c +2 -2
index 9fa3f97223a1..bd0bb74437c7 100644
@@ -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
drivers/gpu/drm/mediatek/mtk_drm_plane.c +15 -11
index 92141a19681b..30ebcfd8832f 100644
@@ -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);
  }
drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c +19 -14
index 83423092de2f..05fa8255caeb 100644
@@ -5,6 +5,7 @@
   * Author: Rob Clark <[email protected]>
   */
 
+#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;
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +10 -6
index 8d15cabdcb02..fefeab73ca27 100644
@@ -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;
 
drivers/gpu/drm/vc4/vc4_plane.c +30 -26
index 6bd8260aa9f2..ff485e58d271 100644
@@ -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
include/drm/drm_modeset_helper_vtables.h +8 -10
index eb706342861d..2b4d085da450 100644
@@ -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);
  };
 
  /**
Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx