drm/rockchip: vop: reject vlank control when vop is disabled
authorMark Yao <mark.yao@rock-chips.com>
Tue, 6 Sep 2016 08:44:57 +0000 (16:44 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Tue, 13 Sep 2016 05:58:39 +0000 (13:58 +0800)
drm enable/disable_vblank callback maybe call when vop is disabled,
it would cause system hang, we need reject it.

Change-Id: I3825fc9074203579bba0f71b1135f77075af85bb
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
drivers/gpu/drm/rockchip/rockchip_drm_vop.c

index 4b76d8cecf4ef429def4fc762ca77a416435e2aa..e5c95bdb38ea89e65f4c2f194d6b1ae54b2aa565 100644 (file)
@@ -158,6 +158,7 @@ struct vop {
        struct drm_property *plane_feature_prop;
        bool is_iommu_enabled;
        bool is_iommu_needed;
+       bool is_enabled;
 
        /* mutex vsync_ work */
        struct mutex vsync_mutex;
@@ -558,6 +559,7 @@ static void vop_enable(struct drm_crtc *crtc)
 
                VOP_WIN_SET(vop, win, gate, 1);
        }
+       vop->is_enabled = true;
 
        spin_lock(&vop->reg_lock);
 
@@ -620,6 +622,7 @@ static void vop_crtc_disable(struct drm_crtc *crtc)
 
        disable_irq(vop->irq);
 
+       vop->is_enabled = false;
        if (vop->is_iommu_enabled) {
                /*
                 * vop standby complete, so iommu detach is safe.
@@ -978,6 +981,9 @@ static int vop_crtc_enable_vblank(struct drm_crtc *crtc)
        struct vop *vop = to_vop(crtc);
        unsigned long flags;
 
+       if (!vop->is_enabled)
+               return -EPERM;
+
        spin_lock_irqsave(&vop->irq_lock, flags);
 
        VOP_INTR_SET_TYPE(vop, enable, FS_INTR, 1);
@@ -992,6 +998,9 @@ static void vop_crtc_disable_vblank(struct drm_crtc *crtc)
        struct vop *vop = to_vop(crtc);
        unsigned long flags;
 
+       if (!vop->is_enabled)
+               return;
+
        spin_lock_irqsave(&vop->irq_lock, flags);
 
        VOP_INTR_SET_TYPE(vop, enable, FS_INTR, 0);