diff mbox series

[2/4] drm: Add helper to check if there are pending vblank work

Message ID 20240508073904.1661848-3-chaitanya.kumar.borah@intel.com (mailing list archive)
State New, archived
Headers show
Series Cursor Fault Fix | expand

Commit Message

Chaitanya Kumar Borah May 8, 2024, 7:39 a.m. UTC
Add helper to check if there are pending vblank work for a crtc
which are yet to be scheduled.

Signed-off-by: Chaitanya Kumar Borah <chaitanya.kumar.borah@intel.com>
---
 drivers/gpu/drm/drm_vblank_work.c | 24 ++++++++++++++++++++++++
 include/drm/drm_vblank_work.h     |  1 +
 2 files changed, 25 insertions(+)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_vblank_work.c b/drivers/gpu/drm/drm_vblank_work.c
index 83a81a5e8280..1137a66d4153 100644
--- a/drivers/gpu/drm/drm_vblank_work.c
+++ b/drivers/gpu/drm/drm_vblank_work.c
@@ -254,6 +254,30 @@  void drm_vblank_work_flush_all(struct drm_crtc *crtc)
 }
 EXPORT_SYMBOL(drm_vblank_work_flush_all);
 
+/**
+ * drm_vblank_has_pending_work - Check if there are any currently pending vblank work on crtc.
+ * @crtc: crtc for which vblank work to flush
+ *
+ * Check if there are any pending vblank work on crtc, which are yet to be scheduled.
+ *
+ * Returns:
+ * %True if there are pending vblank workers, %false
+ * otherwise.
+ */
+bool drm_vblank_has_pending_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(drm_vblank_has_pending_work);
+
 /**
  * drm_vblank_work_init - initialize a vblank work item
  * @work: vblank work item
diff --git a/include/drm/drm_vblank_work.h b/include/drm/drm_vblank_work.h
index e04d436b7297..41ed27c8f74f 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 drm_vblank_has_pending_work(struct drm_crtc *crtc);
 
 #endif /* !_DRM_VBLANK_WORK_H_ */