Lines Matching refs:work
38 * generic delayed work implementation which delays work execution until a
39 * particular vblank has passed, and then executes the work at realtime
43 * re-arming work items can be easily implemented.
48 struct drm_vblank_work *work, *next;
54 list_for_each_entry_safe(work, next, &vblank->pending_work, node) {
55 if (!drm_vblank_passed(count, work->count))
58 list_del_init(&work->node);
60 kthread_queue_work(vblank->worker, &work->base);
67 /* Handle cancelling any pending vblank work items and drop respective vblank
72 struct drm_vblank_work *work, *next;
79 list_for_each_entry_safe(work, next, &vblank->pending_work, node) {
80 list_del_init(&work->node);
88 * drm_vblank_work_schedule - schedule a vblank work
89 * @work: vblank work to schedule
93 * Schedule @work for execution once the crtc vblank count reaches @count.
96 * %false the work starts to execute immediately.
99 * %true the work is deferred until the next vblank (as if @count has been
102 * If @work is already scheduled, this function will reschedule said work
103 * using the new @count. This can be used for self-rearming work items.
106 * %1 if @work was successfully (re)scheduled, %0 if it was either already
109 int drm_vblank_work_schedule(struct drm_vblank_work *work,
112 struct drm_vblank_crtc *vblank = work->vblank;
120 if (work->cancelling)
129 if (list_empty(&work->node)) {
133 } else if (work->count == count) {
140 work->count = count;
150 ret = kthread_queue_work(vblank->worker, &work->base);
153 list_del_init(&work->node);
158 list_add_tail(&work->node, &vblank->pending_work);
171 * drm_vblank_work_cancel_sync - cancel a vblank work and wait for it to
173 * @work: vblank work to cancel
175 * Cancel an already scheduled vblank work and wait for its
178 * On return, @work is guaranteed to no longer be scheduled or running, even
182 * %True if the work was cancelled before it started to execute, %false
185 bool drm_vblank_work_cancel_sync(struct drm_vblank_work *work)
187 struct drm_vblank_crtc *vblank = work->vblank;
192 if (!list_empty(&work->node)) {
193 list_del_init(&work->node);
198 work->cancelling++;
203 if (kthread_cancel_work_sync(&work->base))
207 work->cancelling--;
215 * drm_vblank_work_flush - wait for a scheduled vblank work to finish
217 * @work: vblank work to flush
219 * Wait until @work has finished executing once.
221 void drm_vblank_work_flush(struct drm_vblank_work *work)
223 struct drm_vblank_crtc *vblank = work->vblank;
227 wait_event_lock_irq(vblank->work_wait_queue, list_empty(&work->node),
231 kthread_flush_work(&work->base);
236 * drm_vblank_work_flush_all - flush all currently pending vblank work on crtc.
237 * @crtc: crtc for which vblank work to flush
239 * Wait until all currently queued vblank work on @crtc
258 * drm_vblank_work_init - initialize a vblank work item
259 * @work: vblank work item
260 * @crtc: CRTC whose vblank will trigger the work execution
261 * @func: work function to be executed
263 * Initialize a vblank work item for a specific crtc.
265 void drm_vblank_work_init(struct drm_vblank_work *work, struct drm_crtc *crtc,
266 void (*func)(struct kthread_work *work))
268 kthread_init_work(&work->base, func);
269 INIT_LIST_HEAD(&work->node);
270 work->vblank = drm_crtc_vblank_crtc(crtc);