Skip to contentSkip to conversation

drm/atomic: integrate private objects with suspend/resume helpers

PATCH In review Benoit Parrot 4 participants 7 messages Mar 14, 2019 – Mar 25, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/atomic: integrate private objects with suspend/resume helpers

During a suspend cycle the atomic state is saved to be used during the restore cycle.

However the current state duplication logic does not duplicate private objects. This leads to state inconsistencies at resume time.

With private objects modeset lock now integrated, we can make sure that private object state are properly saved and restored.

---
 drivers/gpu/drm/drm_atomic_helper.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +16 -0
index 540a77a2ade9..b108021cc092 100644
@@ -3189,6 +3189,7 @@ drm_atomic_helper_duplicate_state(struct drm_device *dev,
 	struct drm_connector_list_iter conn_iter;
 	struct drm_plane *plane;
 	struct drm_crtc *crtc;
+	struct drm_private_obj *privobj;
 	int err = 0;
 
 	state = drm_atomic_state_alloc(dev);
@@ -3218,6 +3219,16 @@ drm_atomic_helper_duplicate_state(struct drm_device *dev,
 		}
 	}
 
+	drm_for_each_privobj(privobj, dev) {
+		struct drm_private_state *priv_state;
+
+		priv_state = drm_atomic_get_private_obj_state(state, privobj);
+		if (IS_ERR(priv_state)) {
+			err = PTR_ERR(priv_state);
+			goto free;
+		}
+	}
+
 	drm_connector_list_iter_begin(dev, &conn_iter);
 	drm_for_each_connector_iter(conn, &conn_iter) {
 		struct drm_connector_state *conn_state;
@@ -3325,12 +3336,17 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state,
 	struct drm_connector_state *new_conn_state;
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *new_crtc_state;
+	struct drm_private_obj *privobj;
+	struct drm_private_state *new_priv_state;
 
 	state->acquire_ctx = ctx;
 
 	for_each_new_plane_in_state(state, plane, new_plane_state, i)
 		state->planes[i].old_state = plane->state;
 
+	for_each_new_private_obj_in_state(state, privobj, new_priv_state, i)
+		state->private_objs[i].old_state = privobj->state;
+
 	for_each_new_crtc_in_state(state, crtc, new_crtc_state, i)
 		state->crtcs[i].old_state = crtc->state;
 
Signature · 6 lines
2.17.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 50 lines · Benoit Parrot

During a suspend cycle the atomic state is saved to be used during the restore cycle.

However the current state duplication logic does not duplicate private objects. This leads to state inconsistencies at resume time.

With private objects modeset lock now integrated, we can make sure that private object state are properly saved and restored.

---
 drivers/gpu/drm/drm_atomic_helper.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +13 -0
index 540a77a2ade9..b108021cc092 100644
@@ -3189,6 +3189,7 @@ drm_atomic_helper_duplicate_state(struct drm_device *dev,
 	struct drm_connector_list_iter conn_iter;
 	struct drm_plane *plane;
 	struct drm_crtc *crtc;
+	struct drm_private_obj *privobj;
 	int err = 0;
 
 	state = drm_atomic_state_alloc(dev);
@@ -3218,6 +3219,16 @@ drm_atomic_helper_duplicate_state(struct drm_device *dev,
 		}
 	}
 
+	drm_for_each_privobj(privobj, dev) {
+		struct drm_private_state *priv_state;
+
+		priv_state = drm_atomic_get_private_obj_state(state, privobj);
+		if (IS_ERR(priv_state)) {
+			err = PTR_ERR(priv_state);
+			goto free;
+		}
+	}
+
 	drm_connector_list_iter_begin(dev, &conn_iter);
 	drm_for_each_connector_iter(conn, &conn_iter) {
 		struct drm_connector_state *conn_state;
@@ -3325,12 +3336,17 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state,
 	struct drm_connector_state *new_conn_state;
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *new_crtc_state;
+	struct drm_private_obj *privobj;
+	struct drm_private_state *new_priv_state;
 

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state, · line 3351

Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +3 -0
 	state->acquire_ctx = ctx;
 
 	for_each_new_plane_in_state(state, plane, new_plane_state, i)
 		state->planes[i].old_state = plane->state;
 
+	for_each_new_private_obj_in_state(state, privobj, new_priv_state, i)
+		state->private_objs[i].old_state = privobj->state;
+
 	for_each_new_crtc_in_state(state, crtc, new_crtc_state, i)
 		state->crtcs[i].old_state = crtc->state;

Random order between crtc vs. plane vs. connector vs. priv is tickling my ocd nerve a bit.

Otherwise looks sensible to me.

Quoted 8 lines
Signature · 7 lines
-- 
2.17.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 2 lines
Ville Syrjälä
Intel
#2 lore raw

Ville Syrjälä <[email protected]> wrote on Thu [2019-Mar-14 17:31:29 +0200]:

Quoted 56 lines · Benoit Parrot
Quoted 55 lines

During a suspend cycle the atomic state is saved to be used during the restore cycle.

However the current state duplication logic does not duplicate private objects. This leads to state inconsistencies at resume time.

With private objects modeset lock now integrated, we can make sure that private object state are properly saved and restored.

---
 drivers/gpu/drm/drm_atomic_helper.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +13 -0
index 540a77a2ade9..b108021cc092 100644
@@ -3189,6 +3189,7 @@ drm_atomic_helper_duplicate_state(struct drm_device *dev,
 	struct drm_connector_list_iter conn_iter;
 	struct drm_plane *plane;
 	struct drm_crtc *crtc;
+	struct drm_private_obj *privobj;
 	int err = 0;
 
 	state = drm_atomic_state_alloc(dev);
@@ -3218,6 +3219,16 @@ drm_atomic_helper_duplicate_state(struct drm_device *dev,
 		}
 	}
 
+	drm_for_each_privobj(privobj, dev) {
+		struct drm_private_state *priv_state;
+
+		priv_state = drm_atomic_get_private_obj_state(state, privobj);
+		if (IS_ERR(priv_state)) {
+			err = PTR_ERR(priv_state);
+			goto free;
+		}
+	}
+
 	drm_connector_list_iter_begin(dev, &conn_iter);
 	drm_for_each_connector_iter(conn, &conn_iter) {
 		struct drm_connector_state *conn_state;
@@ -3325,12 +3336,17 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state,
 	struct drm_connector_state *new_conn_state;
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *new_crtc_state;
+	struct drm_private_obj *privobj;
+	struct drm_private_state *new_priv_state;
 
 	state->acquire_ctx = ctx;
 
 	for_each_new_plane_in_state(state, plane, new_plane_state, i)
 		state->planes[i].old_state = plane->state;
 
Quoted 8 lines

drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state, · line 3351

Quoted 5 lines
drivers/gpu/drm/drm_atomic_helper.c +3 -0
+	for_each_new_private_obj_in_state(state, privobj, new_priv_state, i)
+		state->private_objs[i].old_state = privobj->state;
+
 	for_each_new_crtc_in_state(state, crtc, new_crtc_state, i)
 		state->crtcs[i].old_state = crtc->state;

Random order between crtc vs. plane vs. connector vs. priv is tickling my ocd nerve a bit.

These loops are independent from each other.
And even without this patch the order is different between drm_atomic_helper_duplicate_state() and drm_atomic_helper_commit_duplicated_state(). :)

Benoit

Quoted 5 lines

Otherwise looks sensible to me.

Quoted 1 line
Quoted 11 lines
Quoted 7 lines
Signature · 6 lines
2.17.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 2 lines
Ville Syrjälä
Intel

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

Reviewed-by on v1 1/1
#3 lore raw
In reply to Benoit Parrot

Hi Benoit,

Thank you for the patch.

Quoted 10 lines · Benoit Parrot

During a suspend cycle the atomic state is saved to be used during the restore cycle.

However the current state duplication logic does not duplicate private objects. This leads to state inconsistencies at resume time.

With private objects modeset lock now integrated, we can make sure that private object state are properly saved and restored.

This looks good to me. I was actually wondering if private object state was properly handled by the suspend/resume helpers no later than yesterday. Seems you read my mind :-)

Quoted 51 lines
---
 drivers/gpu/drm/drm_atomic_helper.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +16 -0
index 540a77a2ade9..b108021cc092 100644
@@ -3189,6 +3189,7 @@ drm_atomic_helper_duplicate_state(struct drm_device *dev,
 	struct drm_connector_list_iter conn_iter;
 	struct drm_plane *plane;
 	struct drm_crtc *crtc;
+	struct drm_private_obj *privobj;
 	int err = 0;
 
 	state = drm_atomic_state_alloc(dev);
@@ -3218,6 +3219,16 @@ drm_atomic_helper_duplicate_state(struct drm_device *dev,
 		}
 	}
 
+	drm_for_each_privobj(privobj, dev) {
+		struct drm_private_state *priv_state;
+
+		priv_state = drm_atomic_get_private_obj_state(state, privobj);
+		if (IS_ERR(priv_state)) {
+			err = PTR_ERR(priv_state);
+			goto free;
+		}
+	}
+
 	drm_connector_list_iter_begin(dev, &conn_iter);
 	drm_for_each_connector_iter(conn, &conn_iter) {
 		struct drm_connector_state *conn_state;
@@ -3325,12 +3336,17 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state,
 	struct drm_connector_state *new_conn_state;
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *new_crtc_state;
+	struct drm_private_obj *privobj;
+	struct drm_private_state *new_priv_state;
 
 	state->acquire_ctx = ctx;
 
 	for_each_new_plane_in_state(state, plane, new_plane_state, i)
 		state->planes[i].old_state = plane->state;
 
+	for_each_new_private_obj_in_state(state, privobj, new_priv_state, i)
+		state->private_objs[i].old_state = privobj->state;
+
 	for_each_new_crtc_in_state(state, crtc, new_crtc_state, i)
 		state->crtcs[i].old_state = crtc->state;
 
Signature · 3 lines
Regards,

Laurent Pinchart
#4 lore raw
In reply to Benoit Parrot
Quoted 10 lines · Benoit Parrot

During a suspend cycle the atomic state is saved to be used during the restore cycle.

However the current state duplication logic does not duplicate private objects. This leads to state inconsistencies at resume time.

With private objects modeset lock now integrated, we can make sure that private object state are properly saved and restored.

Why do you need this? We're doing a full atomic_check, and your atomic_check should be pulling in any private state objects and recomputing their states. This smells like papering over a driver bug.

The duplicate helpers should only need to duplicate the uapi-relevant states, i.e. connector/crtc/planes.
-Daniel

Quoted 54 lines
---
 drivers/gpu/drm/drm_atomic_helper.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +16 -0
index 540a77a2ade9..b108021cc092 100644
@@ -3189,6 +3189,7 @@ drm_atomic_helper_duplicate_state(struct drm_device *dev,
 	struct drm_connector_list_iter conn_iter;
 	struct drm_plane *plane;
 	struct drm_crtc *crtc;
+	struct drm_private_obj *privobj;
 	int err = 0;
 
 	state = drm_atomic_state_alloc(dev);
@@ -3218,6 +3219,16 @@ drm_atomic_helper_duplicate_state(struct drm_device *dev,
 		}
 	}
 
+	drm_for_each_privobj(privobj, dev) {
+		struct drm_private_state *priv_state;
+
+		priv_state = drm_atomic_get_private_obj_state(state, privobj);
+		if (IS_ERR(priv_state)) {
+			err = PTR_ERR(priv_state);
+			goto free;
+		}
+	}
+
 	drm_connector_list_iter_begin(dev, &conn_iter);
 	drm_for_each_connector_iter(conn, &conn_iter) {
 		struct drm_connector_state *conn_state;
@@ -3325,12 +3336,17 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state,
 	struct drm_connector_state *new_conn_state;
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *new_crtc_state;
+	struct drm_private_obj *privobj;
+	struct drm_private_state *new_priv_state;
 
 	state->acquire_ctx = ctx;
 
 	for_each_new_plane_in_state(state, plane, new_plane_state, i)
 		state->planes[i].old_state = plane->state;
 
+	for_each_new_private_obj_in_state(state, privobj, new_priv_state, i)
+		state->private_objs[i].old_state = privobj->state;
+
 	for_each_new_crtc_in_state(state, crtc, new_crtc_state, i)
 		state->crtcs[i].old_state = crtc->state;
 
Signature · 1 line
2.17.1
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
#5 lore raw

Daniel Vetter <[email protected]> wrote on Fri [2019-Mar-15 11:50:57 +0100]:

Quoted 7 lines · Benoit Parrot
Quoted 6 lines

During a suspend cycle the atomic state is saved to be used during the restore cycle.

However the current state duplication logic does not duplicate private objects. This leads to state inconsistencies at resume time.

Quoted 8 lines
Quoted 4 lines

With private objects modeset lock now integrated, we can make sure that private object state are properly saved and restored.

Why do you need this? We're doing a full atomic_check, and your atomic_check should be pulling in any private state objects and recomputing their states. This smells like papering over a driver bug.

I have not seen any atomic_check called during the suspend duplicate helper. And you are correct normally the private_object state in my case would get pulled in during a plane atomic_check but that does not happen here in this step.

Why wouldn't we save all the "state" artifacts so that the whole atomic state is consistent?

Benoit

Quoted 64 lines

The duplicate helpers should only need to duplicate the uapi-relevant states, i.e. connector/crtc/planes.
-Daniel

Quoted 54 lines
---
 drivers/gpu/drm/drm_atomic_helper.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +16 -0
index 540a77a2ade9..b108021cc092 100644
@@ -3189,6 +3189,7 @@ drm_atomic_helper_duplicate_state(struct drm_device *dev,
 	struct drm_connector_list_iter conn_iter;
 	struct drm_plane *plane;
 	struct drm_crtc *crtc;
+	struct drm_private_obj *privobj;
 	int err = 0;
 
 	state = drm_atomic_state_alloc(dev);
@@ -3218,6 +3219,16 @@ drm_atomic_helper_duplicate_state(struct drm_device *dev,
 		}
 	}
 
+	drm_for_each_privobj(privobj, dev) {
+		struct drm_private_state *priv_state;
+
+		priv_state = drm_atomic_get_private_obj_state(state, privobj);
+		if (IS_ERR(priv_state)) {
+			err = PTR_ERR(priv_state);
+			goto free;
+		}
+	}
+
 	drm_connector_list_iter_begin(dev, &conn_iter);
 	drm_for_each_connector_iter(conn, &conn_iter) {
 		struct drm_connector_state *conn_state;
@@ -3325,12 +3336,17 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state,
 	struct drm_connector_state *new_conn_state;
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *new_crtc_state;
+	struct drm_private_obj *privobj;
+	struct drm_private_state *new_priv_state;
 
 	state->acquire_ctx = ctx;
 
 	for_each_new_plane_in_state(state, plane, new_plane_state, i)
 		state->planes[i].old_state = plane->state;
 
+	for_each_new_private_obj_in_state(state, privobj, new_priv_state, i)
+		state->private_objs[i].old_state = privobj->state;
+
 	for_each_new_crtc_in_state(state, crtc, new_crtc_state, i)
 		state->crtcs[i].old_state = crtc->state;
 
Signature · 1 line
2.17.1
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
#6 lore raw
Quoted 13 lines · Benoit Parrot

Daniel Vetter <[email protected]> wrote on Fri [2019-Mar-15 11:50:57 +0100]:

Quoted 12 lines · Benoit Parrot
Quoted 10 lines

During a suspend cycle the atomic state is saved to be used during the restore cycle.

However the current state duplication logic does not duplicate private objects. This leads to state inconsistencies at resume time.

With private objects modeset lock now integrated, we can make sure that private object state are properly saved and restored.

Quoted 8 lines
Quoted 3 lines

Why do you need this? We're doing a full atomic_check, and your atomic_check should be pulling in any private state objects and recomputing their states. This smells like papering over a driver bug.

I have not seen any atomic_check called during the suspend duplicate helper. And you are correct normally the private_object state in my case would get pulled in during a plane atomic_check but that does not happen here in this step.

Yeah duplicating in suspend won't call atomic_check. Restoring the duplicated state on resume will (or there's going to be lots of broken drivers).

Quoted 2 lines

Why wouldn't we save all the "state" artifacts so that the whole atomic state is consistent?

It's not needed, and might possible paper over driver bugs ...

Quoted 2 lines
Quoted 2 lines

The duplicate helpers should only need to duplicate the uapi-relevant states, i.e. connector/crtc/planes.

... because of this reason. If your driver can't recompute the private state from just the duplicated uapi-relevant states it's broken. Because essentially the exact same thing might happen through the atomic ioctl from userspace.

Hence my question: Why do you need this?
-Daniel

Quoted 65 lines
Quoted 53 lines

-Daniel

Quoted 51 lines
---
 drivers/gpu/drm/drm_atomic_helper.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +16 -0
index 540a77a2ade9..b108021cc092 100644
@@ -3189,6 +3189,7 @@ drm_atomic_helper_duplicate_state(struct drm_device *dev,
 	struct drm_connector_list_iter conn_iter;
 	struct drm_plane *plane;
 	struct drm_crtc *crtc;
+	struct drm_private_obj *privobj;
 	int err = 0;
 
 	state = drm_atomic_state_alloc(dev);
@@ -3218,6 +3219,16 @@ drm_atomic_helper_duplicate_state(struct drm_device *dev,
 		}
 	}
 
+	drm_for_each_privobj(privobj, dev) {
+		struct drm_private_state *priv_state;
+
+		priv_state = drm_atomic_get_private_obj_state(state, privobj);
+		if (IS_ERR(priv_state)) {
+			err = PTR_ERR(priv_state);
+			goto free;
+		}
+	}
+
 	drm_connector_list_iter_begin(dev, &conn_iter);
 	drm_for_each_connector_iter(conn, &conn_iter) {
 		struct drm_connector_state *conn_state;
@@ -3325,12 +3336,17 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state,
 	struct drm_connector_state *new_conn_state;
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *new_crtc_state;
+	struct drm_private_obj *privobj;
+	struct drm_private_state *new_priv_state;
 
 	state->acquire_ctx = ctx;
 
 	for_each_new_plane_in_state(state, plane, new_plane_state, i)
 		state->planes[i].old_state = plane->state;
 
+	for_each_new_private_obj_in_state(state, privobj, new_priv_state, i)
+		state->private_objs[i].old_state = privobj->state;
+
 	for_each_new_crtc_in_state(state, crtc, new_crtc_state, i)
 		state->crtcs[i].old_state = crtc->state;
 
Quoted 8 lines
Quoted 3 lines
Signature · 1 line
2.17.1
Signature · 3 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

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