Lines Matching refs:ring

37 static int adf_reserve_ring(struct adf_etr_bank_data *bank, u32 ring)  in adf_reserve_ring()  argument
40 if (bank->ring_mask & (1 << ring)) { in adf_reserve_ring()
44 bank->ring_mask |= (1 << ring); in adf_reserve_ring()
49 static void adf_unreserve_ring(struct adf_etr_bank_data *bank, u32 ring) in adf_unreserve_ring() argument
52 bank->ring_mask &= ~(1 << ring); in adf_unreserve_ring()
56 static void adf_enable_ring_irq(struct adf_etr_bank_data *bank, u32 ring) in adf_enable_ring_irq() argument
61 bank->irq_mask |= (1 << ring); in adf_enable_ring_irq()
69 static void adf_disable_ring_irq(struct adf_etr_bank_data *bank, u32 ring) in adf_disable_ring_irq() argument
74 bank->irq_mask &= ~(1 << ring); in adf_disable_ring_irq()
80 int adf_send_message(struct adf_etr_ring_data *ring, u32 *msg) in adf_send_message() argument
82 struct adf_hw_csr_ops *csr_ops = GET_CSR_OPS(ring->bank->accel_dev); in adf_send_message()
84 if (atomic_add_return(1, ring->inflights) > in adf_send_message()
85 ADF_MAX_INFLIGHTS(ring->ring_size, ring->msg_size)) { in adf_send_message()
86 atomic_dec(ring->inflights); in adf_send_message()
89 spin_lock_bh(&ring->lock); in adf_send_message()
90 memcpy((void *)((uintptr_t)ring->base_addr + ring->tail), msg, in adf_send_message()
91 ADF_MSG_SIZE_TO_BYTES(ring->msg_size)); in adf_send_message()
93 ring->tail = adf_modulo(ring->tail + in adf_send_message()
94 ADF_MSG_SIZE_TO_BYTES(ring->msg_size), in adf_send_message()
95 ADF_RING_SIZE_MODULO(ring->ring_size)); in adf_send_message()
96 csr_ops->write_csr_ring_tail(ring->bank->csr_addr, in adf_send_message()
97 ring->bank->bank_number, ring->ring_number, in adf_send_message()
98 ring->tail); in adf_send_message()
99 spin_unlock_bh(&ring->lock); in adf_send_message()
104 static int adf_handle_response(struct adf_etr_ring_data *ring) in adf_handle_response() argument
106 struct adf_hw_csr_ops *csr_ops = GET_CSR_OPS(ring->bank->accel_dev); in adf_handle_response()
108 u32 *msg = (u32 *)((uintptr_t)ring->base_addr + ring->head); in adf_handle_response()
111 ring->callback((u32 *)msg); in adf_handle_response()
112 atomic_dec(ring->inflights); in adf_handle_response()
114 ring->head = adf_modulo(ring->head + in adf_handle_response()
115 ADF_MSG_SIZE_TO_BYTES(ring->msg_size), in adf_handle_response()
116 ADF_RING_SIZE_MODULO(ring->ring_size)); in adf_handle_response()
118 msg = (u32 *)((uintptr_t)ring->base_addr + ring->head); in adf_handle_response()
121 csr_ops->write_csr_ring_head(ring->bank->csr_addr, in adf_handle_response()
122 ring->bank->bank_number, in adf_handle_response()
123 ring->ring_number, ring->head); in adf_handle_response()
128 static void adf_configure_tx_ring(struct adf_etr_ring_data *ring) in adf_configure_tx_ring() argument
130 struct adf_hw_csr_ops *csr_ops = GET_CSR_OPS(ring->bank->accel_dev); in adf_configure_tx_ring()
131 u32 ring_config = BUILD_RING_CONFIG(ring->ring_size); in adf_configure_tx_ring()
133 csr_ops->write_csr_ring_config(ring->bank->csr_addr, in adf_configure_tx_ring()
134 ring->bank->bank_number, in adf_configure_tx_ring()
135 ring->ring_number, ring_config); in adf_configure_tx_ring()
139 static void adf_configure_rx_ring(struct adf_etr_ring_data *ring) in adf_configure_rx_ring() argument
141 struct adf_hw_csr_ops *csr_ops = GET_CSR_OPS(ring->bank->accel_dev); in adf_configure_rx_ring()
143 BUILD_RESP_RING_CONFIG(ring->ring_size, in adf_configure_rx_ring()
147 csr_ops->write_csr_ring_config(ring->bank->csr_addr, in adf_configure_rx_ring()
148 ring->bank->bank_number, in adf_configure_rx_ring()
149 ring->ring_number, ring_config); in adf_configure_rx_ring()
152 static int adf_init_ring(struct adf_etr_ring_data *ring) in adf_init_ring() argument
154 struct adf_etr_bank_data *bank = ring->bank; in adf_init_ring()
160 ADF_SIZE_TO_RING_SIZE_IN_BYTES(ring->ring_size); in adf_init_ring()
163 ring->base_addr = dma_alloc_coherent(&GET_DEV(accel_dev), in adf_init_ring()
164 ring_size_bytes, &ring->dma_addr, in adf_init_ring()
166 if (!ring->base_addr) in adf_init_ring()
169 memset(ring->base_addr, 0x7F, ring_size_bytes); in adf_init_ring()
171 if (adf_check_ring_alignment(ring->dma_addr, ring_size_bytes)) { in adf_init_ring()
174 ring->base_addr, ring->dma_addr); in adf_init_ring()
175 ring->base_addr = NULL; in adf_init_ring()
179 if (hw_data->tx_rings_mask & (1 << ring->ring_number)) in adf_init_ring()
180 adf_configure_tx_ring(ring); in adf_init_ring()
183 adf_configure_rx_ring(ring); in adf_init_ring()
185 ring_base = csr_ops->build_csr_ring_base_addr(ring->dma_addr, in adf_init_ring()
186 ring->ring_size); in adf_init_ring()
188 csr_ops->write_csr_ring_base(ring->bank->csr_addr, in adf_init_ring()
189 ring->bank->bank_number, ring->ring_number, in adf_init_ring()
191 spin_lock_init(&ring->lock); in adf_init_ring()
195 static void adf_cleanup_ring(struct adf_etr_ring_data *ring) in adf_cleanup_ring() argument
198 ADF_SIZE_TO_RING_SIZE_IN_BYTES(ring->ring_size); in adf_cleanup_ring()
201 if (ring->base_addr) { in adf_cleanup_ring()
202 memset(ring->base_addr, 0x7F, ring_size_bytes); in adf_cleanup_ring()
203 dma_free_coherent(&GET_DEV(ring->bank->accel_dev), in adf_cleanup_ring()
204 ring_size_bytes, ring->base_addr, in adf_cleanup_ring()
205 ring->dma_addr); in adf_cleanup_ring()
218 struct adf_etr_ring_data *ring; in adf_create_ring() local
258 ring = &bank->rings[ring_num]; in adf_create_ring()
259 ring->ring_number = ring_num; in adf_create_ring()
260 ring->bank = bank; in adf_create_ring()
261 ring->callback = callback; in adf_create_ring()
262 ring->msg_size = ADF_BYTES_TO_MSG_SIZE(msg_size); in adf_create_ring()
263 ring->ring_size = adf_verify_ring_size(msg_size, num_msgs); in adf_create_ring()
264 ring->head = 0; in adf_create_ring()
265 ring->tail = 0; in adf_create_ring()
266 atomic_set(ring->inflights, 0); in adf_create_ring()
267 ret = adf_init_ring(ring); in adf_create_ring()
272 adf_update_ring_arb(ring); in adf_create_ring()
274 if (adf_ring_debugfs_add(ring, ring_name)) { in adf_create_ring()
283 adf_enable_ring_irq(bank, ring->ring_number); in adf_create_ring()
284 *ring_ptr = ring; in adf_create_ring()
287 adf_cleanup_ring(ring); in adf_create_ring()
289 adf_update_ring_arb(ring); in adf_create_ring()
293 void adf_remove_ring(struct adf_etr_ring_data *ring) in adf_remove_ring() argument
295 struct adf_etr_bank_data *bank = ring->bank; in adf_remove_ring()
299 adf_disable_ring_irq(bank, ring->ring_number); in adf_remove_ring()
304 ring->ring_number, 0); in adf_remove_ring()
306 ring->ring_number, 0); in adf_remove_ring()
307 adf_ring_debugfs_rm(ring); in adf_remove_ring()
308 adf_unreserve_ring(bank, ring->ring_number); in adf_remove_ring()
310 adf_update_ring_arb(ring); in adf_remove_ring()
311 adf_cleanup_ring(ring); in adf_remove_ring()
381 struct adf_etr_ring_data *ring; in adf_init_bank() local
414 ring = &bank->rings[i]; in adf_init_bank()
416 ring->inflights = in adf_init_bank()
420 if (!ring->inflights) in adf_init_bank()
429 ring->inflights = tx_ring->inflights; in adf_init_bank()
445 ring = &bank->rings[i]; in adf_init_bank()
446 kfree(ring->inflights); in adf_init_bank()
447 ring->inflights = NULL; in adf_init_bank()
521 struct adf_etr_ring_data *ring = &bank->rings[i]; in cleanup_bank() local
524 adf_cleanup_ring(ring); in cleanup_bank()
527 kfree(ring->inflights); in cleanup_bank()