[PATCH 2/4] drm: Add helper to check if there are pending vblank work
Chaitanya Kumar Borah
chaitanya.kumar.borah at intel.com
Wed May 8 07:39:02 UTC 2024
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 at intel.com>
---
drivers/gpu/drm/drm_vblank_work.c | 24 ++++++++++++++++++++++++
include/drm/drm_vblank_work.h | 1 +
2 files changed, 25 insertions(+)
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_ */
--
2.25.1
More information about the Intel-gfx
mailing list