Lines Matching +full:ipc +full:- +full:3

1 // SPDX-License-Identifier: GPL-2.0-only
16 void catpt_ipc_init(struct catpt_ipc *ipc, struct device *dev) in catpt_ipc_init() argument
18 ipc->dev = dev; in catpt_ipc_init()
19 ipc->ready = false; in catpt_ipc_init()
20 ipc->default_timeout = CATPT_IPC_TIMEOUT_MS; in catpt_ipc_init()
21 init_completion(&ipc->done_completion); in catpt_ipc_init()
22 init_completion(&ipc->busy_completion); in catpt_ipc_init()
23 spin_lock_init(&ipc->lock); in catpt_ipc_init()
24 mutex_init(&ipc->mutex); in catpt_ipc_init()
27 static int catpt_ipc_arm(struct catpt_ipc *ipc, struct catpt_fw_ready *config) in catpt_ipc_arm() argument
34 ipc->rx.data = devm_kzalloc(ipc->dev, config->outbox_size, GFP_KERNEL); in catpt_ipc_arm()
35 if (!ipc->rx.data) in catpt_ipc_arm()
36 return -ENOMEM; in catpt_ipc_arm()
38 memcpy(&ipc->config, config, sizeof(*config)); in catpt_ipc_arm()
39 ipc->ready = true; in catpt_ipc_arm()
44 static void catpt_ipc_msg_init(struct catpt_ipc *ipc, in catpt_ipc_msg_init() argument
47 lockdep_assert_held(&ipc->lock); in catpt_ipc_msg_init()
49 ipc->rx.header = 0; in catpt_ipc_msg_init()
50 ipc->rx.size = reply ? reply->size : 0; in catpt_ipc_msg_init()
51 reinit_completion(&ipc->done_completion); in catpt_ipc_msg_init()
52 reinit_completion(&ipc->busy_completion); in catpt_ipc_msg_init()
58 u32 header = tx->header | CATPT_IPCC_BUSY; in catpt_dsp_send_tx()
61 trace_catpt_ipc_payload(tx->data, tx->size); in catpt_dsp_send_tx()
63 memcpy_toio(catpt_outbox_addr(cdev), tx->data, tx->size); in catpt_dsp_send_tx()
69 struct catpt_ipc *ipc = &cdev->ipc; in catpt_wait_msg_completion() local
72 ret = wait_for_completion_timeout(&ipc->done_completion, in catpt_wait_msg_completion()
75 return -ETIMEDOUT; in catpt_wait_msg_completion()
76 if (ipc->rx.rsp.status != CATPT_REPLY_PENDING) in catpt_wait_msg_completion()
80 ret = wait_for_completion_timeout(&ipc->busy_completion, in catpt_wait_msg_completion()
82 return ret ? 0 : -ETIMEDOUT; in catpt_wait_msg_completion()
89 struct catpt_ipc *ipc = &cdev->ipc; in catpt_dsp_do_send_msg() local
93 if (!ipc->ready) in catpt_dsp_do_send_msg()
94 return -EPERM; in catpt_dsp_do_send_msg()
95 if (request.size > ipc->config.outbox_size || in catpt_dsp_do_send_msg()
96 (reply && reply->size > ipc->config.outbox_size)) in catpt_dsp_do_send_msg()
97 return -EINVAL; in catpt_dsp_do_send_msg()
99 spin_lock_irqsave(&ipc->lock, flags); in catpt_dsp_do_send_msg()
100 catpt_ipc_msg_init(ipc, reply); in catpt_dsp_do_send_msg()
102 spin_unlock_irqrestore(&ipc->lock, flags); in catpt_dsp_do_send_msg()
106 dev_crit(cdev->dev, "communication severed: %d, rebooting dsp..\n", in catpt_dsp_do_send_msg()
108 ipc->ready = false; in catpt_dsp_do_send_msg()
113 ret = ipc->rx.rsp.status; in catpt_dsp_do_send_msg()
115 reply->header = ipc->rx.header; in catpt_dsp_do_send_msg()
117 if (!ret && reply->data) in catpt_dsp_do_send_msg()
118 memcpy(reply->data, ipc->rx.data, reply->size); in catpt_dsp_do_send_msg()
128 struct catpt_ipc *ipc = &cdev->ipc; in catpt_dsp_send_msg_timeout() local
131 mutex_lock(&ipc->mutex); in catpt_dsp_send_msg_timeout()
133 mutex_unlock(&ipc->mutex); in catpt_dsp_send_msg_timeout()
142 cdev->ipc.default_timeout); in catpt_dsp_send_msg()
154 dev_warn(cdev->dev, "notify %d for non-existent stream %d\n", in catpt_dsp_notify_stream()
171 dev_warn(cdev->dev, "glitch %d at pos: 0x%08llx, wp: 0x%08x\n", in catpt_dsp_notify_stream()
177 dev_warn(cdev->dev, "unknown notification: %d received\n", in catpt_dsp_notify_stream()
185 struct catpt_ipc *ipc = &cdev->ipc; in catpt_dsp_copy_rx() local
187 ipc->rx.header = header; in catpt_dsp_copy_rx()
188 if (ipc->rx.rsp.status != CATPT_REPLY_SUCCESS) in catpt_dsp_copy_rx()
191 memcpy_fromio(ipc->rx.data, catpt_outbox_addr(cdev), ipc->rx.size); in catpt_dsp_copy_rx()
192 trace_catpt_ipc_payload(ipc->rx.data, ipc->rx.size); in catpt_dsp_copy_rx()
198 struct catpt_ipc *ipc = &cdev->ipc; in catpt_dsp_process_response() local
202 /* to fit 32b header original address is shifted right by 3 */ in catpt_dsp_process_response()
203 u32 off = msg.mailbox_address << 3; in catpt_dsp_process_response()
205 memcpy_fromio(&config, cdev->lpe_ba + off, sizeof(config)); in catpt_dsp_process_response()
208 catpt_ipc_arm(ipc, &config); in catpt_dsp_process_response()
209 complete(&cdev->fw_ready); in catpt_dsp_process_response()
215 dev_err(cdev->dev, "ADSP device coredump received\n"); in catpt_dsp_process_response()
216 ipc->ready = false; in catpt_dsp_process_response()
229 complete(&ipc->busy_completion); in catpt_dsp_process_response()
235 dev_warn(cdev->dev, "unknown response: %d received\n", in catpt_dsp_process_response()
281 complete(&cdev->ipc.done_completion); in catpt_dsp_irq_handler()