Lines Matching refs:x

9 void completion_init(struct completion *x)  in completion_init()  argument
11 x->done = 0; in completion_init()
12 wait_queue_head_init(&x->wait_queue); in completion_init()
20 void complete(struct completion *x) in complete() argument
23 spin_lock(&x->wait_queue.lock); in complete()
25 if (x->done != COMPLETE_ALL) in complete()
26 ++(x->done); in complete()
27 wait_queue_wakeup_on_stack(&x->wait_queue, -1UL); // -1UL代表所有节点都满足条件,暂时这么写 in complete()
29 spin_unlock(&x->wait_queue.lock); in complete()
37 void complete_all(struct completion *x) in complete_all() argument
39 spin_lock(&x->wait_queue.lock); in complete_all()
41 x->done = COMPLETE_ALL; // 永久赋值 in complete_all()
42 while (!list_empty(&x->wait_queue.wait_list)) in complete_all()
43 wait_queue_wakeup_on_stack(&x->wait_queue, -1UL); // -1UL代表所有节点都满足条件,暂时这么写 in complete_all()
45 spin_unlock(&x->wait_queue.lock); in complete_all()
57 static long __wait_for_common(struct completion *x, long (*action)(long), long timeout, int state) in __wait_for_common() argument
59 if (!x->done) in __wait_for_common()
63 while (!x->done && timeout > 0) in __wait_for_common()
67 list_append(&x->wait_queue.wait_list, &wait.wait_list); in __wait_for_common()
70 spin_unlock(&x->wait_queue.lock); in __wait_for_common()
73 spin_lock(&x->wait_queue.lock); in __wait_for_common()
75 if (!x->done) in __wait_for_common()
82 if (x->done != COMPLETE_ALL) in __wait_for_common()
83 --(x->done); in __wait_for_common()
92 void wait_for_completion(struct completion *x) in wait_for_completion() argument
94 spin_lock(&x->wait_queue.lock); in wait_for_completion()
95 __wait_for_common(x, &schedule_timeout_ms, MAX_TIMEOUT, PROC_UNINTERRUPTIBLE); in wait_for_completion()
96 spin_unlock(&x->wait_queue.lock); in wait_for_completion()
106 long wait_for_completion_timeout(struct completion *x, long timeout) in wait_for_completion_timeout() argument
109 spin_lock(&x->wait_queue.lock); in wait_for_completion_timeout()
110 timeout = __wait_for_common(x, &schedule_timeout_ms, timeout, PROC_UNINTERRUPTIBLE); in wait_for_completion_timeout()
111 spin_unlock(&x->wait_queue.lock); in wait_for_completion_timeout()
120 void wait_for_completion_interruptible(struct completion *x) in wait_for_completion_interruptible() argument
122 spin_lock(&x->wait_queue.lock); in wait_for_completion_interruptible()
123 __wait_for_common(x, &schedule_timeout_ms, MAX_TIMEOUT, PROC_INTERRUPTIBLE); in wait_for_completion_interruptible()
124 spin_unlock(&x->wait_queue.lock); in wait_for_completion_interruptible()
134 long wait_for_completion_interruptible_timeout(struct completion *x, long timeout) in wait_for_completion_interruptible_timeout() argument
138 spin_lock(&x->wait_queue.lock); in wait_for_completion_interruptible_timeout()
139 timeout = __wait_for_common(x, &schedule_timeout_ms, timeout, PROC_INTERRUPTIBLE); in wait_for_completion_interruptible_timeout()
140 spin_unlock(&x->wait_queue.lock); in wait_for_completion_interruptible_timeout()
151 bool try_wait_for_completion(struct completion *x) in try_wait_for_completion() argument
153 if (!READ_ONCE(x->done)) in try_wait_for_completion()
157 spin_lock(&x->wait_queue.lock); in try_wait_for_completion()
159 if (!x->done) in try_wait_for_completion()
161 else if (x->done != COMPLETE_ALL) in try_wait_for_completion()
162 --(x->done); in try_wait_for_completion()
164 spin_unlock(&x->wait_queue.lock); in try_wait_for_completion()
175 bool completion_done(struct completion *x) in completion_done() argument
178 if (!READ_ONCE(x->done)) in completion_done()
182 spin_lock(&x->wait_queue.lock); in completion_done()
184 if (!READ_ONCE(x->done)) in completion_done()
186 spin_unlock(&x->wait_queue.lock); in completion_done()
189 spin_unlock(&x->wait_queue.lock); in completion_done()
199 void wait_for_multicompletion(struct completion x[], int n) in wait_for_multicompletion() argument
203 if (!completion_done(&x[i])) // 如果没有done,直接wait in wait_for_multicompletion()
205 wait_for_completion(&x[i]); in wait_for_multicompletion()
207 else if (!try_wait_for_completion(&x[i])) //上面测试过done>0,那么这里尝试去获取一个done,如果失败了,就继续wait in wait_for_multicompletion()
209 wait_for_completion(&x[i]); in wait_for_multicompletion()