Lines Matching refs:ipc

23 	struct avs_ipc *ipc = adev->ipc;  in avs_dsp_set_d0ix()  local
27 if (ipc->in_d0ix == enable) in avs_dsp_set_d0ix()
34 atomic_inc(&ipc->d0ix_disable_depth); in avs_dsp_set_d0ix()
36 ipc->in_d0ix = false; in avs_dsp_set_d0ix()
40 ipc->in_d0ix = enable; in avs_dsp_set_d0ix()
46 if (atomic_read(&adev->ipc->d0ix_disable_depth)) in avs_dsp_schedule_d0ix()
49 mod_delayed_work(system_power_efficient_wq, &adev->ipc->d0ix_work, in avs_dsp_schedule_d0ix()
55 struct avs_ipc *ipc = container_of(work, struct avs_ipc, d0ix_work.work); in avs_dsp_d0ix_work() local
57 avs_dsp_set_d0ix(to_avs_dev(ipc->dev), true); in avs_dsp_d0ix_work()
62 struct avs_ipc *ipc = adev->ipc; in avs_dsp_wake_d0i0() local
64 if (!atomic_read(&ipc->d0ix_disable_depth)) { in avs_dsp_wake_d0i0()
65 cancel_delayed_work_sync(&ipc->d0ix_work); in avs_dsp_wake_d0i0()
74 struct avs_ipc *ipc = adev->ipc; in avs_dsp_disable_d0ix() local
77 if (atomic_inc_return(&ipc->d0ix_disable_depth) == 1) { in avs_dsp_disable_d0ix()
78 cancel_delayed_work_sync(&ipc->d0ix_work); in avs_dsp_disable_d0ix()
87 struct avs_ipc *ipc = adev->ipc; in avs_dsp_enable_d0ix() local
89 if (atomic_dec_and_test(&ipc->d0ix_disable_depth)) in avs_dsp_enable_d0ix()
90 queue_delayed_work(system_power_efficient_wq, &ipc->d0ix_work, in avs_dsp_enable_d0ix()
148 atomic_set(&adev->ipc->recovering, 0); in avs_dsp_recovery()
153 struct avs_ipc *ipc = container_of(work, struct avs_ipc, recovery_work); in avs_dsp_recovery_work() local
155 avs_dsp_recovery(to_avs_dev(ipc->dev)); in avs_dsp_recovery_work()
160 struct avs_ipc *ipc = adev->ipc; in avs_dsp_exception_caught() local
163 ipc->ready = false; in avs_dsp_exception_caught()
165 if (!atomic_add_unless(&ipc->recovering, 1, 1)) { in avs_dsp_exception_caught()
172 cancel_delayed_work_sync(&ipc->d0ix_work); in avs_dsp_exception_caught()
173 ipc->in_d0ix = false; in avs_dsp_exception_caught()
180 schedule_work(&ipc->recovery_work); in avs_dsp_exception_caught()
185 struct avs_ipc *ipc = adev->ipc; in avs_dsp_receive_rx() local
192 ipc->rx.header = header; in avs_dsp_receive_rx()
198 ipc->rx.size = min_t(u32, AVS_MAILBOX_SIZE, in avs_dsp_receive_rx()
201 memcpy_fromio(ipc->rx.data, avs_uplink_addr(adev), ipc->rx.size); in avs_dsp_receive_rx()
202 trace_avs_msg_payload(ipc->rx.data, ipc->rx.size); in avs_dsp_receive_rx()
218 if (!adev->ipc->ready && msg.notify_msg_type != AVS_NOTIFY_FW_READY) { in avs_dsp_process_notification()
264 adev->ipc->ready = true; in avs_dsp_process_notification()
285 struct avs_ipc *ipc = adev->ipc; in avs_dsp_process_response() local
293 spin_lock_irq(&ipc->rx_lock); in avs_dsp_process_response()
295 ipc->rx_completed = true; in avs_dsp_process_response()
296 spin_unlock_irq(&ipc->rx_lock); in avs_dsp_process_response()
301 complete(&ipc->busy_completion); in avs_dsp_process_response()
307 struct avs_ipc *ipc = adev->ipc; in avs_dsp_irq_handler() local
327 complete(&ipc->done_completion); in avs_dsp_irq_handler()
379 static bool avs_ipc_is_busy(struct avs_ipc *ipc) in avs_ipc_is_busy() argument
381 struct avs_dev *adev = to_avs_dev(ipc->dev); in avs_ipc_is_busy()
388 static int avs_ipc_wait_busy_completion(struct avs_ipc *ipc, int timeout) in avs_ipc_wait_busy_completion() argument
394 ret = wait_for_completion_timeout(&ipc->busy_completion, msecs_to_jiffies(timeout)); in avs_ipc_wait_busy_completion()
397 if (!ipc->ready) in avs_ipc_wait_busy_completion()
401 if (!avs_ipc_is_busy(ipc)) in avs_ipc_wait_busy_completion()
407 wait_for_completion_killable(&ipc->busy_completion); in avs_ipc_wait_busy_completion()
411 spin_lock(&ipc->rx_lock); in avs_ipc_wait_busy_completion()
412 if (!ipc->rx_completed) { in avs_ipc_wait_busy_completion()
416 reinit_completion(&ipc->busy_completion); in avs_ipc_wait_busy_completion()
417 spin_unlock(&ipc->rx_lock); in avs_ipc_wait_busy_completion()
421 spin_unlock(&ipc->rx_lock); in avs_ipc_wait_busy_completion()
425 spin_unlock(&ipc->rx_lock); in avs_ipc_wait_busy_completion()
429 static void avs_ipc_msg_init(struct avs_ipc *ipc, struct avs_ipc_msg *reply) in avs_ipc_msg_init() argument
431 lockdep_assert_held(&ipc->rx_lock); in avs_ipc_msg_init()
433 ipc->rx.header = 0; in avs_ipc_msg_init()
434 ipc->rx.size = reply ? reply->size : 0; in avs_ipc_msg_init()
435 ipc->rx_completed = false; in avs_ipc_msg_init()
437 reinit_completion(&ipc->done_completion); in avs_ipc_msg_init()
438 reinit_completion(&ipc->busy_completion); in avs_ipc_msg_init()
460 struct avs_ipc *ipc = adev->ipc; in avs_dsp_do_send_msg() local
463 if (!ipc->ready) in avs_dsp_do_send_msg()
466 mutex_lock(&ipc->msg_mutex); in avs_dsp_do_send_msg()
468 spin_lock(&ipc->rx_lock); in avs_dsp_do_send_msg()
469 avs_ipc_msg_init(ipc, reply); in avs_dsp_do_send_msg()
471 spin_unlock(&ipc->rx_lock); in avs_dsp_do_send_msg()
473 ret = avs_ipc_wait_busy_completion(ipc, timeout); in avs_dsp_do_send_msg()
484 ret = ipc->rx.rsp.status; in avs_dsp_do_send_msg()
486 reply->header = ipc->rx.header; in avs_dsp_do_send_msg()
487 reply->size = ipc->rx.size; in avs_dsp_do_send_msg()
488 if (reply->data && ipc->rx.size) in avs_dsp_do_send_msg()
489 memcpy(reply->data, ipc->rx.data, reply->size); in avs_dsp_do_send_msg()
493 mutex_unlock(&ipc->msg_mutex); in avs_dsp_do_send_msg()
533 return avs_dsp_send_msg_timeout(adev, request, reply, adev->ipc->default_timeout_ms); in avs_dsp_send_msg()
545 return avs_dsp_send_pm_msg_timeout(adev, request, reply, adev->ipc->default_timeout_ms, in avs_dsp_send_pm_msg()
551 struct avs_ipc *ipc = adev->ipc; in avs_dsp_do_send_rom_msg() local
554 mutex_lock(&ipc->msg_mutex); in avs_dsp_do_send_rom_msg()
556 spin_lock(&ipc->rx_lock); in avs_dsp_do_send_rom_msg()
557 avs_ipc_msg_init(ipc, NULL); in avs_dsp_do_send_rom_msg()
563 spin_unlock(&ipc->rx_lock); in avs_dsp_do_send_rom_msg()
568 ret = wait_for_completion_timeout(&ipc->done_completion, msecs_to_jiffies(timeout)); in avs_dsp_do_send_rom_msg()
572 mutex_unlock(&ipc->msg_mutex); in avs_dsp_do_send_rom_msg()
584 return avs_dsp_send_rom_msg_timeout(adev, request, adev->ipc->default_timeout_ms); in avs_dsp_send_rom_msg()
603 int avs_ipc_init(struct avs_ipc *ipc, struct device *dev) in avs_ipc_init() argument
605 ipc->rx.data = devm_kzalloc(dev, AVS_MAILBOX_SIZE, GFP_KERNEL); in avs_ipc_init()
606 if (!ipc->rx.data) in avs_ipc_init()
609 ipc->dev = dev; in avs_ipc_init()
610 ipc->ready = false; in avs_ipc_init()
611 ipc->default_timeout_ms = AVS_IPC_TIMEOUT_MS; in avs_ipc_init()
612 INIT_WORK(&ipc->recovery_work, avs_dsp_recovery_work); in avs_ipc_init()
613 INIT_DELAYED_WORK(&ipc->d0ix_work, avs_dsp_d0ix_work); in avs_ipc_init()
614 init_completion(&ipc->done_completion); in avs_ipc_init()
615 init_completion(&ipc->busy_completion); in avs_ipc_init()
616 spin_lock_init(&ipc->rx_lock); in avs_ipc_init()
617 mutex_init(&ipc->msg_mutex); in avs_ipc_init()
622 void avs_ipc_block(struct avs_ipc *ipc) in avs_ipc_block() argument
624 ipc->ready = false; in avs_ipc_block()
625 cancel_work_sync(&ipc->recovery_work); in avs_ipc_block()
626 cancel_delayed_work_sync(&ipc->d0ix_work); in avs_ipc_block()
627 ipc->in_d0ix = false; in avs_ipc_block()