Lines Matching full:cb

316  * @cb: mei callback struct
318 void mei_io_cb_free(struct mei_cl_cb *cb) in mei_io_cb_free() argument
320 if (cb == NULL) in mei_io_cb_free()
323 list_del(&cb->list); in mei_io_cb_free()
324 kfree(cb->buf.data); in mei_io_cb_free()
325 kfree(cb); in mei_io_cb_free()
333 * @cb: mei callback struct
336 static inline void mei_tx_cb_enqueue(struct mei_cl_cb *cb, in mei_tx_cb_enqueue() argument
339 list_add_tail(&cb->list, head); in mei_tx_cb_enqueue()
340 cb->cl->tx_cb_queued++; in mei_tx_cb_enqueue()
348 * @cb: mei callback struct to dequeue and free
350 static inline void mei_tx_cb_dequeue(struct mei_cl_cb *cb) in mei_tx_cb_dequeue() argument
352 if (!WARN_ON(cb->cl->tx_cb_queued == 0)) in mei_tx_cb_dequeue()
353 cb->cl->tx_cb_queued--; in mei_tx_cb_dequeue()
355 mei_io_cb_free(cb); in mei_tx_cb_dequeue()
392 struct mei_cl_cb *cb; in mei_io_cb_init() local
394 cb = kzalloc(sizeof(*cb), GFP_KERNEL); in mei_io_cb_init()
395 if (!cb) in mei_io_cb_init()
398 INIT_LIST_HEAD(&cb->list); in mei_io_cb_init()
399 cb->fp = fp; in mei_io_cb_init()
400 cb->cl = cl; in mei_io_cb_init()
401 cb->buf_idx = 0; in mei_io_cb_init()
402 cb->fop_type = type; in mei_io_cb_init()
403 cb->vtag = 0; in mei_io_cb_init()
405 return cb; in mei_io_cb_init()
417 struct mei_cl_cb *cb, *next; in mei_io_list_flush_cl() local
419 list_for_each_entry_safe(cb, next, head, list) { in mei_io_list_flush_cl()
420 if (cl == cb->cl) { in mei_io_list_flush_cl()
421 list_del_init(&cb->list); in mei_io_list_flush_cl()
422 if (cb->fop_type == MEI_FOP_READ) in mei_io_list_flush_cl()
423 mei_io_cb_free(cb); in mei_io_list_flush_cl()
429 * mei_io_tx_list_free_cl - removes cb belonging to the cl and free them
433 * @fp: file pointer (matching cb file object), may be NULL
439 struct mei_cl_cb *cb, *next; in mei_io_tx_list_free_cl() local
441 list_for_each_entry_safe(cb, next, head, list) { in mei_io_tx_list_free_cl()
442 if (cl == cb->cl && (!fp || fp == cb->fp)) in mei_io_tx_list_free_cl()
443 mei_tx_cb_dequeue(cb); in mei_io_tx_list_free_cl()
448 * mei_io_list_free_fp - free cb from a list that matches file pointer
451 * @fp: file pointer (matching cb file object), may be NULL
455 struct mei_cl_cb *cb, *next; in mei_io_list_free_fp() local
457 list_for_each_entry_safe(cb, next, head, list) in mei_io_list_free_fp()
458 if (!fp || fp == cb->fp) in mei_io_list_free_fp()
459 mei_io_cb_free(cb); in mei_io_list_free_fp()
463 * mei_cl_free_pending - free pending cb
469 struct mei_cl_cb *cb; in mei_cl_free_pending() local
471 cb = list_first_entry_or_null(&cl->rd_pending, struct mei_cl_cb, list); in mei_cl_free_pending()
472 mei_io_cb_free(cb); in mei_cl_free_pending()
476 * mei_cl_alloc_cb - a convenient wrapper for allocating read cb
483 * Return: cb on success and NULL on failure
489 struct mei_cl_cb *cb; in mei_cl_alloc_cb() local
491 cb = mei_io_cb_init(cl, fop_type, fp); in mei_cl_alloc_cb()
492 if (!cb) in mei_cl_alloc_cb()
496 return cb; in mei_cl_alloc_cb()
498 cb->buf.data = kmalloc(roundup(length, MEI_SLOT_SIZE), GFP_KERNEL); in mei_cl_alloc_cb()
499 if (!cb->buf.data) { in mei_cl_alloc_cb()
500 mei_io_cb_free(cb); in mei_cl_alloc_cb()
503 cb->buf.size = length; in mei_cl_alloc_cb()
505 return cb; in mei_cl_alloc_cb()
510 * and enqueuing of the control commands cb
517 * Return: cb on success and NULL on failure
524 struct mei_cl_cb *cb; in mei_cl_enqueue_ctrl_wr_cb() local
530 cb = mei_cl_alloc_cb(cl, length, fop_type, fp); in mei_cl_enqueue_ctrl_wr_cb()
531 if (!cb) in mei_cl_enqueue_ctrl_wr_cb()
534 list_add_tail(&cb->list, &cl->dev->ctrl_wr_list); in mei_cl_enqueue_ctrl_wr_cb()
535 return cb; in mei_cl_enqueue_ctrl_wr_cb()
543 * @fp: file pointer (matching cb file object), may be NULL
545 * Return: cb on success, NULL if cb is not found
549 struct mei_cl_cb *cb; in mei_cl_read_cb() local
553 list_for_each_entry(cb, &cl->rd_completed, list) in mei_cl_read_cb()
554 if (!fp || fp == cb->fp) { in mei_cl_read_cb()
555 ret_cb = cb; in mei_cl_read_cb()
566 * @fp: file pointer (matching cb file object), may be NULL
582 /* free pending and control cb only in final flush */ in mei_cl_flush_queues()
854 * @cb: callback block
858 static int mei_cl_send_disconnect(struct mei_cl *cl, struct mei_cl_cb *cb) in mei_cl_send_disconnect() argument
872 list_move_tail(&cb->list, &dev->ctrl_rd_list); in mei_cl_send_disconnect()
884 * @cb: callback block.
889 int mei_cl_irq_disconnect(struct mei_cl *cl, struct mei_cl_cb *cb, in mei_cl_irq_disconnect() argument
905 ret = mei_cl_send_disconnect(cl, cb); in mei_cl_irq_disconnect()
907 list_move_tail(&cb->list, cmpl_list); in mei_cl_irq_disconnect()
923 struct mei_cl_cb *cb; in __mei_cl_disconnect() local
930 cb = mei_cl_enqueue_ctrl_wr_cb(cl, 0, MEI_FOP_DISCONNECT, NULL); in __mei_cl_disconnect()
931 if (!cb) { in __mei_cl_disconnect()
937 rets = mei_cl_send_disconnect(cl, cb); in __mei_cl_disconnect()
964 mei_io_cb_free(cb); in __mei_cl_disconnect()
1032 struct mei_cl_cb *cb; in mei_cl_is_other_connecting() local
1036 list_for_each_entry(cb, &dev->ctrl_rd_list, list) { in mei_cl_is_other_connecting()
1037 if (cb->fop_type == MEI_FOP_CONNECT && in mei_cl_is_other_connecting()
1038 mei_cl_me_id(cl) == mei_cl_me_id(cb->cl)) in mei_cl_is_other_connecting()
1049 * @cb: callback block
1053 static int mei_cl_send_connect(struct mei_cl *cl, struct mei_cl_cb *cb) in mei_cl_send_connect() argument
1067 list_move_tail(&cb->list, &dev->ctrl_rd_list); in mei_cl_send_connect()
1077 * @cb: callback block
1082 int mei_cl_irq_connect(struct mei_cl *cl, struct mei_cl_cb *cb, in mei_cl_irq_connect() argument
1101 rets = mei_cl_send_connect(cl, cb); in mei_cl_irq_connect()
1103 list_move_tail(&cb->list, cmpl_list); in mei_cl_irq_connect()
1123 struct mei_cl_cb *cb; in mei_cl_connect() local
1148 cb = mei_cl_enqueue_ctrl_wr_cb(cl, 0, MEI_FOP_CONNECT, fp); in mei_cl_connect()
1149 if (!cb) { in mei_cl_connect()
1156 rets = mei_cl_send_connect(cl, cb); in mei_cl_connect()
1193 mei_io_cb_free(cb); in mei_cl_connect()
1400 * @cb: callback block
1403 void mei_cl_add_rd_completed(struct mei_cl *cl, struct mei_cl_cb *cb) in mei_cl_add_rd_completed() argument
1408 fp = mei_cl_fp_by_vtag(cl, cb->vtag); in mei_cl_add_rd_completed()
1411 mei_io_cb_free(cb); in mei_cl_add_rd_completed()
1414 cb->fp = fp; in mei_cl_add_rd_completed()
1415 mei_cl_reset_read_by_vtag(cl, cb->vtag); in mei_cl_add_rd_completed()
1420 list_add_tail(&cb->list, &cl->rd_completed); in mei_cl_add_rd_completed()
1428 * @cb: callback block
1431 void mei_cl_del_rd_completed(struct mei_cl *cl, struct mei_cl_cb *cb) in mei_cl_del_rd_completed() argument
1434 mei_io_cb_free(cb); in mei_cl_del_rd_completed()
1472 * @cb: callback block.
1477 int mei_cl_irq_notify(struct mei_cl *cl, struct mei_cl_cb *cb, in mei_cl_irq_notify() argument
1494 request = mei_cl_notify_fop2req(cb->fop_type); in mei_cl_irq_notify()
1498 list_move_tail(&cb->list, cmpl_list); in mei_cl_irq_notify()
1502 list_move_tail(&cb->list, &dev->ctrl_rd_list); in mei_cl_irq_notify()
1521 struct mei_cl_cb *cb; in mei_cl_notify_request() local
1546 cb = mei_cl_enqueue_ctrl_wr_cb(cl, 0, fop_type, fp); in mei_cl_notify_request()
1547 if (!cb) { in mei_cl_notify_request()
1557 list_move_tail(&cb->list, &dev->ctrl_rd_list); in mei_cl_notify_request()
1578 mei_io_cb_free(cb); in mei_cl_notify_request()
1673 struct mei_cl_cb *cb; in mei_cl_read_start() local
1698 cb = mei_cl_enqueue_ctrl_wr_cb(cl, length, MEI_FOP_READ, fp); in mei_cl_read_start()
1699 if (!cb) in mei_cl_read_start()
1717 list_move_tail(&cb->list, &cl->rd_pending); in mei_cl_read_start()
1727 mei_io_cb_free(cb); in mei_cl_read_start()
1746 * @cb: message callback structure
1750 static struct mei_msg_hdr *mei_msg_hdr_init(const struct mei_cl_cb *cb) in mei_msg_hdr_init() argument
1757 if (!cb) in mei_msg_hdr_init()
1761 is_vtag = (cb->vtag && cb->buf_idx == 0); in mei_msg_hdr_init()
1779 mei_hdr->host_addr = mei_cl_host_addr(cb->cl); in mei_msg_hdr_init()
1780 mei_hdr->me_addr = mei_cl_me_id(cb->cl); in mei_msg_hdr_init()
1781 mei_hdr->internal = cb->internal; in mei_msg_hdr_init()
1790 meta->size += mei_ext_hdr_set_vtag(meta->hdrs, cb->vtag); in mei_msg_hdr_init()
1802 * @cb: callback block.
1807 int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb, in mei_cl_irq_write() argument
1829 buf = &cb->buf; in mei_cl_irq_write()
1831 first_chunk = cb->buf_idx == 0; in mei_cl_irq_write()
1842 buf_len = buf->size - cb->buf_idx; in mei_cl_irq_write()
1843 data = buf->data + cb->buf_idx; in mei_cl_irq_write()
1854 mei_hdr = mei_msg_hdr_init(cb); in mei_cl_irq_write()
1862 mei_hdr->extended, cb->vtag); in mei_cl_irq_write()
1893 mei_dma_ring_write(dev, buf->data + cb->buf_idx, buf_len); in mei_cl_irq_write()
1901 cb->buf_idx += buf_len; in mei_cl_irq_write()
1911 list_move_tail(&cb->list, &dev->write_waiting_list); in mei_cl_irq_write()
1919 list_move_tail(&cb->list, cmpl_list); in mei_cl_irq_write()
1924 * mei_cl_write - submit a write cb to mei device
1928 * @cb: write callback with filled data
1932 ssize_t mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb) in mei_cl_write() argument
1951 if (WARN_ON(!cb)) in mei_cl_write()
1956 buf = &cb->buf; in mei_cl_write()
1961 blocking = cb->blocking; in mei_cl_write()
1971 cb->buf_idx = 0; in mei_cl_write()
1979 mei_hdr = mei_msg_hdr_init(cb); in mei_cl_write()
1987 mei_hdr->extended, cb->vtag); in mei_cl_write()
2045 cb->buf_idx = buf_len; in mei_cl_write()
2051 mei_tx_cb_enqueue(cb, &dev->write_waiting_list); in mei_cl_write()
2053 mei_tx_cb_enqueue(cb, &dev->write_list); in mei_cl_write()
2055 cb = NULL; in mei_cl_write()
2081 mei_io_cb_free(cb); in mei_cl_write()
2092 * @cb: callback block.
2094 void mei_cl_complete(struct mei_cl *cl, struct mei_cl_cb *cb) in mei_cl_complete() argument
2098 switch (cb->fop_type) { in mei_cl_complete()
2100 mei_tx_cb_dequeue(cb); in mei_cl_complete()
2111 mei_cl_add_rd_completed(cl, cb); in mei_cl_complete()
2130 mei_io_cb_free(cb); in mei_cl_complete()
2167 * @cb: callback block.
2172 int mei_cl_irq_dma_map(struct mei_cl *cl, struct mei_cl_cb *cb, in mei_cl_irq_dma_map() argument
2191 list_move_tail(&cb->list, cmpl_list); in mei_cl_irq_dma_map()
2195 list_move_tail(&cb->list, &dev->ctrl_rd_list); in mei_cl_irq_dma_map()
2203 * @cb: callback block.
2208 int mei_cl_irq_dma_unmap(struct mei_cl *cl, struct mei_cl_cb *cb, in mei_cl_irq_dma_unmap() argument
2227 list_move_tail(&cb->list, cmpl_list); in mei_cl_irq_dma_unmap()
2231 list_move_tail(&cb->list, &dev->ctrl_rd_list); in mei_cl_irq_dma_unmap()
2279 struct mei_cl_cb *cb; in mei_cl_dma_alloc_and_map() local
2320 cb = mei_cl_enqueue_ctrl_wr_cb(cl, 0, MEI_FOP_DMA_MAP, fp); in mei_cl_dma_alloc_and_map()
2321 if (!cb) { in mei_cl_dma_alloc_and_map()
2331 list_move_tail(&cb->list, &dev->ctrl_rd_list); in mei_cl_dma_alloc_and_map()
2355 mei_io_cb_free(cb); in mei_cl_dma_alloc_and_map()
2372 struct mei_cl_cb *cb; in mei_cl_dma_unmap() local
2399 cb = mei_cl_enqueue_ctrl_wr_cb(cl, 0, MEI_FOP_DMA_UNMAP, fp); in mei_cl_dma_unmap()
2400 if (!cb) { in mei_cl_dma_unmap()
2410 list_move_tail(&cb->list, &dev->ctrl_rd_list); in mei_cl_dma_unmap()
2433 mei_io_cb_free(cb); in mei_cl_dma_unmap()