Lines Matching refs:ipc
12 static bool qtnf_shm_ipc_has_new_data(struct qtnf_shm_ipc *ipc) in qtnf_shm_ipc_has_new_data() argument
14 const u32 flags = readl(&ipc->shm_region->headroom.hdr.flags); in qtnf_shm_ipc_has_new_data()
19 static void qtnf_shm_handle_new_data(struct qtnf_shm_ipc *ipc) in qtnf_shm_handle_new_data() argument
25 shm_reg_hdr = &ipc->shm_region->headroom.hdr; in qtnf_shm_handle_new_data()
35 ipc->rx_packet_count++; in qtnf_shm_handle_new_data()
36 ipc->rx_callback.fn(ipc->rx_callback.arg, in qtnf_shm_handle_new_data()
37 ipc->shm_region->data, size); in qtnf_shm_handle_new_data()
43 ipc->interrupt.fn(ipc->interrupt.arg); in qtnf_shm_handle_new_data()
48 struct qtnf_shm_ipc *ipc = container_of(work, struct qtnf_shm_ipc, in qtnf_shm_ipc_irq_work() local
51 while (qtnf_shm_ipc_has_new_data(ipc)) in qtnf_shm_ipc_irq_work()
52 qtnf_shm_handle_new_data(ipc); in qtnf_shm_ipc_irq_work()
55 static void qtnf_shm_ipc_irq_inbound_handler(struct qtnf_shm_ipc *ipc) in qtnf_shm_ipc_irq_inbound_handler() argument
59 flags = readl(&ipc->shm_region->headroom.hdr.flags); in qtnf_shm_ipc_irq_inbound_handler()
62 queue_work(ipc->workqueue, &ipc->irq_work); in qtnf_shm_ipc_irq_inbound_handler()
65 static void qtnf_shm_ipc_irq_outbound_handler(struct qtnf_shm_ipc *ipc) in qtnf_shm_ipc_irq_outbound_handler() argument
69 if (!READ_ONCE(ipc->waiting_for_ack)) in qtnf_shm_ipc_irq_outbound_handler()
72 flags = readl(&ipc->shm_region->headroom.hdr.flags); in qtnf_shm_ipc_irq_outbound_handler()
75 WRITE_ONCE(ipc->waiting_for_ack, 0); in qtnf_shm_ipc_irq_outbound_handler()
76 complete(&ipc->tx_completion); in qtnf_shm_ipc_irq_outbound_handler()
80 int qtnf_shm_ipc_init(struct qtnf_shm_ipc *ipc, in qtnf_shm_ipc_init() argument
91 ipc->shm_region = shm_region; in qtnf_shm_ipc_init()
92 ipc->direction = direction; in qtnf_shm_ipc_init()
93 ipc->interrupt = *interrupt; in qtnf_shm_ipc_init()
94 ipc->rx_callback = *rx_callback; in qtnf_shm_ipc_init()
95 ipc->tx_packet_count = 0; in qtnf_shm_ipc_init()
96 ipc->rx_packet_count = 0; in qtnf_shm_ipc_init()
97 ipc->workqueue = workqueue; in qtnf_shm_ipc_init()
98 ipc->waiting_for_ack = 0; in qtnf_shm_ipc_init()
99 ipc->tx_timeout_count = 0; in qtnf_shm_ipc_init()
103 ipc->irq_handler = qtnf_shm_ipc_irq_outbound_handler; in qtnf_shm_ipc_init()
106 ipc->irq_handler = qtnf_shm_ipc_irq_inbound_handler; in qtnf_shm_ipc_init()
112 INIT_WORK(&ipc->irq_work, qtnf_shm_ipc_irq_work); in qtnf_shm_ipc_init()
113 init_completion(&ipc->tx_completion); in qtnf_shm_ipc_init()
118 void qtnf_shm_ipc_free(struct qtnf_shm_ipc *ipc) in qtnf_shm_ipc_free() argument
120 complete_all(&ipc->tx_completion); in qtnf_shm_ipc_free()
123 int qtnf_shm_ipc_send(struct qtnf_shm_ipc *ipc, const u8 *buf, size_t size) in qtnf_shm_ipc_send() argument
128 shm_reg_hdr = &ipc->shm_region->headroom.hdr; in qtnf_shm_ipc_send()
133 ipc->tx_packet_count++; in qtnf_shm_ipc_send()
136 memcpy_toio(ipc->shm_region->data, buf, size); in qtnf_shm_ipc_send()
141 WRITE_ONCE(ipc->waiting_for_ack, 1); in qtnf_shm_ipc_send()
149 ipc->interrupt.fn(ipc->interrupt.arg); in qtnf_shm_ipc_send()
151 if (!wait_for_completion_timeout(&ipc->tx_completion, in qtnf_shm_ipc_send()
154 ipc->tx_timeout_count++; in qtnf_shm_ipc_send()
159 WRITE_ONCE(ipc->waiting_for_ack, 0); in qtnf_shm_ipc_send()