[PATCH] drm: mali-dp: Restore commit_tail behaviour to the runtime_pm friendly version.

From: Liviu Dudau
Date: Wed Aug 02 2017 - 11:48:44 EST


Commit 46f1d42f2738 ("drm: mali-dp: Update the state of all planes
before re-enabling active CRTCs.") changed the runtime_pm recommended
order of doing the commit_tail (disable old crtc, enable new crtc, do
the plane updates) to the old non-atomic compat order (disable old crtc,
do the plane updates, enable new crtc) in order to stop planes streaming
out stale data. Turns out that the proper thing to do is to remember to
disable the planes on the crtcs that get disabled, and the problem goes
away. Oh, and only activate the planes that are involved in the new
commit, too.

Fixes commit 46f1d42f2738 ("drm: mali-dp: Update the state of all planes
before re-enabling active CRTCs.")

Signed-off-by: Liviu Dudau <Liviu.Dudau@xxxxxxx>
---
drivers/gpu/drm/arm/malidp_crtc.c | 4 ++++
drivers/gpu/drm/arm/malidp_drv.c | 11 +++--------
2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/arm/malidp_crtc.c b/drivers/gpu/drm/arm/malidp_crtc.c
index 3615d18a7ddf..ca413896b087 100644
--- a/drivers/gpu/drm/arm/malidp_crtc.c
+++ b/drivers/gpu/drm/arm/malidp_crtc.c
@@ -77,7 +77,11 @@ static void malidp_crtc_atomic_disable(struct drm_crtc *crtc,
struct malidp_hw_device *hwdev = malidp->dev;
int err;

+ /* always disable planes on the CRTC that is being turned off */
+ drm_atomic_helper_disable_planes_on_crtc(old_state, false);
+
drm_crtc_vblank_off(crtc);
+
hwdev->enter_config_mode(hwdev);
clk_disable_unprepare(hwdev->pxlclk);

diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
index a6a05a768dd1..d4b1636b441a 100644
--- a/drivers/gpu/drm/arm/malidp_drv.c
+++ b/drivers/gpu/drm/arm/malidp_drv.c
@@ -221,9 +221,8 @@ static void malidp_atomic_commit_tail(struct drm_atomic_state *state)
struct drm_crtc_state *old_crtc_state;
int i;

- pm_runtime_get_sync(drm->dev);
-
drm_atomic_helper_commit_modeset_disables(drm, state);
+ drm_atomic_helper_commit_modeset_enables(drm, state);

for_each_old_crtc_in_state(state, crtc, old_crtc_state, i) {
malidp_atomic_commit_update_gamma(crtc, old_crtc_state);
@@ -231,16 +230,12 @@ static void malidp_atomic_commit_tail(struct drm_atomic_state *state)
malidp_atomic_commit_se_config(crtc, old_crtc_state);
}

- drm_atomic_helper_commit_planes(drm, state, 0);
-
- drm_atomic_helper_commit_modeset_enables(drm, state);
+ drm_atomic_helper_commit_planes(drm, state, DRM_PLANE_COMMIT_ACTIVE_ONLY);

malidp_atomic_commit_hw_done(state);

drm_atomic_helper_wait_for_vblanks(drm, state);

- pm_runtime_put(drm->dev);
-
drm_atomic_helper_cleanup_planes(drm, state);
}

@@ -685,12 +680,12 @@ static void malidp_unbind(struct device *dev)
struct malidp_drm *malidp = drm->dev_private;

drm_dev_unregister(drm);
+ pm_runtime_get_sync(dev);
if (malidp->fbdev) {
drm_fbdev_cma_fini(malidp->fbdev);
malidp->fbdev = NULL;
}
drm_kms_helper_poll_fini(drm);
- pm_runtime_get_sync(dev);
malidp_se_irq_fini(drm);
malidp_de_irq_fini(drm);
component_unbind_all(dev, drm);
--
2.13.3