drm/mediatek: Fix mtk_atomic_complete for runtime_pm
authorBibby Hsieh <bibby.hsieh@mediatek.com>
Thu, 4 Aug 2016 02:59:57 +0000 (10:59 +0800)
committerSean Paul <seanpaul@chromium.org>
Mon, 8 Aug 2016 18:20:02 +0000 (14:20 -0400)
To properly implement atomic w/ runtime pm, we move
drm_atomic_helper_commit_modeset_enables() above
drm_atomic_helper_commit_planes() to ensure CRTCs are enabled before
modifying plane registers, and set active_only to true to filter out
plane update notifications when the CRTC is disabled.

According to the document from linux kernel:
Set the active_only parameters to true in order not to receive plane
update notifications related to a disabled CRTC. This avoids the need
to manually ignore plane updates in driver code when the driver and/or
hardware can't or just don't need to deal with updates on disabled
CRTCs, for example when supporting runtime PM.

Signed-off-by: Bibby Hsieh <bibby.hsieh@mediatek.com>
Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Link: http://patchwork.freedesktop.org/patch/msgid/1470279597-60453-8-git-send-email-bibby.hsieh@mediatek.com
drivers/gpu/drm/mediatek/mtk_drm_drv.c

index eebb7d881c2ba88b9b50a309a6c37b7087feb77d..0e769abd0c2cd5fb4aa419d67a179b8e2afdaf6c 100644 (file)
@@ -61,10 +61,25 @@ static void mtk_atomic_complete(struct mtk_drm_private *private,
 
        mtk_atomic_wait_for_fences(state);
 
+       /*
+        * Mediatek drm supports runtime PM, so plane registers cannot be
+        * written when their crtc is disabled.
+        *
+        * The comment for drm_atomic_helper_commit states:
+        *     For drivers supporting runtime PM the recommended sequence is
+        *
+        *     drm_atomic_helper_commit_modeset_disables(dev, state);
+        *     drm_atomic_helper_commit_modeset_enables(dev, state);
+        *     drm_atomic_helper_commit_planes(dev, state, true);
+        *
+        * See the kerneldoc entries for these three functions for more details.
+        */
        drm_atomic_helper_commit_modeset_disables(drm, state);
-       drm_atomic_helper_commit_planes(drm, state, false);
        drm_atomic_helper_commit_modeset_enables(drm, state);
+       drm_atomic_helper_commit_planes(drm, state, true);
+
        drm_atomic_helper_wait_for_vblanks(drm, state);
+
        drm_atomic_helper_cleanup_planes(drm, state);
        drm_atomic_state_free(state);
 }