Lines Matching refs:thread
68 struct cmdq_thread *thread; member
78 struct cmdq_thread *thread; member
101 static int cmdq_thread_suspend(struct cmdq *cmdq, struct cmdq_thread *thread) in cmdq_thread_suspend() argument
105 writel(CMDQ_THR_SUSPEND, thread->base + CMDQ_THR_SUSPEND_TASK); in cmdq_thread_suspend()
108 if (!(readl(thread->base + CMDQ_THR_ENABLE_TASK) & CMDQ_THR_ENABLED)) in cmdq_thread_suspend()
111 if (readl_poll_timeout_atomic(thread->base + CMDQ_THR_CURR_STATUS, in cmdq_thread_suspend()
114 (u32)(thread->base - cmdq->base)); in cmdq_thread_suspend()
121 static void cmdq_thread_resume(struct cmdq_thread *thread) in cmdq_thread_resume() argument
123 writel(CMDQ_THR_RESUME, thread->base + CMDQ_THR_SUSPEND_TASK); in cmdq_thread_resume()
139 static int cmdq_thread_reset(struct cmdq *cmdq, struct cmdq_thread *thread) in cmdq_thread_reset() argument
143 writel(CMDQ_THR_DO_WARM_RESET, thread->base + CMDQ_THR_WARM_RESET); in cmdq_thread_reset()
144 if (readl_poll_timeout_atomic(thread->base + CMDQ_THR_WARM_RESET, in cmdq_thread_reset()
148 (u32)(thread->base - cmdq->base)); in cmdq_thread_reset()
155 static void cmdq_thread_disable(struct cmdq *cmdq, struct cmdq_thread *thread) in cmdq_thread_disable() argument
157 cmdq_thread_reset(cmdq, thread); in cmdq_thread_disable()
158 writel(CMDQ_THR_DISABLED, thread->base + CMDQ_THR_ENABLE_TASK); in cmdq_thread_disable()
162 static void cmdq_thread_invalidate_fetched_data(struct cmdq_thread *thread) in cmdq_thread_invalidate_fetched_data() argument
164 writel(readl(thread->base + CMDQ_THR_CURR_ADDR), in cmdq_thread_invalidate_fetched_data()
165 thread->base + CMDQ_THR_CURR_ADDR); in cmdq_thread_invalidate_fetched_data()
171 struct cmdq_thread *thread = task->thread; in cmdq_task_insert_into_thread() local
173 &thread->task_busy_list, typeof(*task), list_entry); in cmdq_task_insert_into_thread()
185 cmdq_thread_invalidate_fetched_data(thread); in cmdq_task_insert_into_thread()
188 static bool cmdq_thread_is_in_wfe(struct cmdq_thread *thread) in cmdq_thread_is_in_wfe() argument
190 return readl(thread->base + CMDQ_THR_WAIT_TOKEN) & CMDQ_THR_IS_WAITING; in cmdq_thread_is_in_wfe()
199 mbox_chan_received_data(task->thread->chan, &data); in cmdq_task_exec_done()
206 struct cmdq_thread *thread = task->thread; in cmdq_task_handle_error() local
211 WARN_ON(cmdq_thread_suspend(cmdq, thread) < 0); in cmdq_task_handle_error()
212 next_task = list_first_entry_or_null(&thread->task_busy_list, in cmdq_task_handle_error()
216 thread->base + CMDQ_THR_CURR_ADDR); in cmdq_task_handle_error()
217 cmdq_thread_resume(thread); in cmdq_task_handle_error()
221 struct cmdq_thread *thread) in cmdq_thread_irq_handler() argument
227 irq_flag = readl(thread->base + CMDQ_THR_IRQ_STATUS); in cmdq_thread_irq_handler()
228 writel(~irq_flag, thread->base + CMDQ_THR_IRQ_STATUS); in cmdq_thread_irq_handler()
236 if (!(readl(thread->base + CMDQ_THR_ENABLE_TASK) & CMDQ_THR_ENABLED)) in cmdq_thread_irq_handler()
246 curr_pa = readl(thread->base + CMDQ_THR_CURR_ADDR) << cmdq->shift_pa; in cmdq_thread_irq_handler()
248 list_for_each_entry_safe(task, tmp, &thread->task_busy_list, in cmdq_thread_irq_handler()
267 if (list_empty(&thread->task_busy_list)) { in cmdq_thread_irq_handler()
268 cmdq_thread_disable(cmdq, thread); in cmdq_thread_irq_handler()
284 struct cmdq_thread *thread = &cmdq->thread[bit]; in cmdq_irq_handler() local
286 spin_lock_irqsave(&thread->chan->lock, flags); in cmdq_irq_handler()
287 cmdq_thread_irq_handler(cmdq, thread); in cmdq_irq_handler()
288 spin_unlock_irqrestore(&thread->chan->lock, flags); in cmdq_irq_handler()
297 struct cmdq_thread *thread; in cmdq_suspend() local
304 thread = &cmdq->thread[i]; in cmdq_suspend()
305 if (!list_empty(&thread->task_busy_list)) { in cmdq_suspend()
339 struct cmdq_thread *thread = (struct cmdq_thread *)chan->con_priv; in cmdq_mbox_send_data() local
354 task->thread = thread; in cmdq_mbox_send_data()
357 if (list_empty(&thread->task_busy_list)) { in cmdq_mbox_send_data()
366 WARN_ON(cmdq_thread_reset(cmdq, thread) < 0); in cmdq_mbox_send_data()
369 thread->base + CMDQ_THR_CURR_ADDR); in cmdq_mbox_send_data()
371 thread->base + CMDQ_THR_END_ADDR); in cmdq_mbox_send_data()
373 writel(thread->priority, thread->base + CMDQ_THR_PRIORITY); in cmdq_mbox_send_data()
374 writel(CMDQ_THR_IRQ_EN, thread->base + CMDQ_THR_IRQ_ENABLE); in cmdq_mbox_send_data()
375 writel(CMDQ_THR_ENABLED, thread->base + CMDQ_THR_ENABLE_TASK); in cmdq_mbox_send_data()
377 WARN_ON(cmdq_thread_suspend(cmdq, thread) < 0); in cmdq_mbox_send_data()
378 curr_pa = readl(thread->base + CMDQ_THR_CURR_ADDR) << in cmdq_mbox_send_data()
380 end_pa = readl(thread->base + CMDQ_THR_END_ADDR) << in cmdq_mbox_send_data()
387 thread->base + CMDQ_THR_CURR_ADDR); in cmdq_mbox_send_data()
393 thread->base + CMDQ_THR_END_ADDR); in cmdq_mbox_send_data()
394 cmdq_thread_resume(thread); in cmdq_mbox_send_data()
396 list_move_tail(&task->list_entry, &thread->task_busy_list); in cmdq_mbox_send_data()
408 struct cmdq_thread *thread = (struct cmdq_thread *)chan->con_priv; in cmdq_mbox_shutdown() local
413 spin_lock_irqsave(&thread->chan->lock, flags); in cmdq_mbox_shutdown()
414 if (list_empty(&thread->task_busy_list)) in cmdq_mbox_shutdown()
417 WARN_ON(cmdq_thread_suspend(cmdq, thread) < 0); in cmdq_mbox_shutdown()
420 cmdq_thread_irq_handler(cmdq, thread); in cmdq_mbox_shutdown()
421 if (list_empty(&thread->task_busy_list)) in cmdq_mbox_shutdown()
424 list_for_each_entry_safe(task, tmp, &thread->task_busy_list, in cmdq_mbox_shutdown()
430 cmdq_thread_disable(cmdq, thread); in cmdq_mbox_shutdown()
440 spin_unlock_irqrestore(&thread->chan->lock, flags); in cmdq_mbox_shutdown()
445 struct cmdq_thread *thread = (struct cmdq_thread *)chan->con_priv; in cmdq_mbox_flush() local
452 spin_lock_irqsave(&thread->chan->lock, flags); in cmdq_mbox_flush()
453 if (list_empty(&thread->task_busy_list)) in cmdq_mbox_flush()
456 WARN_ON(cmdq_thread_suspend(cmdq, thread) < 0); in cmdq_mbox_flush()
457 if (!cmdq_thread_is_in_wfe(thread)) in cmdq_mbox_flush()
460 list_for_each_entry_safe(task, tmp, &thread->task_busy_list, in cmdq_mbox_flush()
464 mbox_chan_received_data(task->thread->chan, &data); in cmdq_mbox_flush()
469 cmdq_thread_resume(thread); in cmdq_mbox_flush()
470 cmdq_thread_disable(cmdq, thread); in cmdq_mbox_flush()
474 spin_unlock_irqrestore(&thread->chan->lock, flags); in cmdq_mbox_flush()
478 cmdq_thread_resume(thread); in cmdq_mbox_flush()
479 spin_unlock_irqrestore(&thread->chan->lock, flags); in cmdq_mbox_flush()
480 if (readl_poll_timeout_atomic(thread->base + CMDQ_THR_ENABLE_TASK, in cmdq_mbox_flush()
483 (u32)(thread->base - cmdq->base)); in cmdq_mbox_flush()
501 struct cmdq_thread *thread; in cmdq_xlate() local
506 thread = (struct cmdq_thread *)mbox->chans[ind].con_priv; in cmdq_xlate()
507 thread->priority = sp->args[1]; in cmdq_xlate()
508 thread->chan = &mbox->chans[ind]; in cmdq_xlate()
596 cmdq->thread = devm_kcalloc(dev, cmdq->thread_nr, in cmdq_probe()
597 sizeof(*cmdq->thread), GFP_KERNEL); in cmdq_probe()
598 if (!cmdq->thread) in cmdq_probe()
602 cmdq->thread[i].base = cmdq->base + CMDQ_THR_BASE + in cmdq_probe()
604 INIT_LIST_HEAD(&cmdq->thread[i].task_busy_list); in cmdq_probe()
605 cmdq->mbox.chans[i].con_priv = (void *)&cmdq->thread[i]; in cmdq_probe()