Lines Matching refs:cmd_q
24 static u32 ccp_lsb_alloc(struct ccp_cmd_queue *cmd_q, unsigned int count) in ccp_lsb_alloc() argument
30 if (cmd_q->lsb >= 0) { in ccp_lsb_alloc()
31 start = (u32)bitmap_find_next_zero_area(cmd_q->lsbmap, in ccp_lsb_alloc()
35 bitmap_set(cmd_q->lsbmap, start, count); in ccp_lsb_alloc()
36 return start + cmd_q->lsb * LSB_SIZE; in ccp_lsb_alloc()
41 ccp = cmd_q->ccp; in ccp_lsb_alloc()
66 static void ccp_lsb_free(struct ccp_cmd_queue *cmd_q, unsigned int start, in ccp_lsb_free() argument
74 if (cmd_q->lsb == lsbno) { in ccp_lsb_free()
76 bitmap_clear(cmd_q->lsbmap, start % LSB_SIZE, count); in ccp_lsb_free()
79 struct ccp_device *ccp = cmd_q->ccp; in ccp_lsb_free()
195 static unsigned int ccp5_get_free_slots(struct ccp_cmd_queue *cmd_q) in ccp5_get_free_slots() argument
200 queue_start = low_address(cmd_q->qdma_tail); in ccp5_get_free_slots()
201 head_lo = ioread32(cmd_q->reg_head_lo); in ccp5_get_free_slots()
204 n = head_idx + COMMANDS_PER_QUEUE - cmd_q->qidx - 1; in ccp5_get_free_slots()
210 struct ccp_cmd_queue *cmd_q) in ccp5_do_cmd() argument
222 mutex_lock(&cmd_q->q_mutex); in ccp5_do_cmd()
224 mP = (u32 *) &cmd_q->qbase[cmd_q->qidx]; in ccp5_do_cmd()
229 cmd_q->qidx = (cmd_q->qidx + 1) % COMMANDS_PER_QUEUE; in ccp5_do_cmd()
235 tail = low_address(cmd_q->qdma_tail + cmd_q->qidx * Q_DESC_SIZE); in ccp5_do_cmd()
236 iowrite32(tail, cmd_q->reg_tail_lo); in ccp5_do_cmd()
239 iowrite32(cmd_q->qcontrol | CMD5_Q_RUN, cmd_q->reg_control); in ccp5_do_cmd()
240 mutex_unlock(&cmd_q->q_mutex); in ccp5_do_cmd()
244 ret = wait_event_interruptible(cmd_q->int_queue, in ccp5_do_cmd()
245 cmd_q->int_rcvd); in ccp5_do_cmd()
246 if (ret || cmd_q->cmd_error) { in ccp5_do_cmd()
247 if (cmd_q->cmd_error) in ccp5_do_cmd()
248 ccp_log_error(cmd_q->ccp, in ccp5_do_cmd()
249 cmd_q->cmd_error); in ccp5_do_cmd()
254 cmd_q->int_rcvd = 0; in ccp5_do_cmd()
300 return ccp5_do_cmd(&desc, op->cmd_q); in ccp5_perform_aes()
341 return ccp5_do_cmd(&desc, op->cmd_q); in ccp5_perform_xts_aes()
380 return ccp5_do_cmd(&desc, op->cmd_q); in ccp5_perform_sha()
420 return ccp5_do_cmd(&desc, op->cmd_q); in ccp5_perform_rsa()
478 return ccp5_do_cmd(&desc, op->cmd_q); in ccp5_perform_passthru()
511 return ccp5_do_cmd(&desc, op->cmd_q); in ccp5_perform_ecc()
514 static int ccp_find_lsb_regions(struct ccp_cmd_queue *cmd_q, u64 status) in ccp_find_lsb_regions() argument
516 int q_mask = 1 << cmd_q->id; in ccp_find_lsb_regions()
525 bitmap_set(cmd_q->lsbmask, j, 1); in ccp_find_lsb_regions()
528 queues = bitmap_weight(cmd_q->lsbmask, MAX_LSB_CNT); in ccp_find_lsb_regions()
529 dev_info(cmd_q->ccp->dev, "Queue %d can access %d LSB regions\n", in ccp_find_lsb_regions()
530 cmd_q->id, queues); in ccp_find_lsb_regions()
556 struct ccp_cmd_queue *cmd_q = &ccp->cmd_q[i]; in ccp_find_and_assign_lsb_to_q() local
558 qlsb_wgt = bitmap_weight(cmd_q->lsbmask, MAX_LSB_CNT); in ccp_find_and_assign_lsb_to_q()
561 bitmap_copy(qlsb, cmd_q->lsbmask, MAX_LSB_CNT); in ccp_find_and_assign_lsb_to_q()
569 cmd_q->lsb = bitno; in ccp_find_and_assign_lsb_to_q()
607 lsb_pub, ccp->cmd_q[i].lsbmask, in ccp_assign_lsbs()
653 iowrite32(0x0, ccp->cmd_q[i].reg_int_enable); in ccp5_disable_queue_interrupts()
661 iowrite32(SUPPORTED_INTERRUPTS, ccp->cmd_q[i].reg_int_enable); in ccp5_enable_queue_interrupts()
671 struct ccp_cmd_queue *cmd_q = &ccp->cmd_q[i]; in ccp5_irq_bh() local
673 status = ioread32(cmd_q->reg_interrupt_status); in ccp5_irq_bh()
676 cmd_q->int_status = status; in ccp5_irq_bh()
677 cmd_q->q_status = ioread32(cmd_q->reg_status); in ccp5_irq_bh()
678 cmd_q->q_int_status = ioread32(cmd_q->reg_int_status); in ccp5_irq_bh()
681 if ((status & INT_ERROR) && !cmd_q->cmd_error) in ccp5_irq_bh()
682 cmd_q->cmd_error = CMD_Q_ERROR(cmd_q->q_status); in ccp5_irq_bh()
684 cmd_q->int_rcvd = 1; in ccp5_irq_bh()
687 iowrite32(status, cmd_q->reg_interrupt_status); in ccp5_irq_bh()
688 wake_up_interruptible(&cmd_q->int_queue); in ccp5_irq_bh()
710 struct ccp_cmd_queue *cmd_q; in ccp5_init() local
737 cmd_q = &ccp->cmd_q[ccp->cmd_q_count]; in ccp5_init()
740 cmd_q->ccp = ccp; in ccp5_init()
741 cmd_q->id = i; in ccp5_init()
742 cmd_q->dma_pool = dma_pool; in ccp5_init()
743 mutex_init(&cmd_q->q_mutex); in ccp5_init()
747 cmd_q->qsize = Q_SIZE(Q_DESC_SIZE); in ccp5_init()
748 cmd_q->qbase = dma_zalloc_coherent(dev, cmd_q->qsize, in ccp5_init()
749 &cmd_q->qbase_dma, in ccp5_init()
751 if (!cmd_q->qbase) { in ccp5_init()
757 cmd_q->qidx = 0; in ccp5_init()
761 cmd_q->reg_control = ccp->io_regs + in ccp5_init()
763 cmd_q->reg_tail_lo = cmd_q->reg_control + CMD5_Q_TAIL_LO_BASE; in ccp5_init()
764 cmd_q->reg_head_lo = cmd_q->reg_control + CMD5_Q_HEAD_LO_BASE; in ccp5_init()
765 cmd_q->reg_int_enable = cmd_q->reg_control + in ccp5_init()
767 cmd_q->reg_interrupt_status = cmd_q->reg_control + in ccp5_init()
769 cmd_q->reg_status = cmd_q->reg_control + CMD5_Q_STATUS_BASE; in ccp5_init()
770 cmd_q->reg_int_status = cmd_q->reg_control + in ccp5_init()
772 cmd_q->reg_dma_status = cmd_q->reg_control + in ccp5_init()
774 cmd_q->reg_dma_read_status = cmd_q->reg_control + in ccp5_init()
776 cmd_q->reg_dma_write_status = cmd_q->reg_control + in ccp5_init()
779 init_waitqueue_head(&cmd_q->int_queue); in ccp5_init()
793 cmd_q = &ccp->cmd_q[i]; in ccp5_init()
795 cmd_q->qcontrol = 0; /* Start with nothing */ in ccp5_init()
796 iowrite32(cmd_q->qcontrol, cmd_q->reg_control); in ccp5_init()
798 ioread32(cmd_q->reg_int_status); in ccp5_init()
799 ioread32(cmd_q->reg_status); in ccp5_init()
802 iowrite32(SUPPORTED_INTERRUPTS, cmd_q->reg_interrupt_status); in ccp5_init()
834 cmd_q = &ccp->cmd_q[i]; in ccp5_init()
836 cmd_q->qcontrol &= ~(CMD5_Q_SIZE << CMD5_Q_SHIFT); in ccp5_init()
837 cmd_q->qcontrol |= QUEUE_SIZE_VAL << CMD5_Q_SHIFT; in ccp5_init()
839 cmd_q->qdma_tail = cmd_q->qbase_dma; in ccp5_init()
840 dma_addr_lo = low_address(cmd_q->qdma_tail); in ccp5_init()
841 iowrite32((u32)dma_addr_lo, cmd_q->reg_tail_lo); in ccp5_init()
842 iowrite32((u32)dma_addr_lo, cmd_q->reg_head_lo); in ccp5_init()
844 dma_addr_hi = high_address(cmd_q->qdma_tail); in ccp5_init()
845 cmd_q->qcontrol |= (dma_addr_hi << 16); in ccp5_init()
846 iowrite32(cmd_q->qcontrol, cmd_q->reg_control); in ccp5_init()
849 ccp_find_lsb_regions(cmd_q, status); in ccp5_init()
850 cmd_q->lsb = -1; /* Unassigned value */ in ccp5_init()
862 ccp->cmd_q[i].sb_key = ccp_lsb_alloc(&ccp->cmd_q[i], 2); in ccp5_init()
863 ccp->cmd_q[i].sb_ctx = ccp_lsb_alloc(&ccp->cmd_q[i], 2); in ccp5_init()
871 cmd_q = &ccp->cmd_q[i]; in ccp5_init()
873 kthread = kthread_create(ccp_cmd_queue_thread, cmd_q, in ccp5_init()
874 "%s-q%u", ccp->name, cmd_q->id); in ccp5_init()
882 cmd_q->kthread = kthread; in ccp5_init()
909 if (ccp->cmd_q[i].kthread) in ccp5_init()
910 kthread_stop(ccp->cmd_q[i].kthread); in ccp5_init()
917 dma_pool_destroy(ccp->cmd_q[i].dma_pool); in ccp5_init()
925 struct ccp_cmd_queue *cmd_q; in ccp5_destroy() local
941 cmd_q = &ccp->cmd_q[i]; in ccp5_destroy()
944 iowrite32(cmd_q->qcontrol & ~CMD5_Q_RUN, cmd_q->reg_control); in ccp5_destroy()
947 iowrite32(SUPPORTED_INTERRUPTS, cmd_q->reg_interrupt_status); in ccp5_destroy()
948 ioread32(cmd_q->reg_int_status); in ccp5_destroy()
949 ioread32(cmd_q->reg_status); in ccp5_destroy()
954 if (ccp->cmd_q[i].kthread) in ccp5_destroy()
955 kthread_stop(ccp->cmd_q[i].kthread); in ccp5_destroy()
960 cmd_q = &ccp->cmd_q[i]; in ccp5_destroy()
961 dma_free_coherent(dev, cmd_q->qsize, cmd_q->qbase, in ccp5_destroy()
962 cmd_q->qbase_dma); in ccp5_destroy()