Lines Matching refs:nq
755 static void put_tag(struct nullb_queue *nq, unsigned int tag)
757 clear_bit_unlock(tag, nq->tag_map);
759 if (waitqueue_active(&nq->wait))
760 wake_up(&nq->wait);
763 static unsigned int get_tag(struct nullb_queue *nq)
768 tag = find_first_zero_bit(nq->tag_map, nq->queue_depth);
769 if (tag >= nq->queue_depth)
771 } while (test_and_set_bit_lock(tag, nq->tag_map));
778 put_tag(cmd->nq, cmd->tag);
783 static struct nullb_cmd *__alloc_cmd(struct nullb_queue *nq)
788 tag = get_tag(nq);
790 cmd = &nq->cmds[tag];
793 cmd->nq = nq;
794 if (nq->dev->irqmode == NULL_IRQ_TIMER) {
805 static struct nullb_cmd *alloc_cmd(struct nullb_queue *nq, struct bio *bio)
815 cmd = __alloc_cmd(nq);
820 prepare_to_wait(&nq->wait, &wait, TASK_UNINTERRUPTIBLE);
822 finish_wait(&nq->wait, &wait);
828 int queue_mode = cmd->nq->dev->queue_mode;
852 ktime_t kt = cmd->nq->dev->completion_nsec;
1277 struct nullb *nullb = cmd->nq->dev->nullb;
1304 struct nullb *nullb = cmd->nq->dev->nullb;
1345 struct nullb_device *dev = cmd->nq->dev;
1368 struct badblocks *bb = &cmd->nq->dev->badblocks;
1383 struct nullb_device *dev = cmd->nq->dev;
1399 struct nullb_device *dev = cmd->nq->dev;
1426 switch (cmd->nq->dev->irqmode) {
1428 switch (cmd->nq->dev->queue_mode) {
1452 struct nullb_device *dev = cmd->nq->dev;
1470 struct nullb_device *dev = cmd->nq->dev;
1541 struct nullb_queue *nq = nullb_to_queue(nullb);
1543 null_handle_cmd(alloc_cmd(nq, bio), sector, nr_sectors, bio_op(bio));
1551 struct nullb_device *dev = cmd->nq->dev;
1559 struct nullb_device *dev = cmd->nq->dev;
1643 struct nullb_queue *nq = hctx->driver_data;
1648 spin_lock(&nq->poll_lock);
1649 list_splice_init(&nq->poll_list, &list);
1652 spin_unlock(&nq->poll_lock);
1678 struct nullb_queue *nq = hctx->driver_data;
1680 spin_lock(&nq->poll_lock);
1683 spin_unlock(&nq->poll_lock);
1687 spin_unlock(&nq->poll_lock);
1710 struct nullb_queue *nq = hctx->driver_data;
1717 if (!is_poll && nq->dev->irqmode == NULL_IRQ_TIMER) {
1723 cmd->nq = nq;
1734 nq->requeue_selection++;
1735 if (nq->requeue_selection & 1)
1742 spin_lock(&nq->poll_lock);
1743 list_add_tail(&rq->queuelist, &nq->poll_list);
1744 spin_unlock(&nq->poll_lock);
1753 static void cleanup_queue(struct nullb_queue *nq)
1755 bitmap_free(nq->tag_map);
1756 kfree(nq->cmds);
1771 struct nullb_queue *nq = hctx->driver_data;
1772 struct nullb *nullb = nq->dev->nullb;
1777 static void null_init_queue(struct nullb *nullb, struct nullb_queue *nq)
1779 init_waitqueue_head(&nq->wait);
1780 nq->queue_depth = nullb->queue_depth;
1781 nq->dev = nullb->dev;
1782 INIT_LIST_HEAD(&nq->poll_list);
1783 spin_lock_init(&nq->poll_lock);
1790 struct nullb_queue *nq;
1795 nq = &nullb->queues[hctx_idx];
1796 hctx->driver_data = nq;
1797 null_init_queue(nullb, nq);
1877 static int setup_commands(struct nullb_queue *nq)
1882 nq->cmds = kcalloc(nq->queue_depth, sizeof(*cmd), GFP_KERNEL);
1883 if (!nq->cmds)
1886 nq->tag_map = bitmap_zalloc(nq->queue_depth, GFP_KERNEL);
1887 if (!nq->tag_map) {
1888 kfree(nq->cmds);
1892 for (i = 0; i < nq->queue_depth; i++) {
1893 cmd = &nq->cmds[i];
1918 struct nullb_queue *nq;
1922 nq = &nullb->queues[i];
1924 null_init_queue(nullb, nq);
1926 ret = setup_commands(nq);