Lines Matching refs:cmd_q

25 static u32 ccp_lsb_alloc(struct ccp_cmd_queue *cmd_q, unsigned int count)  in ccp_lsb_alloc()  argument
31 if (cmd_q->lsb >= 0) { in ccp_lsb_alloc()
32 start = (u32)bitmap_find_next_zero_area(cmd_q->lsbmap, in ccp_lsb_alloc()
36 bitmap_set(cmd_q->lsbmap, start, count); in ccp_lsb_alloc()
37 return start + cmd_q->lsb * LSB_SIZE; in ccp_lsb_alloc()
42 ccp = cmd_q->ccp; in ccp_lsb_alloc()
70 static void ccp_lsb_free(struct ccp_cmd_queue *cmd_q, unsigned int start, in ccp_lsb_free() argument
76 if (cmd_q->lsb == start) { in ccp_lsb_free()
78 bitmap_clear(cmd_q->lsbmap, start, count); in ccp_lsb_free()
81 struct ccp_device *ccp = cmd_q->ccp; in ccp_lsb_free()
207 static unsigned int ccp5_get_free_slots(struct ccp_cmd_queue *cmd_q) in ccp5_get_free_slots() argument
212 queue_start = low_address(cmd_q->qdma_tail); in ccp5_get_free_slots()
213 head_lo = ioread32(cmd_q->reg_head_lo); in ccp5_get_free_slots()
216 n = head_idx + COMMANDS_PER_QUEUE - cmd_q->qidx - 1; in ccp5_get_free_slots()
222 struct ccp_cmd_queue *cmd_q) in ccp5_do_cmd() argument
230 cmd_q->total_ops++; in ccp5_do_cmd()
236 mutex_lock(&cmd_q->q_mutex); in ccp5_do_cmd()
238 mP = (__le32 *)&cmd_q->qbase[cmd_q->qidx]; in ccp5_do_cmd()
243 cmd_q->qidx = (cmd_q->qidx + 1) % COMMANDS_PER_QUEUE; in ccp5_do_cmd()
249 tail = low_address(cmd_q->qdma_tail + cmd_q->qidx * Q_DESC_SIZE); in ccp5_do_cmd()
250 iowrite32(tail, cmd_q->reg_tail_lo); in ccp5_do_cmd()
253 iowrite32(cmd_q->qcontrol | CMD5_Q_RUN, cmd_q->reg_control); in ccp5_do_cmd()
254 mutex_unlock(&cmd_q->q_mutex); in ccp5_do_cmd()
258 ret = wait_event_interruptible(cmd_q->int_queue, in ccp5_do_cmd()
259 cmd_q->int_rcvd); in ccp5_do_cmd()
260 if (ret || cmd_q->cmd_error) { in ccp5_do_cmd()
264 if (cmd_q->cmd_error) in ccp5_do_cmd()
265 ccp_log_error(cmd_q->ccp, in ccp5_do_cmd()
266 cmd_q->cmd_error); in ccp5_do_cmd()
267 iowrite32(tail, cmd_q->reg_head_lo); in ccp5_do_cmd()
271 cmd_q->int_rcvd = 0; in ccp5_do_cmd()
283 op->cmd_q->total_aes_ops++; in ccp5_perform_aes()
319 return ccp5_do_cmd(&desc, op->cmd_q); in ccp5_perform_aes()
328 op->cmd_q->total_xts_aes_ops++; in ccp5_perform_xts_aes()
362 return ccp5_do_cmd(&desc, op->cmd_q); in ccp5_perform_xts_aes()
370 op->cmd_q->total_sha_ops++; in ccp5_perform_sha()
403 return ccp5_do_cmd(&desc, op->cmd_q); in ccp5_perform_sha()
412 op->cmd_q->total_3des_ops++; in ccp5_perform_des3()
446 return ccp5_do_cmd(&desc, op->cmd_q); in ccp5_perform_des3()
454 op->cmd_q->total_rsa_ops++; in ccp5_perform_rsa()
488 return ccp5_do_cmd(&desc, op->cmd_q); in ccp5_perform_rsa()
499 op->cmd_q->total_pt_ops++; in ccp5_perform_passthru()
549 return ccp5_do_cmd(&desc, op->cmd_q); in ccp5_perform_passthru()
557 op->cmd_q->total_ecc_ops++; in ccp5_perform_ecc()
584 return ccp5_do_cmd(&desc, op->cmd_q); in ccp5_perform_ecc()
587 static int ccp_find_lsb_regions(struct ccp_cmd_queue *cmd_q, u64 status) in ccp_find_lsb_regions() argument
589 int q_mask = 1 << cmd_q->id; in ccp_find_lsb_regions()
598 bitmap_set(cmd_q->lsbmask, j, 1); in ccp_find_lsb_regions()
601 queues = bitmap_weight(cmd_q->lsbmask, MAX_LSB_CNT); in ccp_find_lsb_regions()
602 dev_dbg(cmd_q->ccp->dev, "Queue %d can access %d LSB regions\n", in ccp_find_lsb_regions()
603 cmd_q->id, queues); in ccp_find_lsb_regions()
628 struct ccp_cmd_queue *cmd_q = &ccp->cmd_q[i]; in ccp_find_and_assign_lsb_to_q() local
630 qlsb_wgt = bitmap_weight(cmd_q->lsbmask, MAX_LSB_CNT); in ccp_find_and_assign_lsb_to_q()
633 bitmap_copy(qlsb, cmd_q->lsbmask, MAX_LSB_CNT); in ccp_find_and_assign_lsb_to_q()
641 cmd_q->lsb = bitno; in ccp_find_and_assign_lsb_to_q()
679 lsb_pub, ccp->cmd_q[i].lsbmask, in ccp_assign_lsbs()
725 iowrite32(0x0, ccp->cmd_q[i].reg_int_enable); in ccp5_disable_queue_interrupts()
733 iowrite32(SUPPORTED_INTERRUPTS, ccp->cmd_q[i].reg_int_enable); in ccp5_enable_queue_interrupts()
743 struct ccp_cmd_queue *cmd_q = &ccp->cmd_q[i]; in ccp5_irq_bh() local
745 status = ioread32(cmd_q->reg_interrupt_status); in ccp5_irq_bh()
748 cmd_q->int_status = status; in ccp5_irq_bh()
749 cmd_q->q_status = ioread32(cmd_q->reg_status); in ccp5_irq_bh()
750 cmd_q->q_int_status = ioread32(cmd_q->reg_int_status); in ccp5_irq_bh()
753 if ((status & INT_ERROR) && !cmd_q->cmd_error) in ccp5_irq_bh()
754 cmd_q->cmd_error = CMD_Q_ERROR(cmd_q->q_status); in ccp5_irq_bh()
756 cmd_q->int_rcvd = 1; in ccp5_irq_bh()
759 iowrite32(status, cmd_q->reg_interrupt_status); in ccp5_irq_bh()
760 wake_up_interruptible(&cmd_q->int_queue); in ccp5_irq_bh()
782 struct ccp_cmd_queue *cmd_q; in ccp5_init() local
820 cmd_q = &ccp->cmd_q[ccp->cmd_q_count]; in ccp5_init()
823 cmd_q->ccp = ccp; in ccp5_init()
824 cmd_q->id = i; in ccp5_init()
825 cmd_q->dma_pool = dma_pool; in ccp5_init()
826 mutex_init(&cmd_q->q_mutex); in ccp5_init()
830 cmd_q->qsize = Q_SIZE(Q_DESC_SIZE); in ccp5_init()
831 cmd_q->qbase = dmam_alloc_coherent(dev, cmd_q->qsize, in ccp5_init()
832 &cmd_q->qbase_dma, in ccp5_init()
834 if (!cmd_q->qbase) { in ccp5_init()
840 cmd_q->qidx = 0; in ccp5_init()
844 cmd_q->reg_control = ccp->io_regs + in ccp5_init()
846 cmd_q->reg_tail_lo = cmd_q->reg_control + CMD5_Q_TAIL_LO_BASE; in ccp5_init()
847 cmd_q->reg_head_lo = cmd_q->reg_control + CMD5_Q_HEAD_LO_BASE; in ccp5_init()
848 cmd_q->reg_int_enable = cmd_q->reg_control + in ccp5_init()
850 cmd_q->reg_interrupt_status = cmd_q->reg_control + in ccp5_init()
852 cmd_q->reg_status = cmd_q->reg_control + CMD5_Q_STATUS_BASE; in ccp5_init()
853 cmd_q->reg_int_status = cmd_q->reg_control + in ccp5_init()
855 cmd_q->reg_dma_status = cmd_q->reg_control + in ccp5_init()
857 cmd_q->reg_dma_read_status = cmd_q->reg_control + in ccp5_init()
859 cmd_q->reg_dma_write_status = cmd_q->reg_control + in ccp5_init()
862 init_waitqueue_head(&cmd_q->int_queue); in ccp5_init()
876 cmd_q = &ccp->cmd_q[i]; in ccp5_init()
878 cmd_q->qcontrol = 0; /* Start with nothing */ in ccp5_init()
879 iowrite32(cmd_q->qcontrol, cmd_q->reg_control); in ccp5_init()
881 ioread32(cmd_q->reg_int_status); in ccp5_init()
882 ioread32(cmd_q->reg_status); in ccp5_init()
885 iowrite32(SUPPORTED_INTERRUPTS, cmd_q->reg_interrupt_status); in ccp5_init()
914 cmd_q = &ccp->cmd_q[i]; in ccp5_init()
916 cmd_q->qcontrol &= ~(CMD5_Q_SIZE << CMD5_Q_SHIFT); in ccp5_init()
917 cmd_q->qcontrol |= QUEUE_SIZE_VAL << CMD5_Q_SHIFT; in ccp5_init()
919 cmd_q->qdma_tail = cmd_q->qbase_dma; in ccp5_init()
920 dma_addr_lo = low_address(cmd_q->qdma_tail); in ccp5_init()
921 iowrite32((u32)dma_addr_lo, cmd_q->reg_tail_lo); in ccp5_init()
922 iowrite32((u32)dma_addr_lo, cmd_q->reg_head_lo); in ccp5_init()
924 dma_addr_hi = high_address(cmd_q->qdma_tail); in ccp5_init()
925 cmd_q->qcontrol |= (dma_addr_hi << 16); in ccp5_init()
926 iowrite32(cmd_q->qcontrol, cmd_q->reg_control); in ccp5_init()
929 ccp_find_lsb_regions(cmd_q, status); in ccp5_init()
930 cmd_q->lsb = -1; /* Unassigned value */ in ccp5_init()
942 ccp->cmd_q[i].sb_key = ccp_lsb_alloc(&ccp->cmd_q[i], 2); in ccp5_init()
943 ccp->cmd_q[i].sb_ctx = ccp_lsb_alloc(&ccp->cmd_q[i], 2); in ccp5_init()
951 cmd_q = &ccp->cmd_q[i]; in ccp5_init()
953 kthread = kthread_run(ccp_cmd_queue_thread, cmd_q, in ccp5_init()
954 "%s-q%u", ccp->name, cmd_q->id); in ccp5_init()
962 cmd_q->kthread = kthread; in ccp5_init()
993 if (ccp->cmd_q[i].kthread) in ccp5_init()
994 kthread_stop(ccp->cmd_q[i].kthread); in ccp5_init()
1001 dma_pool_destroy(ccp->cmd_q[i].dma_pool); in ccp5_init()
1008 struct ccp_cmd_queue *cmd_q; in ccp5_destroy() local
1032 cmd_q = &ccp->cmd_q[i]; in ccp5_destroy()
1035 iowrite32(cmd_q->qcontrol & ~CMD5_Q_RUN, cmd_q->reg_control); in ccp5_destroy()
1038 iowrite32(SUPPORTED_INTERRUPTS, cmd_q->reg_interrupt_status); in ccp5_destroy()
1039 ioread32(cmd_q->reg_int_status); in ccp5_destroy()
1040 ioread32(cmd_q->reg_status); in ccp5_destroy()
1045 if (ccp->cmd_q[i].kthread) in ccp5_destroy()
1046 kthread_stop(ccp->cmd_q[i].kthread); in ccp5_destroy()