Skip to contentSkip to conversation

drm/atomic: Add sanity checks to drm_atomic_helper_async_commit()

PATCH Applied Boris Brezillon 4 participants 5 messages Mar 30, 2018 – Apr 18, 2018

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

PATCH 1/1 drm/atomic: Add sanity checks to drm_atomic_helper_async_commit()

->atomic_async_update() requires that drivers update the plane->state object before returning. Make sure at least common properties have been updated.

---
Hello,

This is a problem I had when debugging the VC4 ->atomic_async_update() implementation. The function was not updating plane->fb as it's supposed thus leaving plane->state->fb in an inconsistent state after each async update.

Not sure if such WARN_ON_ONCE() are accepted in the core though, so I'll maintainers decide whether this is relevant or not and whether they prefer to have WARN_ON() or DRM_ERROR() messages.

Regards,

Boris

---
 drivers/gpu/drm/drm_atomic_helper.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +11 -0
index c35654591c12..d2b2583487ee 100644
@@ -1561,6 +1561,17 @@ void drm_atomic_helper_async_commit(struct drm_device *dev,
 	for_each_new_plane_in_state(state, plane, plane_state, i) {
 		funcs = plane->helper_private;
 		funcs->atomic_async_update(plane, plane_state);
+
+		/*
+		 * ->atomic_async_update() is supposed to update the
+		 * plane->state in-place, make sure at least common
+		 * properties have been properly updated.
+		 */
+		WARN_ON_ONCE(plane->state->fb != plane_state->fb);
+		WARN_ON_ONCE(plane->state->crtc_x != plane_state->crtc_x);
+		WARN_ON_ONCE(plane->state->crtc_y != plane_state->crtc_y);
+		WARN_ON_ONCE(plane->state->src_x != plane_state->src_x);
+		WARN_ON_ONCE(plane->state->src_y != plane_state->src_y);
 	}
 }
 EXPORT_SYMBOL(drm_atomic_helper_async_commit);
Signature · 6 lines
2.14.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Boris Brezillon

->atomic_async_update() requires that drivers update the plane->state object before returning. Make sure at least common properties have been updated.

---
Hello,

Quoted 8 lines

This is a problem I had when debugging the VC4 ->atomic_async_update() implementation. The function was not updating plane->fb as it's supposed thus leaving plane->state->fb in an inconsistent state after each async update.

Not sure if such WARN_ON_ONCE() are accepted in the core though, so I'll maintainers decide whether this is relevant or not and whether they prefer to have WARN_ON() or DRM_ERROR() messages.

I'm a huge fan of this kind of safety check. FWIW,

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

Acked-by
#2 lore raw
Quoted 16 lines · Eric Anholt
Quoted 14 lines · Boris Brezillon

->atomic_async_update() requires that drivers update the plane->state object before returning. Make sure at least common properties have been updated.

---
Hello,

This is a problem I had when debugging the VC4 ->atomic_async_update() implementation. The function was not updating plane->fb as it's supposed thus leaving plane->state->fb in an inconsistent state after each async update.

Quoted 7 lines
Quoted 3 lines

Not sure if such WARN_ON_ONCE() are accepted in the core though, so I'll maintainers decide whether this is relevant or not and whether they prefer to have WARN_ON() or DRM_ERROR() messages.

I'm a huge fan of this kind of safety check. FWIW,

Agreed, seems like a useful safety net to me.

Quoted 4 lines

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

Signature · 5 lines
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by
#3 lore raw
Quoted 21 lines · Sean Paul
Quoted 20 lines · Eric Anholt
Quoted 17 lines · Boris Brezillon

->atomic_async_update() requires that drivers update the plane->state object before returning. Make sure at least common properties have been updated.

---
Hello,

This is a problem I had when debugging the VC4 ->atomic_async_update() implementation. The function was not updating plane->fb as it's supposed thus leaving plane->state->fb in an inconsistent state after each async update.

Not sure if such WARN_ON_ONCE() are accepted in the core though, so I'll maintainers decide whether this is relevant or not and whether they prefer to have WARN_ON() or DRM_ERROR() messages.

Quoted 7 lines
Quoted 3 lines

I'm a huge fan of this kind of safety check. FWIW,

Agreed, seems like a useful safety net to me.

Yeah, makes sense.

Quoted 11 lines
Quoted 7 lines

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

Signature · 1 line
Sean Paul, Software Engineer, Google / Chromium OS
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
author Applied
#4 lore raw
In reply to Boris Brezillon
Quoted 6 lines · On Fri, 30 Mar 2018 16:55:18 +0200 Boris Brezillon…

->atomic_async_update() requires that drivers update the plane->state object before returning. Make sure at least common properties have been updated.

Applied to drm-misc-next.

Quoted 31 lines

---
Hello,

This is a problem I had when debugging the VC4 ->atomic_async_update() implementation. The function was not updating plane->fb as it's supposed thus leaving plane->state->fb in an inconsistent state after each async update.

Not sure if such WARN_ON_ONCE() are accepted in the core though, so I'll maintainers decide whether this is relevant or not and whether they prefer to have WARN_ON() or DRM_ERROR() messages.

Regards,

Boris

---
 drivers/gpu/drm/drm_atomic_helper.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +4 -0
index c35654591c12..d2b2583487ee 100644
@@ -1561,6 +1561,17 @@ void drm_atomic_helper_async_commit(struct drm_device *dev,
 	for_each_new_plane_in_state(state, plane, plane_state, i) {
 		funcs = plane->helper_private;
 		funcs->atomic_async_update(plane, plane_state);
+
+		/*
+		 * ->atomic_async_update() is supposed to update the
+		 * plane->state in-place, make sure at least common

drivers/gpu/drm/drm_atomic_helper.c void drm_atomic_helper_async_commit(struct drm_device *dev, · line 1577

Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +7 -0
+		 * properties have been properly updated.
+		 */
+		WARN_ON_ONCE(plane->state->fb != plane_state->fb);
+		WARN_ON_ONCE(plane->state->crtc_x != plane_state->crtc_x);
+		WARN_ON_ONCE(plane->state->crtc_y != plane_state->crtc_y);
+		WARN_ON_ONCE(plane->state->src_x != plane_state->src_x);
+		WARN_ON_ONCE(plane->state->src_y != plane_state->src_y);
 	}
 }
 EXPORT_SYMBOL(drm_atomic_helper_async_commit);

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