Lines Matching defs:work

38  * Define all work struct states
69 * This function atomically updates the work state and returns the
94 linux_work_exec_unblock(struct work_struct *work)
100 wq = work->work_queue;
106 if (exec->target == work) {
122 tq = dwork->work.work_queue->taskqueue;
123 taskqueue_enqueue(tq, &dwork->work.work_task);
127 * This function queues the given work structure on the given
128 * workqueue. It returns non-zero if the work was successfully
129 * [re-]queued. Else the work is already pending for completion.
133 struct work_struct *work)
144 return (!work_pending(work));
146 switch (linux_update_state(&work->state, states)) {
149 if (linux_work_exec_unblock(work) != 0)
153 work->work_queue = wq;
154 taskqueue_enqueue(wq->taskqueue, &work->work_task);
170 linux_queue_work_on(WORK_CPU_UNBOUND, rwork->wq, &rwork->work);
174 * This function queue a work after a grace period
175 * If the work was already pending it returns false,
182 if (!linux_work_pending(&rwork->work)) {
191 * This function waits for the last execution of a work and then
192 * flush the work.
193 * It returns true if the work was pending and we waited, it returns
200 if (linux_work_pending(&rwork->work)) {
202 linux_flush_work(&rwork->work);
205 return (linux_flush_work(&rwork->work));
209 * This function queues the given work structure on the given
211 * work was successfully [re-]queued. Else the work is already pending
228 return (!work_pending(&dwork->work));
238 switch (linux_update_state(&dwork->work.state, states)) {
241 if (delay == 0 && linux_work_exec_unblock(&dwork->work)) {
248 dwork->work.work_queue = wq;
276 [WORK_ST_TIMER] = WORK_ST_EXEC, /* delayed work w/o timeout */
281 struct work_struct *work;
289 work = context;
290 wq = work->work_queue;
293 exec.target = work;
299 switch (linux_update_state(&work->state, states)) {
305 /* set current work structure */
306 task->work = work;
308 /* call work function */
309 work->func(work);
311 /* set current work structure */
312 task->work = NULL;
316 if (exec.target != work) {
318 exec.target = work;
338 * Make sure the timer belonging to the delayed work gets
339 * drained before invoking the work function. Else the timer
341 * situations, because the work function might free the work
346 linux_work_fn(&dwork->work, pending);
361 switch (linux_update_state(&dwork->work.state, states)) {
372 * This function cancels the given work structure in a
373 * non-blocking fashion. It returns non-zero if the work was
374 * successfully cancelled. Else the work may still be busy or already
378 linux_cancel_work(struct work_struct *work)
389 MPASS(atomic_read(&work->state) != WORK_ST_TIMER);
390 MPASS(atomic_read(&work->state) != WORK_ST_CANCEL);
392 switch (linux_update_state(&work->state, states)) {
394 tq = work->work_queue->taskqueue;
395 if (taskqueue_cancel(tq, &work->work_task, NULL) == 0)
404 * This function cancels the given work structure in a synchronous
405 * fashion. It returns non-zero if the work was successfully
406 * cancelled. Else the work was already cancelled.
409 linux_cancel_work_sync(struct work_struct *work)
424 switch (linux_update_state(&work->state, states)) {
429 tq = work->work_queue->taskqueue;
430 if (taskqueue_cancel(tq, &work->work_task, NULL) != 0)
431 taskqueue_drain(tq, &work->work_task);
432 goto retry; /* work may have restarted itself */
434 tq = work->work_queue->taskqueue;
435 if (taskqueue_cancel(tq, &work->work_task, NULL) != 0)
436 taskqueue_drain(tq, &work->work_task);
464 * This function cancels the given delayed work structure in a
465 * non-blocking fashion. It returns non-zero if the work was
466 * successfully cancelled. Else the work may still be busy or already
483 switch (linux_update_state(&dwork->work.state, states)) {
488 atomic_cmpxchg(&dwork->work.state,
495 tq = dwork->work.work_queue->taskqueue;
496 if (taskqueue_cancel(tq, &dwork->work.work_task, NULL) == 0) {
497 atomic_cmpxchg(&dwork->work.state,
510 * Cancel and drain delayed work, reporting cancelled pending work through
534 state = linux_update_state(&dwork->work.state, states);
553 tq = dwork->work.work_queue->taskqueue;
554 ret = taskqueue_cancel(tq, &dwork->work.work_task, pending);
558 taskqueue_drain(tq, &dwork->work.work_task);
561 tq = dwork->work.work_queue->taskqueue;
562 ret = taskqueue_cancel(tq, &dwork->work.work_task, pending);
565 taskqueue_drain(tq, &dwork->work.work_task);
590 * This function waits until the given work structure is completed.
591 * It returns non-zero if the work was successfully
592 * waited for. Else the work was not waited for.
595 linux_flush_work(struct work_struct *work)
603 switch (atomic_read(&work->state)) {
607 tq = work->work_queue->taskqueue;
608 retval = taskqueue_poll_is_busy(tq, &work->work_task);
609 taskqueue_drain(tq, &work->work_task);
615 * This function waits until the given delayed work structure is
616 * completed. It returns non-zero if the work was successfully waited
617 * for. Else the work was not waited for.
628 switch (atomic_read(&dwork->work.state)) {
636 tq = dwork->work.work_queue->taskqueue;
637 retval = taskqueue_poll_is_busy(tq, &dwork->work.work_task);
638 taskqueue_drain(tq, &dwork->work.work_task);
644 * This function returns true if the given work is pending, and not
648 linux_work_pending(struct work_struct *work)
650 switch (atomic_read(&work->state)) {
661 * This function returns true if the given work is busy.
664 linux_work_busy(struct work_struct *work)
668 switch (atomic_read(&work->state)) {
672 tq = work->work_queue->taskqueue;
673 return (taskqueue_poll_is_busy(tq, &work->work_task));
715 dwork->work.func = func;
716 TASK_INIT(&dwork->work.work_task, 0, linux_delayed_work_fn, dwork);
725 return (current->work);