Lines Matching refs:nq

614 static void put_tag(struct nullb_queue *nq, unsigned int tag)
616 clear_bit_unlock(tag, nq->tag_map);
618 if (waitqueue_active(&nq->wait))
619 wake_up(&nq->wait);
622 static unsigned int get_tag(struct nullb_queue *nq)
627 tag = find_first_zero_bit(nq->tag_map, nq->queue_depth);
628 if (tag >= nq->queue_depth)
630 } while (test_and_set_bit_lock(tag, nq->tag_map));
637 put_tag(cmd->nq, cmd->tag);
642 static struct nullb_cmd *__alloc_cmd(struct nullb_queue *nq)
647 tag = get_tag(nq);
649 cmd = &nq->cmds[tag];
652 cmd->nq = nq;
653 if (nq->dev->irqmode == NULL_IRQ_TIMER) {
664 static struct nullb_cmd *alloc_cmd(struct nullb_queue *nq, int can_wait)
669 cmd = __alloc_cmd(nq);
674 prepare_to_wait(&nq->wait, &wait, TASK_UNINTERRUPTIBLE);
675 cmd = __alloc_cmd(nq);
682 finish_wait(&nq->wait, &wait);
688 int queue_mode = cmd->nq->dev->queue_mode;
712 ktime_t kt = cmd->nq->dev->completion_nsec;
1149 struct nullb *nullb = cmd->nq->dev->nullb;
1183 struct nullb *nullb = cmd->nq->dev->nullb;
1232 struct nullb_device *dev = cmd->nq->dev;
1255 struct badblocks *bb = &cmd->nq->dev->badblocks;
1268 struct nullb_device *dev = cmd->nq->dev;
1281 struct nullb_device *dev = cmd->nq->dev;
1308 switch (cmd->nq->dev->irqmode) {
1310 switch (cmd->nq->dev->queue_mode) {
1335 struct nullb_device *dev = cmd->nq->dev;
1353 struct nullb_device *dev = cmd->nq->dev;
1424 struct nullb_queue *nq = nullb_to_queue(nullb);
1427 cmd = alloc_cmd(nq, 1);
1475 struct nullb_queue *nq = hctx->driver_data;
1481 if (nq->dev->irqmode == NULL_IRQ_TIMER) {
1487 cmd->nq = nq;
1498 nq->requeue_selection++;
1499 if (nq->requeue_selection & 1)
1512 static void cleanup_queue(struct nullb_queue *nq)
1514 kfree(nq->tag_map);
1515 kfree(nq->cmds);
1530 struct nullb_queue *nq = hctx->driver_data;
1531 struct nullb *nullb = nq->dev->nullb;
1536 static void null_init_queue(struct nullb *nullb, struct nullb_queue *nq)
1538 init_waitqueue_head(&nq->wait);
1539 nq->queue_depth = nullb->queue_depth;
1540 nq->dev = nullb->dev;
1547 struct nullb_queue *nq;
1554 nq = &nullb->queues[hctx_idx];
1555 hctx->driver_data = nq;
1556 null_init_queue(nullb, nq);
1631 static int setup_commands(struct nullb_queue *nq)
1636 nq->cmds = kcalloc(nq->queue_depth, sizeof(*cmd), GFP_KERNEL);
1637 if (!nq->cmds)
1640 tag_size = ALIGN(nq->queue_depth, BITS_PER_LONG) / BITS_PER_LONG;
1641 nq->tag_map = kcalloc(tag_size, sizeof(unsigned long), GFP_KERNEL);
1642 if (!nq->tag_map) {
1643 kfree(nq->cmds);
1647 for (i = 0; i < nq->queue_depth; i++) {
1648 cmd = &nq->cmds[i];
1669 struct nullb_queue *nq;
1673 nq = &nullb->queues[i];
1675 null_init_queue(nullb, nq);
1677 ret = setup_commands(nq);