Lines Matching full:ipc

3  * Intel SST generic IPC Support
24 #include "sst-ipc.h"
26 /* IPC message timeout (msecs) */
32 static struct ipc_message *msg_get_empty(struct sst_generic_ipc *ipc) in msg_get_empty() argument
36 if (!list_empty(&ipc->empty_list)) { in msg_get_empty()
37 msg = list_first_entry(&ipc->empty_list, struct ipc_message, in msg_get_empty()
45 static int tx_wait_done(struct sst_generic_ipc *ipc, in tx_wait_done() argument
55 spin_lock_irqsave(&ipc->dsp->spinlock, flags); in tx_wait_done()
57 if (ipc->ops.shim_dbg != NULL) in tx_wait_done()
58 ipc->ops.shim_dbg(ipc, "message timeout"); in tx_wait_done()
73 list_add_tail(&msg->list, &ipc->empty_list); in tx_wait_done()
74 spin_unlock_irqrestore(&ipc->dsp->spinlock, flags); in tx_wait_done()
78 static int ipc_tx_message(struct sst_generic_ipc *ipc, in ipc_tx_message() argument
85 spin_lock_irqsave(&ipc->dsp->spinlock, flags); in ipc_tx_message()
87 msg = msg_get_empty(ipc); in ipc_tx_message()
89 spin_unlock_irqrestore(&ipc->dsp->spinlock, flags); in ipc_tx_message()
102 if ((request.size) && (ipc->ops.tx_data_copy != NULL)) in ipc_tx_message()
103 ipc->ops.tx_data_copy(msg, request.data, request.size); in ipc_tx_message()
105 list_add_tail(&msg->list, &ipc->tx_list); in ipc_tx_message()
106 schedule_work(&ipc->kwork); in ipc_tx_message()
107 spin_unlock_irqrestore(&ipc->dsp->spinlock, flags); in ipc_tx_message()
110 return tx_wait_done(ipc, msg, reply); in ipc_tx_message()
115 static int msg_empty_list_init(struct sst_generic_ipc *ipc) in msg_empty_list_init() argument
119 ipc->msg = kcalloc(IPC_EMPTY_LIST_SIZE, sizeof(struct ipc_message), in msg_empty_list_init()
121 if (ipc->msg == NULL) in msg_empty_list_init()
125 ipc->msg[i].tx.data = kzalloc(ipc->tx_data_max_size, GFP_KERNEL); in msg_empty_list_init()
126 if (ipc->msg[i].tx.data == NULL) in msg_empty_list_init()
129 ipc->msg[i].rx.data = kzalloc(ipc->rx_data_max_size, GFP_KERNEL); in msg_empty_list_init()
130 if (ipc->msg[i].rx.data == NULL) { in msg_empty_list_init()
131 kfree(ipc->msg[i].tx.data); in msg_empty_list_init()
135 init_waitqueue_head(&ipc->msg[i].waitq); in msg_empty_list_init()
136 list_add(&ipc->msg[i].list, &ipc->empty_list); in msg_empty_list_init()
143 kfree(ipc->msg[i-1].tx.data); in msg_empty_list_init()
144 kfree(ipc->msg[i-1].rx.data); in msg_empty_list_init()
147 kfree(ipc->msg); in msg_empty_list_init()
154 struct sst_generic_ipc *ipc = in ipc_tx_msgs() local
158 spin_lock_irq(&ipc->dsp->spinlock); in ipc_tx_msgs()
160 while (!list_empty(&ipc->tx_list) && !ipc->pending) { in ipc_tx_msgs()
165 if (ipc->ops.is_dsp_busy && ipc->ops.is_dsp_busy(ipc->dsp)) { in ipc_tx_msgs()
166 dev_dbg(ipc->dev, "ipc_tx_msgs dsp busy\n"); in ipc_tx_msgs()
170 msg = list_first_entry(&ipc->tx_list, struct ipc_message, list); in ipc_tx_msgs()
171 list_move(&msg->list, &ipc->rx_list); in ipc_tx_msgs()
173 if (ipc->ops.tx_msg != NULL) in ipc_tx_msgs()
174 ipc->ops.tx_msg(ipc, msg); in ipc_tx_msgs()
177 spin_unlock_irq(&ipc->dsp->spinlock); in ipc_tx_msgs()
180 int sst_ipc_tx_message_wait(struct sst_generic_ipc *ipc, in sst_ipc_tx_message_wait() argument
188 * if so invoke that before sending IPC in sst_ipc_tx_message_wait()
190 if (ipc->ops.check_dsp_lp_on) in sst_ipc_tx_message_wait()
191 if (ipc->ops.check_dsp_lp_on(ipc->dsp, true)) in sst_ipc_tx_message_wait()
194 ret = ipc_tx_message(ipc, request, reply, 1); in sst_ipc_tx_message_wait()
196 if (ipc->ops.check_dsp_lp_on) in sst_ipc_tx_message_wait()
197 if (ipc->ops.check_dsp_lp_on(ipc->dsp, false)) in sst_ipc_tx_message_wait()
204 int sst_ipc_tx_message_nowait(struct sst_generic_ipc *ipc, in sst_ipc_tx_message_nowait() argument
207 return ipc_tx_message(ipc, request, NULL, 0); in sst_ipc_tx_message_nowait()
211 int sst_ipc_tx_message_nopm(struct sst_generic_ipc *ipc, in sst_ipc_tx_message_nopm() argument
214 return ipc_tx_message(ipc, request, reply, 1); in sst_ipc_tx_message_nopm()
218 struct ipc_message *sst_ipc_reply_find_msg(struct sst_generic_ipc *ipc, in sst_ipc_reply_find_msg() argument
224 if (ipc->ops.reply_msg_match != NULL) in sst_ipc_reply_find_msg()
225 header = ipc->ops.reply_msg_match(header, &mask); in sst_ipc_reply_find_msg()
229 if (list_empty(&ipc->rx_list)) { in sst_ipc_reply_find_msg()
230 dev_err(ipc->dev, "error: rx list empty but received 0x%llx\n", in sst_ipc_reply_find_msg()
235 list_for_each_entry(msg, &ipc->rx_list, list) { in sst_ipc_reply_find_msg()
245 void sst_ipc_tx_msg_reply_complete(struct sst_generic_ipc *ipc, in sst_ipc_tx_msg_reply_complete() argument
251 list_add_tail(&msg->list, &ipc->empty_list); in sst_ipc_tx_msg_reply_complete()
257 int sst_ipc_init(struct sst_generic_ipc *ipc) in sst_ipc_init() argument
261 INIT_LIST_HEAD(&ipc->tx_list); in sst_ipc_init()
262 INIT_LIST_HEAD(&ipc->rx_list); in sst_ipc_init()
263 INIT_LIST_HEAD(&ipc->empty_list); in sst_ipc_init()
264 init_waitqueue_head(&ipc->wait_txq); in sst_ipc_init()
266 ret = msg_empty_list_init(ipc); in sst_ipc_init()
270 INIT_WORK(&ipc->kwork, ipc_tx_msgs); in sst_ipc_init()
275 void sst_ipc_fini(struct sst_generic_ipc *ipc) in sst_ipc_fini() argument
279 cancel_work_sync(&ipc->kwork); in sst_ipc_fini()
281 if (ipc->msg) { in sst_ipc_fini()
283 kfree(ipc->msg[i].tx.data); in sst_ipc_fini()
284 kfree(ipc->msg[i].rx.data); in sst_ipc_fini()
286 kfree(ipc->msg); in sst_ipc_fini()
293 MODULE_DESCRIPTION("Intel SST IPC generic");