Lines Matching +full:current +full:- +full:rotate

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2020-21 Intel Corporation.
15 unsigned int q_rpos = ipc_task->q_rpos; in ipc_task_queue_handler()
18 while (q_rpos != ipc_task->q_wpos) { in ipc_task_queue_handler()
19 /* Get the current first queue element. */ in ipc_task_queue_handler()
20 struct ipc_task_queue_args *args = &ipc_task->args[q_rpos]; in ipc_task_queue_handler()
23 if (args->func) in ipc_task_queue_handler()
24 args->response = args->func(args->ipc_imem, args->arg, in ipc_task_queue_handler()
25 args->msg, args->size); in ipc_task_queue_handler()
28 if (args->completion) in ipc_task_queue_handler()
29 complete(args->completion); in ipc_task_queue_handler()
32 if (args->is_copy) in ipc_task_queue_handler()
33 kfree(args->msg); in ipc_task_queue_handler()
39 * ipc_task element, queue will not rotate again to in ipc_task_queue_handler()
42 args->completion = NULL; in ipc_task_queue_handler()
43 args->func = NULL; in ipc_task_queue_handler()
44 args->msg = NULL; in ipc_task_queue_handler()
45 args->size = 0; in ipc_task_queue_handler()
46 args->is_copy = false; in ipc_task_queue_handler()
52 ipc_task->q_rpos = q_rpos; in ipc_task_queue_handler()
59 unsigned int q_rpos = ipc_task->q_rpos; in ipc_task_queue_cleanup()
61 while (q_rpos != ipc_task->q_wpos) { in ipc_task_queue_cleanup()
62 struct ipc_task_queue_args *args = &ipc_task->args[q_rpos]; in ipc_task_queue_cleanup()
64 if (args->completion) in ipc_task_queue_cleanup()
65 complete(args->completion); in ipc_task_queue_cleanup()
67 if (args->is_copy) in ipc_task_queue_cleanup()
68 kfree(args->msg); in ipc_task_queue_cleanup()
71 ipc_task->q_rpos = q_rpos; in ipc_task_queue_cleanup()
83 struct tasklet_struct *ipc_tasklet = ipc_imem->ipc_task->ipc_tasklet; in ipc_task_queue_add_task()
84 struct ipc_task_queue *ipc_task = &ipc_imem->ipc_task->ipc_queue; in ipc_task_queue_add_task()
88 int result = -EIO; in ipc_task_queue_add_task()
95 spin_lock_irqsave(&ipc_task->q_lock, flags); in ipc_task_queue_add_task()
97 pos = ipc_task->q_wpos; in ipc_task_queue_add_task()
101 if (nextpos != ipc_task->q_rpos) { in ipc_task_queue_add_task()
105 ipc_task->args[pos].arg = arg; in ipc_task_queue_add_task()
106 ipc_task->args[pos].msg = msg; in ipc_task_queue_add_task()
107 ipc_task->args[pos].func = func; in ipc_task_queue_add_task()
108 ipc_task->args[pos].ipc_imem = ipc_imem; in ipc_task_queue_add_task()
109 ipc_task->args[pos].size = size; in ipc_task_queue_add_task()
110 ipc_task->args[pos].is_copy = is_copy; in ipc_task_queue_add_task()
111 ipc_task->args[pos].completion = wait ? &completion : NULL; in ipc_task_queue_add_task()
112 ipc_task->args[pos].response = -1; in ipc_task_queue_add_task()
114 /* apply write barrier so that ipc_task->q_rpos elements in ipc_task_queue_add_task()
115 * are updated before ipc_task->q_wpos is being updated. in ipc_task_queue_add_task()
120 ipc_task->q_wpos = nextpos; in ipc_task_queue_add_task()
124 spin_unlock_irqrestore(&ipc_task->q_lock, flags); in ipc_task_queue_add_task()
131 result = ipc_task->args[pos].response; in ipc_task_queue_add_task()
134 dev_err(ipc_imem->ipc_task->dev, "queue is full"); in ipc_task_queue_add_task()
147 int ret = -ENOMEM; in ipc_task_queue_send_task()
160 dev_err(imem->ipc_task->dev, in ipc_task_queue_send_task()
175 struct ipc_task_queue *ipc_queue = &ipc_task->ipc_queue; in ipc_task_init()
177 ipc_task->ipc_tasklet = kzalloc(sizeof(*ipc_task->ipc_tasklet), in ipc_task_init()
180 if (!ipc_task->ipc_tasklet) in ipc_task_init()
181 return -ENOMEM; in ipc_task_init()
186 spin_lock_init(&ipc_queue->q_lock); in ipc_task_init()
188 tasklet_init(ipc_task->ipc_tasklet, ipc_task_queue_handler, in ipc_task_init()
195 tasklet_kill(ipc_task->ipc_tasklet); in ipc_task_deinit()
197 kfree(ipc_task->ipc_tasklet); in ipc_task_deinit()
201 ipc_task_queue_cleanup(&ipc_task->ipc_queue); in ipc_task_deinit()