Lines Matching refs:cons

66 ivpu_ipc_tx_prepare(struct ivpu_device *vdev, struct ivpu_ipc_consumer *cons,
101 tx_buf->ipc.channel = cons->channel;
111 cons->request_id = req->request_id;
114 cons->tx_vpu_addr = tx_buf_vpu_addr;
136 ivpu_ipc_rx_msg_add(struct ivpu_device *vdev, struct ivpu_ipc_consumer *cons,
155 rx_msg->callback = cons->rx_callback;
160 spin_lock(&cons->rx_lock);
161 list_add_tail(&rx_msg->link, &cons->rx_msg_list);
162 spin_unlock(&cons->rx_lock);
163 wake_up(&cons->rx_msg_wq);
176 void ivpu_ipc_consumer_add(struct ivpu_device *vdev, struct ivpu_ipc_consumer *cons,
181 INIT_LIST_HEAD(&cons->link);
182 cons->channel = channel;
183 cons->tx_vpu_addr = 0;
184 cons->request_id = 0;
185 cons->aborted = false;
186 cons->rx_callback = rx_callback;
187 spin_lock_init(&cons->rx_lock);
188 INIT_LIST_HEAD(&cons->rx_msg_list);
189 init_waitqueue_head(&cons->rx_msg_wq);
192 list_add_tail(&cons->link, &ipc->cons_list);
196 void ivpu_ipc_consumer_del(struct ivpu_device *vdev, struct ivpu_ipc_consumer *cons)
202 list_del(&cons->link);
205 spin_lock_irq(&cons->rx_lock);
206 list_for_each_entry_safe(rx_msg, r, &cons->rx_msg_list, link)
208 spin_unlock_irq(&cons->rx_lock);
210 ivpu_ipc_tx_release(vdev, cons->tx_vpu_addr);
214 ivpu_ipc_send(struct ivpu_device *vdev, struct ivpu_ipc_consumer *cons, struct vpu_jsm_msg *req)
226 ret = ivpu_ipc_tx_prepare(vdev, cons, req);
230 ivpu_ipc_tx(vdev, cons->tx_vpu_addr);
237 static bool ivpu_ipc_rx_need_wakeup(struct ivpu_ipc_consumer *cons)
241 spin_lock_irq(&cons->rx_lock);
242 ret = !list_empty(&cons->rx_msg_list) || cons->aborted;
243 spin_unlock_irq(&cons->rx_lock);
248 int ivpu_ipc_receive(struct ivpu_device *vdev, struct ivpu_ipc_consumer *cons,
255 if (drm_WARN_ONCE(&vdev->drm, cons->rx_callback, "Consumer works only in async mode\n"))
258 wait_ret = wait_event_timeout(cons->rx_msg_wq,
259 ivpu_ipc_rx_need_wakeup(cons),
265 spin_lock_irq(&cons->rx_lock);
266 if (cons->aborted) {
267 spin_unlock_irq(&cons->rx_lock);
270 rx_msg = list_first_entry_or_null(&cons->rx_msg_list, struct ivpu_ipc_rx_msg, link);
272 spin_unlock_irq(&cons->rx_lock);
291 spin_unlock_irq(&cons->rx_lock);
301 struct ivpu_ipc_consumer cons;
304 ivpu_ipc_consumer_add(vdev, &cons, channel, NULL);
306 ret = ivpu_ipc_send(vdev, &cons, req);
312 ret = ivpu_ipc_receive(vdev, &cons, NULL, resp, timeout_ms);
325 ivpu_ipc_consumer_del(vdev, &cons);
369 ivpu_ipc_match_consumer(struct ivpu_device *vdev, struct ivpu_ipc_consumer *cons,
372 if (cons->channel != ipc_hdr->channel)
375 if (!jsm_msg || jsm_msg->request_id == cons->request_id)
384 struct ivpu_ipc_consumer *cons;
430 list_for_each_entry(cons, &ipc->cons_list, link) {
431 if (ivpu_ipc_match_consumer(vdev, cons, ipc_hdr, jsm_msg)) {
432 ivpu_ipc_rx_msg_add(vdev, cons, ipc_hdr, jsm_msg);
543 struct ivpu_ipc_consumer *cons, *c;
553 list_for_each_entry_safe(cons, c, &ipc->cons_list, link) {
554 spin_lock(&cons->rx_lock);
555 if (!cons->rx_callback)
556 cons->aborted = true;
557 list_for_each_entry_safe(rx_msg, r, &cons->rx_msg_list, link)
559 spin_unlock(&cons->rx_lock);
560 wake_up(&cons->rx_msg_wq);