Lines Matching refs:cq

42 void optee_cq_init(struct optee_call_queue *cq, int thread_count)  in optee_cq_init()  argument
44 mutex_init(&cq->mutex); in optee_cq_init()
45 INIT_LIST_HEAD(&cq->waiters); in optee_cq_init()
53 cq->total_thread_count = thread_count; in optee_cq_init()
54 cq->free_thread_count = thread_count; in optee_cq_init()
57 void optee_cq_wait_init(struct optee_call_queue *cq, in optee_cq_wait_init() argument
73 mutex_lock(&cq->mutex); in optee_cq_wait_init()
82 list_add_tail(&w->list_node, &cq->waiters); in optee_cq_wait_init()
85 if (cq->total_thread_count) { in optee_cq_wait_init()
86 if (sys_thread || !cq->sys_thread_req_count) in optee_cq_wait_init()
91 if (cq->free_thread_count > free_thread_threshold) in optee_cq_wait_init()
92 cq->free_thread_count--; in optee_cq_wait_init()
97 mutex_unlock(&cq->mutex); in optee_cq_wait_init()
100 optee_cq_wait_for_completion(cq, w); in optee_cq_wait_init()
101 mutex_lock(&cq->mutex); in optee_cq_wait_init()
103 if (sys_thread || !cq->sys_thread_req_count) in optee_cq_wait_init()
108 if (cq->free_thread_count > free_thread_threshold) { in optee_cq_wait_init()
109 cq->free_thread_count--; in optee_cq_wait_init()
113 mutex_unlock(&cq->mutex); in optee_cq_wait_init()
117 void optee_cq_wait_for_completion(struct optee_call_queue *cq, in optee_cq_wait_for_completion() argument
122 mutex_lock(&cq->mutex); in optee_cq_wait_for_completion()
127 list_add_tail(&w->list_node, &cq->waiters); in optee_cq_wait_for_completion()
129 mutex_unlock(&cq->mutex); in optee_cq_wait_for_completion()
132 static void optee_cq_complete_one(struct optee_call_queue *cq) in optee_cq_complete_one() argument
137 list_for_each_entry(w, &cq->waiters, list_node) { in optee_cq_complete_one()
144 list_for_each_entry(w, &cq->waiters, list_node) { in optee_cq_complete_one()
152 void optee_cq_wait_final(struct optee_call_queue *cq, in optee_cq_wait_final() argument
160 mutex_lock(&cq->mutex); in optee_cq_wait_final()
165 cq->free_thread_count++; in optee_cq_wait_final()
168 optee_cq_complete_one(cq); in optee_cq_wait_final()
177 optee_cq_complete_one(cq); in optee_cq_wait_final()
179 mutex_unlock(&cq->mutex); in optee_cq_wait_final()
183 static bool optee_cq_incr_sys_thread_count(struct optee_call_queue *cq) in optee_cq_incr_sys_thread_count() argument
185 if (cq->total_thread_count <= 1) in optee_cq_incr_sys_thread_count()
188 mutex_lock(&cq->mutex); in optee_cq_incr_sys_thread_count()
189 cq->sys_thread_req_count++; in optee_cq_incr_sys_thread_count()
190 mutex_unlock(&cq->mutex); in optee_cq_incr_sys_thread_count()
195 static void optee_cq_decr_sys_thread_count(struct optee_call_queue *cq) in optee_cq_decr_sys_thread_count() argument
197 mutex_lock(&cq->mutex); in optee_cq_decr_sys_thread_count()
198 cq->sys_thread_req_count--; in optee_cq_decr_sys_thread_count()
200 optee_cq_complete_one(cq); in optee_cq_decr_sys_thread_count()
201 mutex_unlock(&cq->mutex); in optee_cq_decr_sys_thread_count()