FROMLIST: drm/rockchip: vop: Disable planes when disabling CRTC
authorTomeu Vizoso <tomeu.vizoso@collabora.com>
Tue, 22 Mar 2016 15:08:04 +0000 (16:08 +0100)
committerHuang, Tao <huangtao@rock-chips.com>
Wed, 30 Mar 2016 02:01:47 +0000 (10:01 +0800)
When a VOP is re-enabled, it will start scanning right away the
framebuffers that were configured from the last time, even if those have
been destroyed already.

To prevent the VOP from trying to access freed memory, disable all its
windows when the CRTC is being disabled, then each window will get a
valid framebuffer address before it's enabled again.

Link: http://lkml.kernel.org/g/CAAObsKAv+05ih5U+=4kic_NsjGMhfxYheHR8xXXmacZs+p5SHw@mail.gmail.com
(am from https://patchwork.kernel.org/patch/8643631/)

Change-Id: Iaacb1624b4351a94d663ec73d9174b0fd4bc4b54
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
drivers/gpu/drm/rockchip/rockchip_drm_vop.c

index f36213c2e9a8c08be750bc8157559156ac20a3df..aad4fd5249ca0e0844357c79cf72a20e0aeb063e 100644 (file)
@@ -499,10 +499,25 @@ err_disable_hclk:
 static void vop_crtc_disable(struct drm_crtc *crtc)
 {
        struct vop *vop = to_vop(crtc);
+       int i;
 
        if (!vop->is_enabled)
                return;
 
+       /*
+        * We need to make sure that all windows are disabled before we
+        * disable that crtc. Otherwise we might try to scan from a destroyed
+        * buffer later.
+        */
+       for (i = 0; i < vop->data->win_size; i++) {
+               struct vop_win *vop_win = &vop->win[i];
+               const struct vop_win_data *win = vop_win->data;
+
+               spin_lock(&vop->reg_lock);
+               VOP_WIN_SET(vop, win, enable, 0);
+               spin_unlock(&vop->reg_lock);
+       }
+
        drm_crtc_vblank_off(crtc);
 
        /*