From: Sean Paul <seanp...@chromium.org>

commit 354c2d310082d1c384213ba76c3757dd3cd8755d upstream.

Since the dirtyfb ioctl doesn't give us any hints as to which plane is
scanning out the fb it's marking as damaged, we need to loop through
planes to find it.

Currently we just reach into plane state and check, but that can race
with another commit changing the fb out from under us. This patch locks
the plane before checking the fb and will release the lock if the plane
is not displaying the dirty fb.

Fixes: b9fc5e01d1ce ("drm: Add helper to implement legacy dirtyfb")
Cc: Rob Clark <robdcl...@gmail.com>
Cc: Deepak Rawat <dra...@vmware.com>
Cc: Daniel Vetter <daniel.vet...@ffwll.ch>
Cc: Thomas Hellstrom <thellst...@vmware.com>
Cc: Maarten Lankhorst <maarten.lankho...@linux.intel.com>
Cc: Maxime Ripard <maxime.rip...@bootlin.com>
Cc: Sean Paul <s...@poorly.run>
Cc: David Airlie <airl...@linux.ie>
Cc: Daniel Vetter <dan...@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org
Cc: <sta...@vger.kernel.org> # v5.0+
Reported-by: Daniel Vetter <dan...@ffwll.ch>
Reviewed-by: Daniel Vetter <dan...@ffwll.ch>
Signed-off-by: Sean Paul <seanp...@chromium.org>
Link: 
https://patchwork.freedesktop.org/patch/msgid/20190904202938.110207-1-s...@poorly.run
Signed-off-by: Greg Kroah-Hartman <gre...@linuxfoundation.org>

---
 drivers/gpu/drm/drm_damage_helper.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

--- a/drivers/gpu/drm/drm_damage_helper.c
+++ b/drivers/gpu/drm/drm_damage_helper.c
@@ -212,8 +212,14 @@ retry:
        drm_for_each_plane(plane, fb->dev) {
                struct drm_plane_state *plane_state;
 
-               if (plane->state->fb != fb)
+               ret = drm_modeset_lock(&plane->mutex, state->acquire_ctx);
+               if (ret)
+                       goto out;
+
+               if (plane->state->fb != fb) {
+                       drm_modeset_unlock(&plane->mutex);
                        continue;
+               }
 
                plane_state = drm_atomic_get_plane_state(state, plane);
                if (IS_ERR(plane_state)) {


_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reply via email to