drm_crtc_vblank_put may take some locks, this should probably
not be the first thing we do after entering the time sensitive
part.

A better place is after programming is completed. Add a flag
to put the vblank after completion.

In the case of drm_vblank_work_schedule, we may not even need
to disable the vblank interrupt any more if it takes its own
reference.

Signed-off-by: Maarten Lankhorst <[email protected]>
Reviewed-by: Uma Shankar <[email protected]>
---
 drivers/gpu/drm/i915/display/intel_cursor.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_cursor.c 
b/drivers/gpu/drm/i915/display/intel_cursor.c
index 2c5d917fbd7e9..3e84a2078a0a7 100644
--- a/drivers/gpu/drm/i915/display/intel_cursor.c
+++ b/drivers/gpu/drm/i915/display/intel_cursor.c
@@ -816,6 +816,7 @@ intel_legacy_cursor_update(struct drm_plane *_plane,
                to_intel_crtc_state(crtc->base.state);
        struct intel_crtc_state *new_crtc_state;
        struct intel_vblank_evade_ctx evade;
+       bool has_vblank = false;
        int ret;
 
        /*
@@ -913,6 +914,8 @@ intel_legacy_cursor_update(struct drm_plane *_plane,
        intel_psr_lock(crtc_state);
 
        if (!drm_WARN_ON(display->drm, drm_crtc_vblank_get(&crtc->base))) {
+               has_vblank = true;
+
                /*
                 * TODO: maybe check if we're still in PSR
                 * and skip the vblank evasion entirely?
@@ -922,8 +925,6 @@ intel_legacy_cursor_update(struct drm_plane *_plane,
                local_irq_disable();
 
                intel_vblank_evade(&evade);
-
-               drm_crtc_vblank_put(&crtc->base);
        } else {
                local_irq_disable();
        }
@@ -939,6 +940,9 @@ intel_legacy_cursor_update(struct drm_plane *_plane,
 
        intel_psr_unlock(crtc_state);
 
+       if (has_vblank)
+               drm_crtc_vblank_put(&crtc->base);
+
        if (old_plane_state->ggtt_vma != new_plane_state->ggtt_vma) {
                drm_vblank_work_init(&old_plane_state->unpin_work, &crtc->base,
                                     intel_cursor_unpin_work);
-- 
2.51.0

Reply via email to