From: Ivan Lipski <[email protected]>

[Why&How]
Return -EINVAL when userspace asks us to enable vblank on a crtc that is
not yet enabled.

Suggested-by: Aurabindo Pillai <[email protected]>
Reviewed-by: Aurabindo Pillai <[email protected]>
Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/1856
Signed-off-by: Ivan Lipski <[email protected]>
Signed-off-by: Wayne Lin <[email protected]>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c
index f08121a2b838..38f9ea313dcb 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c
@@ -308,8 +308,12 @@ static inline int amdgpu_dm_crtc_set_vblank(struct 
drm_crtc *crtc, bool enable)
        int irq_type;
        int rc = 0;
 
-       if (acrtc->otg_inst == -1)
-               goto skip;
+       if (enable && !acrtc->base.enabled) {
+               drm_dbg_vbl(crtc->dev,
+                               "Reject vblank enable on unconfigured CRTC %d 
(enabled=%d)\n",
+                               acrtc->crtc_id, acrtc->base.enabled);
+               return -EINVAL;
+       }
 
        irq_type = amdgpu_display_crtc_idx_to_irq_type(adev, acrtc->crtc_id);
 
@@ -394,7 +398,7 @@ static inline int amdgpu_dm_crtc_set_vblank(struct drm_crtc 
*crtc, bool enable)
                        return rc;
        }
 #endif
-skip:
+
        if (amdgpu_in_reset(adev))
                return 0;
 
-- 
2.43.0

Reply via email to