Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: intel-xe@lists.freedesktop.org, Maarten Lankhorst <dev@lankhorst.se>
Subject: [PATCH v2] drm: Add drm_vblank_work_flush_all().
Date: Fri,  5 Apr 2024 15:03:02 +0200	[thread overview]
Message-ID: <20240405130302.8086-1-maarten.lankhorst@linux.intel.com> (raw)
In-Reply-To: <20240404104813.150030-1-maarten.lankhorst@linux.intel.com>

From: Maarten Lankhorst <dev@lankhorst.se>

In some cases we want to flush all vblank work, right before vblank_off
for example. Add a simple function to make this possible.

Signed-off-by: Maarten Lankhorst <dev@lankhorst.se>
---
 drivers/gpu/drm/drm_vblank_work.c | 22 ++++++++++++++++++++++
 include/drm/drm_vblank_work.h     |  2 ++
 2 files changed, 24 insertions(+)

 Changes since v1:
   Check in flush_all for waitqueue_active was inverted.

diff --git a/drivers/gpu/drm/drm_vblank_work.c b/drivers/gpu/drm/drm_vblank_work.c
index 43cd5c0f4f6f..6a53cede547a 100644
--- a/drivers/gpu/drm/drm_vblank_work.c
+++ b/drivers/gpu/drm/drm_vblank_work.c
@@ -232,6 +232,28 @@ void drm_vblank_work_flush(struct drm_vblank_work *work)
 }
 EXPORT_SYMBOL(drm_vblank_work_flush);
 
+/**
+ * drm_vblank_work_flush_all - flush all currently pending vblank work on crtc.
+ * @crtc: crtc for which vblank work to flush
+ *
+ * Wait until all currently queued vblank work on @crtc
+ * has finished executing once.
+ */
+void drm_vblank_work_flush_all(struct drm_crtc *crtc)
+{
+	struct drm_device *dev = crtc->dev;
+	struct drm_vblank_crtc *vblank = &dev->vblank[drm_crtc_index(crtc)];
+
+	spin_lock_irq(&dev->event_lock);
+	wait_event_lock_irq(vblank->work_wait_queue,
+			    !waitqueue_active(&vblank->work_wait_queue),
+			    dev->event_lock);
+	spin_unlock_irq(&dev->event_lock);
+
+	kthread_flush_worker(vblank->worker);
+}
+EXPORT_SYMBOL(drm_vblank_work_flush_all);
+
 /**
  * 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 eb41d0810c4f..e04d436b7297 100644
--- a/include/drm/drm_vblank_work.h
+++ b/include/drm/drm_vblank_work.h
@@ -17,6 +17,7 @@ struct drm_crtc;
  * drm_vblank_work_init()
  * drm_vblank_work_cancel_sync()
  * drm_vblank_work_flush()
+ * drm_vblank_work_flush_all()
  */
 struct drm_vblank_work {
 	/**
@@ -67,5 +68,6 @@ void drm_vblank_work_init(struct drm_vblank_work *work, struct drm_crtc *crtc,
 			  void (*func)(struct kthread_work *work));
 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);
 
 #endif /* !_DRM_VBLANK_WORK_H_ */
-- 
2.43.0


  parent reply	other threads:[~2024-04-05 13:03 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-04 10:48 [rebase 1/3] drm: Add drm_vblank_work_flush_all() Maarten Lankhorst
2024-04-04 10:48 ` [rebase 2/3] drm/i915: Use vblank worker to unpin old legacy cursor fb safely Maarten Lankhorst
2024-04-04 10:48 ` [rebase 3/3] drm/i915: Use the same vblank worker for atomic unpin Maarten Lankhorst
2024-04-04 10:53 ` ✓ CI.Patch_applied: success for series starting with [rebase,1/3] drm: Add drm_vblank_work_flush_all() Patchwork
2024-04-04 10:53 ` ✗ CI.checkpatch: warning " Patchwork
2024-04-04 10:57 ` ✓ CI.KUnit: success " Patchwork
2024-04-04 11:08 ` ✓ CI.Build: " Patchwork
2024-04-04 11:11 ` ✓ CI.Hooks: " Patchwork
2024-04-04 11:12 ` ✗ CI.checksparse: warning " Patchwork
2024-04-05 13:03 ` Maarten Lankhorst [this message]
2024-04-05 13:36 ` [rebase 1/3] " Lucas De Marchi
2024-04-06 17:45   ` Maarten Lankhorst
2024-04-05 15:03 ` ✓ CI.Patch_applied: success for series starting with [v2] drm: Add drm_vblank_work_flush_all(). (rev2) Patchwork
2024-04-05 15:03 ` ✗ CI.checkpatch: warning " Patchwork
2024-04-05 15:04 ` ✓ CI.KUnit: success " Patchwork
2024-04-05 15:15 ` ✓ CI.Build: " Patchwork
2024-04-05 15:19 ` ✓ CI.Hooks: " Patchwork
2024-04-05 15:20 ` ✗ CI.checksparse: warning " Patchwork
2024-04-05 16:01 ` ✓ CI.BAT: success " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240405130302.8086-1-maarten.lankhorst@linux.intel.com \
    --to=maarten.lankhorst@linux.intel.com \
    --cc=dev@lankhorst.se \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox