[PATCH 4/4] drm: wait for vblank if pending vblank work

Chaitanya Kumar Borah chaitanya.kumar.borah at intel.com
Tue May 7 21:16:57 UTC 2024


Signed-off-by: Chaitanya Kumar Borah <chaitanya.kumar.borah at intel.com>
---
 drivers/gpu/drm/drm_vblank_work.c            | 13 +++++++++++++
 drivers/gpu/drm/i915/display/intel_display.c |  5 ++++-
 include/drm/drm_vblank_work.h                |  1 +
 3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_vblank_work.c b/drivers/gpu/drm/drm_vblank_work.c
index 83a81a5e8280..5e96e058ba24 100644
--- a/drivers/gpu/drm/drm_vblank_work.c
+++ b/drivers/gpu/drm/drm_vblank_work.c
@@ -254,6 +254,19 @@ void drm_vblank_work_flush_all(struct drm_crtc *crtc)
 }
 EXPORT_SYMBOL(drm_vblank_work_flush_all);
 
+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_pending = false;
+
+	spin_lock_irq(&dev->event_lock);
+	is_pending = !list_empty(&vblank->pending_work);
+	spin_unlock_irq(&dev->event_lock);
+
+	return is_pending;
+}
+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..d561df211213 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->base)) {
+			intel_crtc_wait_for_next_vblank(crtc);
+			drm_vblank_work_flush_all(&crtc->base);
+		}
 	}
 
 	/* Only disable port sync and MST slaves */
diff --git a/include/drm/drm_vblank_work.h b/include/drm/drm_vblank_work.h
index e04d436b7297..02ff3c5a8008 100644
--- a/include/drm/drm_vblank_work.h
+++ b/include/drm/drm_vblank_work.h
@@ -69,5 +69,6 @@ void drm_vblank_work_init(struct drm_vblank_work *work, struct drm_crtc *crtc,
 bool drm_vblank_work_cancel_sync(struct drm_vblank_work *work);
 void drm_vblank_work_flush(struct drm_vblank_work *work);
 void drm_vblank_work_flush_all(struct drm_crtc *crtc);
+bool pending_vblank_work(struct drm_crtc *crtc);
 
 #endif /* !_DRM_VBLANK_WORK_H_ */
-- 
2.25.1



More information about the Intel-gfx-trybot mailing list