Lines Matching full:work

38  * Define all work struct states
68 * This function atomically updates the work state and returns the
93 linux_work_exec_unblock(struct work_struct *work) in linux_work_exec_unblock() argument
99 wq = work->work_queue; in linux_work_exec_unblock()
105 if (exec->target == work) { in linux_work_exec_unblock()
121 tq = dwork->work.work_queue->taskqueue; in linux_delayed_work_enqueue()
122 taskqueue_enqueue(tq, &dwork->work.work_task); in linux_delayed_work_enqueue()
126 * This function queues the given work structure on the given
127 * workqueue. It returns non-zero if the work was successfully
128 * [re-]queued. Else the work is already pending for completion.
132 struct work_struct *work) in linux_queue_work_on() argument
143 return (!work_pending(work)); in linux_queue_work_on()
145 switch (linux_update_state(&work->state, states)) { in linux_queue_work_on()
148 if (linux_work_exec_unblock(work) != 0) in linux_queue_work_on()
152 work->work_queue = wq; in linux_queue_work_on()
153 taskqueue_enqueue(wq->taskqueue, &work->work_task); in linux_queue_work_on()
169 linux_queue_work_on(WORK_CPU_UNBOUND, rwork->wq, &rwork->work); in rcu_work_func()
173 * This function queue a work after a grace period
174 * If the work was already pending it returns false,
181 if (!linux_work_pending(&rwork->work)) { in linux_queue_rcu_work()
190 * This function waits for the last execution of a work and then
191 * flush the work.
192 * It returns true if the work was pending and we waited, it returns
199 if (linux_work_pending(&rwork->work)) { in linux_flush_rcu_work()
201 linux_flush_work(&rwork->work); in linux_flush_rcu_work()
204 return (linux_flush_work(&rwork->work)); in linux_flush_rcu_work()
208 * This function queues the given work structure on the given
210 * work was successfully [re-]queued. Else the work is already pending
227 return (!work_pending(&dwork->work)); in linux_queue_delayed_work_on()
230 switch (linux_update_state(&dwork->work.state, states)) { in linux_queue_delayed_work_on()
233 if (delay == 0 && linux_work_exec_unblock(&dwork->work)) { in linux_queue_delayed_work_on()
240 dwork->work.work_queue = wq; in linux_queue_delayed_work_on()
268 [WORK_ST_TIMER] = WORK_ST_EXEC, /* delayed work w/o timeout */ in linux_work_fn()
273 struct work_struct *work; in linux_work_fn() local
281 work = context; in linux_work_fn()
282 wq = work->work_queue; in linux_work_fn()
285 exec.target = work; in linux_work_fn()
291 switch (linux_update_state(&work->state, states)) { in linux_work_fn()
297 /* set current work structure */ in linux_work_fn()
298 task->work = work; in linux_work_fn()
300 /* call work function */ in linux_work_fn()
301 work->func(work); in linux_work_fn()
303 /* set current work structure */ in linux_work_fn()
304 task->work = NULL; in linux_work_fn()
308 if (exec.target != work) { in linux_work_fn()
310 exec.target = work; in linux_work_fn()
330 * Make sure the timer belonging to the delayed work gets in linux_delayed_work_fn()
331 * drained before invoking the work function. Else the timer in linux_delayed_work_fn()
333 * situations, because the work function might free the work in linux_delayed_work_fn()
338 linux_work_fn(&dwork->work, pending); in linux_delayed_work_fn()
353 switch (linux_update_state(&dwork->work.state, states)) { in linux_delayed_work_timer_fn()
364 * This function cancels the given work structure in a
365 * non-blocking fashion. It returns non-zero if the work was
366 * successfully cancelled. Else the work may still be busy or already
370 linux_cancel_work(struct work_struct *work) in linux_cancel_work() argument
381 MPASS(atomic_read(&work->state) != WORK_ST_TIMER); in linux_cancel_work()
382 MPASS(atomic_read(&work->state) != WORK_ST_CANCEL); in linux_cancel_work()
384 switch (linux_update_state(&work->state, states)) { in linux_cancel_work()
386 tq = work->work_queue->taskqueue; in linux_cancel_work()
387 if (taskqueue_cancel(tq, &work->work_task, NULL) == 0) in linux_cancel_work()
396 * This function cancels the given work structure in a synchronous
397 * fashion. It returns non-zero if the work was successfully
398 * cancelled. Else the work was already cancelled.
401 linux_cancel_work_sync(struct work_struct *work) in linux_cancel_work_sync() argument
416 switch (linux_update_state(&work->state, states)) { in linux_cancel_work_sync()
421 tq = work->work_queue->taskqueue; in linux_cancel_work_sync()
422 if (taskqueue_cancel(tq, &work->work_task, NULL) != 0) in linux_cancel_work_sync()
423 taskqueue_drain(tq, &work->work_task); in linux_cancel_work_sync()
424 goto retry; /* work may have restarted itself */ in linux_cancel_work_sync()
426 tq = work->work_queue->taskqueue; in linux_cancel_work_sync()
427 if (taskqueue_cancel(tq, &work->work_task, NULL) != 0) in linux_cancel_work_sync()
428 taskqueue_drain(tq, &work->work_task); in linux_cancel_work_sync()
456 * This function cancels the given delayed work structure in a
457 * non-blocking fashion. It returns non-zero if the work was
458 * successfully cancelled. Else the work may still be busy or already
475 switch (linux_update_state(&dwork->work.state, states)) { in linux_cancel_delayed_work()
480 atomic_cmpxchg(&dwork->work.state, in linux_cancel_delayed_work()
487 tq = dwork->work.work_queue->taskqueue; in linux_cancel_delayed_work()
488 if (taskqueue_cancel(tq, &dwork->work.work_task, NULL) == 0) { in linux_cancel_delayed_work()
489 atomic_cmpxchg(&dwork->work.state, in linux_cancel_delayed_work()
502 * This function cancels the given work structure in a synchronous
503 * fashion. It returns true if the work was successfully
504 * cancelled. Else the work was already cancelled.
524 state = linux_update_state(&dwork->work.state, states); in linux_cancel_delayed_work_sync_int()
533 tq = dwork->work.work_queue->taskqueue; in linux_cancel_delayed_work_sync_int()
534 ret = taskqueue_cancel(tq, &dwork->work.work_task, NULL); in linux_cancel_delayed_work_sync_int()
538 taskqueue_drain(tq, &dwork->work.work_task); in linux_cancel_delayed_work_sync_int()
541 tq = dwork->work.work_queue->taskqueue; in linux_cancel_delayed_work_sync_int()
542 ret = taskqueue_cancel(tq, &dwork->work.work_task, NULL); in linux_cancel_delayed_work_sync_int()
545 taskqueue_drain(tq, &dwork->work.work_task); in linux_cancel_delayed_work_sync_int()
562 * This function waits until the given work structure is completed.
563 * It returns non-zero if the work was successfully
564 * waited for. Else the work was not waited for.
567 linux_flush_work(struct work_struct *work) in linux_flush_work() argument
575 switch (atomic_read(&work->state)) { in linux_flush_work()
579 tq = work->work_queue->taskqueue; in linux_flush_work()
580 retval = taskqueue_poll_is_busy(tq, &work->work_task); in linux_flush_work()
581 taskqueue_drain(tq, &work->work_task); in linux_flush_work()
587 * This function waits until the given delayed work structure is
588 * completed. It returns non-zero if the work was successfully waited
589 * for. Else the work was not waited for.
600 switch (atomic_read(&dwork->work.state)) { in linux_flush_delayed_work()
608 tq = dwork->work.work_queue->taskqueue; in linux_flush_delayed_work()
609 retval = taskqueue_poll_is_busy(tq, &dwork->work.work_task); in linux_flush_delayed_work()
610 taskqueue_drain(tq, &dwork->work.work_task); in linux_flush_delayed_work()
616 * This function returns true if the given work is pending, and not
620 linux_work_pending(struct work_struct *work) in linux_work_pending() argument
622 switch (atomic_read(&work->state)) { in linux_work_pending()
633 * This function returns true if the given work is busy.
636 linux_work_busy(struct work_struct *work) in linux_work_busy() argument
640 switch (atomic_read(&work->state)) { in linux_work_busy()
644 tq = work->work_queue->taskqueue; in linux_work_busy()
645 return (taskqueue_poll_is_busy(tq, &work->work_task)); in linux_work_busy()
687 dwork->work.func = func; in linux_init_delayed_work()
688 TASK_INIT(&dwork->work.work_task, 0, linux_delayed_work_fn, dwork); in linux_init_delayed_work()
697 return (current->work); in linux_current_work()