[PATCH 4/4] drm: wait for vblank if pending vblank work
Chaitanya Kumar Borah
chaitanya.kumar.borah at intel.com
Tue May 7 21:08:15 UTC 2024
Signed-off-by: Chaitanya Kumar Borah <chaitanya.kumar.borah at intel.com>
---
drivers/gpu/drm/drm_vblank_work.c | 15 ++++++++++++++-
drivers/gpu/drm/i915/display/intel_display.c | 5 ++++-
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/drm_vblank_work.c b/drivers/gpu/drm/drm_vblank_work.c
index 83a81a5e8280..cd53c15ceb08 100644
--- a/drivers/gpu/drm/drm_vblank_work.c
+++ b/drivers/gpu/drm/drm_vblank_work.c
@@ -246,7 +246,7 @@ void drm_vblank_work_flush_all(struct drm_crtc *crtc)
spin_lock_irq(&dev->event_lock);
wait_event_lock_irq(vblank->work_wait_queue,
- !waitqueue_active(&vblank->work_wait_queue),
+ no_pending_work_for_current_vblank(vblank)
dev->event_lock);
spin_unlock_irq(&dev->event_lock);
@@ -254,6 +254,19 @@ void drm_vblank_work_flush_all(struct drm_crtc *crtc)
}
EXPORT_SYMBOL(drm_vblank_work_flush_all);
+static bool pending_vblank_work(struct drm_crtc *crtc)
+{
+ struct drm_device *dev = crtc->dev;
+ struct drm_vblank_crtc *vblank = &dev->vblank[drm_crtc_index(crtc)];
+ bool is_empty = false;
+
+ spin_lock_irq(&dev->event_lock);
+ is_empty = list_empty(&vblank->pending_work);
+ spin_unlock_irq(&dev->event_lock);
+
+ return is_empty;
+}
+EXPORT_SYMBOL(pending_vblank_work);
/**
* drm_vblank_work_init - initialize a vblank work item
* @work: vblank work item
diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index 120ca76d1215..f42a41426f85 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -6925,7 +6925,10 @@ static void intel_commit_modeset_disables(struct intel_atomic_state *state)
intel_crtc_disable_planes(state, crtc);
- drm_vblank_work_flush_all(&crtc->base);
+ if(pending_vblank_work(crtc)) {
+ intel_crtc_wait_for_next_vblank(crtc);
+ drm_vblank_work_flush_all(&crtc->base);
+ }
}
/* Only disable port sync and MST slaves */
--
2.25.1
More information about the Intel-gfx-trybot
mailing list