drm: rcar-du: Move group locking inside rcar_du_crtc_update_planes()
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Mon, 23 Feb 2015 14:55:56 +0000 (16:55 +0200)
committerLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Tue, 3 Mar 2015 14:16:29 +0000 (16:16 +0200)
Only the planes to CRTCs association control register DPTSR needs to be
protected by custom locking, don't hold the mutex around the whole code.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
drivers/gpu/drm/rcar-du/rcar_du_crtc.c

index 29bbb44eecc9a89841f843432af50bc57fedf7c6..8459aaee8addc68f3477465be86ef6639a340074 100644 (file)
@@ -252,8 +252,6 @@ static void rcar_du_crtc_update_planes(struct rcar_du_crtc *rcrtc)
         * with superposition controller 2.
         */
        if (rcrtc->index % 2) {
-               u32 value = rcar_du_group_read(rcrtc->group, DPTSR);
-
                /* The DPTSR register is updated when the display controller is
                 * stopped. We thus need to restart the DU. Once again, sorry
                 * for the flicker. One way to mitigate the issue would be to
@@ -261,11 +259,13 @@ static void rcar_du_crtc_update_planes(struct rcar_du_crtc *rcrtc)
                 * split, or through a module parameter). Flicker would then
                 * occur only if we need to break the pre-association.
                 */
-               if (value != dptsr) {
+               mutex_lock(&rcrtc->group->planes.lock);
+               if (rcar_du_group_read(rcrtc->group, DPTSR) != dptsr) {
                        rcar_du_group_write(rcrtc->group, DPTSR, dptsr);
                        if (rcrtc->group->used_crtcs)
                                rcar_du_group_restart(rcrtc->group);
                }
+               mutex_unlock(&rcrtc->group->planes.lock);
        }
 
        rcar_du_group_write(rcrtc->group, rcrtc->index % 2 ? DS2PR : DS1PR,
@@ -435,9 +435,7 @@ void rcar_du_crtc_resume(struct rcar_du_crtc *rcrtc)
                rcar_du_plane_setup(plane);
        }
 
-       mutex_lock(&rcrtc->group->planes.lock);
        rcar_du_crtc_update_planes(rcrtc);
-       mutex_unlock(&rcrtc->group->planes.lock);
 }
 
 /* -----------------------------------------------------------------------------
@@ -501,9 +499,7 @@ static void rcar_du_crtc_atomic_flush(struct drm_crtc *crtc)
 {
        struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
 
-       mutex_lock(&rcrtc->group->planes.lock);
        rcar_du_crtc_update_planes(rcrtc);
-       mutex_unlock(&rcrtc->group->planes.lock);
 }
 
 static const struct drm_crtc_helper_funcs crtc_helper_funcs = {