Lines Matching refs:thread
70 struct cmdq_thread *thread; member
80 struct cmdq_thread *thread; member
113 static int cmdq_thread_suspend(struct cmdq *cmdq, struct cmdq_thread *thread) in cmdq_thread_suspend() argument
117 writel(CMDQ_THR_SUSPEND, thread->base + CMDQ_THR_SUSPEND_TASK); in cmdq_thread_suspend()
120 if (!(readl(thread->base + CMDQ_THR_ENABLE_TASK) & CMDQ_THR_ENABLED)) in cmdq_thread_suspend()
123 if (readl_poll_timeout_atomic(thread->base + CMDQ_THR_CURR_STATUS, in cmdq_thread_suspend()
126 (u32)(thread->base - cmdq->base)); in cmdq_thread_suspend()
133 static void cmdq_thread_resume(struct cmdq_thread *thread) in cmdq_thread_resume() argument
135 writel(CMDQ_THR_RESUME, thread->base + CMDQ_THR_SUSPEND_TASK); in cmdq_thread_resume()
158 static int cmdq_thread_reset(struct cmdq *cmdq, struct cmdq_thread *thread) in cmdq_thread_reset() argument
162 writel(CMDQ_THR_DO_WARM_RESET, thread->base + CMDQ_THR_WARM_RESET); in cmdq_thread_reset()
163 if (readl_poll_timeout_atomic(thread->base + CMDQ_THR_WARM_RESET, in cmdq_thread_reset()
167 (u32)(thread->base - cmdq->base)); in cmdq_thread_reset()
174 static void cmdq_thread_disable(struct cmdq *cmdq, struct cmdq_thread *thread) in cmdq_thread_disable() argument
176 cmdq_thread_reset(cmdq, thread); in cmdq_thread_disable()
177 writel(CMDQ_THR_DISABLED, thread->base + CMDQ_THR_ENABLE_TASK); in cmdq_thread_disable()
181 static void cmdq_thread_invalidate_fetched_data(struct cmdq_thread *thread) in cmdq_thread_invalidate_fetched_data() argument
183 writel(readl(thread->base + CMDQ_THR_CURR_ADDR), in cmdq_thread_invalidate_fetched_data()
184 thread->base + CMDQ_THR_CURR_ADDR); in cmdq_thread_invalidate_fetched_data()
190 struct cmdq_thread *thread = task->thread; in cmdq_task_insert_into_thread() local
192 &thread->task_busy_list, typeof(*task), list_entry); in cmdq_task_insert_into_thread()
204 cmdq_thread_invalidate_fetched_data(thread); in cmdq_task_insert_into_thread()
207 static bool cmdq_thread_is_in_wfe(struct cmdq_thread *thread) in cmdq_thread_is_in_wfe() argument
209 return readl(thread->base + CMDQ_THR_WAIT_TOKEN) & CMDQ_THR_IS_WAITING; in cmdq_thread_is_in_wfe()
218 mbox_chan_received_data(task->thread->chan, &data); in cmdq_task_exec_done()
225 struct cmdq_thread *thread = task->thread; in cmdq_task_handle_error() local
230 WARN_ON(cmdq_thread_suspend(cmdq, thread) < 0); in cmdq_task_handle_error()
231 next_task = list_first_entry_or_null(&thread->task_busy_list, in cmdq_task_handle_error()
235 thread->base + CMDQ_THR_CURR_ADDR); in cmdq_task_handle_error()
236 cmdq_thread_resume(thread); in cmdq_task_handle_error()
240 struct cmdq_thread *thread) in cmdq_thread_irq_handler() argument
246 irq_flag = readl(thread->base + CMDQ_THR_IRQ_STATUS); in cmdq_thread_irq_handler()
247 writel(~irq_flag, thread->base + CMDQ_THR_IRQ_STATUS); in cmdq_thread_irq_handler()
255 if (!(readl(thread->base + CMDQ_THR_ENABLE_TASK) & CMDQ_THR_ENABLED)) in cmdq_thread_irq_handler()
265 curr_pa = readl(thread->base + CMDQ_THR_CURR_ADDR) << cmdq->pdata->shift; in cmdq_thread_irq_handler()
267 list_for_each_entry_safe(task, tmp, &thread->task_busy_list, in cmdq_thread_irq_handler()
286 if (list_empty(&thread->task_busy_list)) { in cmdq_thread_irq_handler()
287 cmdq_thread_disable(cmdq, thread); in cmdq_thread_irq_handler()
303 struct cmdq_thread *thread = &cmdq->thread[bit]; in cmdq_irq_handler() local
305 spin_lock_irqsave(&thread->chan->lock, flags); in cmdq_irq_handler()
306 cmdq_thread_irq_handler(cmdq, thread); in cmdq_irq_handler()
307 spin_unlock_irqrestore(&thread->chan->lock, flags); in cmdq_irq_handler()
316 struct cmdq_thread *thread; in cmdq_suspend() local
323 thread = &cmdq->thread[i]; in cmdq_suspend()
324 if (!list_empty(&thread->task_busy_list)) { in cmdq_suspend()
368 struct cmdq_thread *thread = (struct cmdq_thread *)chan->con_priv; in cmdq_mbox_send_data() local
383 task->thread = thread; in cmdq_mbox_send_data()
386 if (list_empty(&thread->task_busy_list)) { in cmdq_mbox_send_data()
395 WARN_ON(cmdq_thread_reset(cmdq, thread) < 0); in cmdq_mbox_send_data()
398 thread->base + CMDQ_THR_CURR_ADDR); in cmdq_mbox_send_data()
400 thread->base + CMDQ_THR_END_ADDR); in cmdq_mbox_send_data()
402 writel(thread->priority, thread->base + CMDQ_THR_PRIORITY); in cmdq_mbox_send_data()
403 writel(CMDQ_THR_IRQ_EN, thread->base + CMDQ_THR_IRQ_ENABLE); in cmdq_mbox_send_data()
404 writel(CMDQ_THR_ENABLED, thread->base + CMDQ_THR_ENABLE_TASK); in cmdq_mbox_send_data()
406 WARN_ON(cmdq_thread_suspend(cmdq, thread) < 0); in cmdq_mbox_send_data()
407 curr_pa = readl(thread->base + CMDQ_THR_CURR_ADDR) << in cmdq_mbox_send_data()
409 end_pa = readl(thread->base + CMDQ_THR_END_ADDR) << in cmdq_mbox_send_data()
416 thread->base + CMDQ_THR_CURR_ADDR); in cmdq_mbox_send_data()
422 thread->base + CMDQ_THR_END_ADDR); in cmdq_mbox_send_data()
423 cmdq_thread_resume(thread); in cmdq_mbox_send_data()
425 list_move_tail(&task->list_entry, &thread->task_busy_list); in cmdq_mbox_send_data()
437 struct cmdq_thread *thread = (struct cmdq_thread *)chan->con_priv; in cmdq_mbox_shutdown() local
442 spin_lock_irqsave(&thread->chan->lock, flags); in cmdq_mbox_shutdown()
443 if (list_empty(&thread->task_busy_list)) in cmdq_mbox_shutdown()
446 WARN_ON(cmdq_thread_suspend(cmdq, thread) < 0); in cmdq_mbox_shutdown()
449 cmdq_thread_irq_handler(cmdq, thread); in cmdq_mbox_shutdown()
450 if (list_empty(&thread->task_busy_list)) in cmdq_mbox_shutdown()
453 list_for_each_entry_safe(task, tmp, &thread->task_busy_list, in cmdq_mbox_shutdown()
459 cmdq_thread_disable(cmdq, thread); in cmdq_mbox_shutdown()
469 spin_unlock_irqrestore(&thread->chan->lock, flags); in cmdq_mbox_shutdown()
474 struct cmdq_thread *thread = (struct cmdq_thread *)chan->con_priv; in cmdq_mbox_flush() local
481 spin_lock_irqsave(&thread->chan->lock, flags); in cmdq_mbox_flush()
482 if (list_empty(&thread->task_busy_list)) in cmdq_mbox_flush()
485 WARN_ON(cmdq_thread_suspend(cmdq, thread) < 0); in cmdq_mbox_flush()
486 if (!cmdq_thread_is_in_wfe(thread)) in cmdq_mbox_flush()
489 list_for_each_entry_safe(task, tmp, &thread->task_busy_list, in cmdq_mbox_flush()
493 mbox_chan_received_data(task->thread->chan, &data); in cmdq_mbox_flush()
498 cmdq_thread_resume(thread); in cmdq_mbox_flush()
499 cmdq_thread_disable(cmdq, thread); in cmdq_mbox_flush()
503 spin_unlock_irqrestore(&thread->chan->lock, flags); in cmdq_mbox_flush()
507 cmdq_thread_resume(thread); in cmdq_mbox_flush()
508 spin_unlock_irqrestore(&thread->chan->lock, flags); in cmdq_mbox_flush()
509 if (readl_poll_timeout_atomic(thread->base + CMDQ_THR_ENABLE_TASK, in cmdq_mbox_flush()
512 (u32)(thread->base - cmdq->base)); in cmdq_mbox_flush()
530 struct cmdq_thread *thread; in cmdq_xlate() local
535 thread = (struct cmdq_thread *)mbox->chans[ind].con_priv; in cmdq_xlate()
536 thread->priority = sp->args[1]; in cmdq_xlate()
537 thread->chan = &mbox->chans[ind]; in cmdq_xlate()
614 cmdq->thread = devm_kcalloc(dev, cmdq->pdata->thread_nr, in cmdq_probe()
615 sizeof(*cmdq->thread), GFP_KERNEL); in cmdq_probe()
616 if (!cmdq->thread) in cmdq_probe()
620 cmdq->thread[i].base = cmdq->base + CMDQ_THR_BASE + in cmdq_probe()
622 INIT_LIST_HEAD(&cmdq->thread[i].task_busy_list); in cmdq_probe()
623 cmdq->mbox.chans[i].con_priv = (void *)&cmdq->thread[i]; in cmdq_probe()