Lines Matching refs:nq
726 static void put_tag(struct nullb_queue *nq, unsigned int tag) in put_tag() argument
728 clear_bit_unlock(tag, nq->tag_map); in put_tag()
730 if (waitqueue_active(&nq->wait)) in put_tag()
731 wake_up(&nq->wait); in put_tag()
734 static unsigned int get_tag(struct nullb_queue *nq) in get_tag() argument
739 tag = find_first_zero_bit(nq->tag_map, nq->queue_depth); in get_tag()
740 if (tag >= nq->queue_depth) in get_tag()
742 } while (test_and_set_bit_lock(tag, nq->tag_map)); in get_tag()
749 put_tag(cmd->nq, cmd->tag); in free_cmd()
754 static struct nullb_cmd *__alloc_cmd(struct nullb_queue *nq) in __alloc_cmd() argument
759 tag = get_tag(nq); in __alloc_cmd()
761 cmd = &nq->cmds[tag]; in __alloc_cmd()
764 cmd->nq = nq; in __alloc_cmd()
765 if (nq->dev->irqmode == NULL_IRQ_TIMER) { in __alloc_cmd()
776 static struct nullb_cmd *alloc_cmd(struct nullb_queue *nq, struct bio *bio) in alloc_cmd() argument
786 cmd = __alloc_cmd(nq); in alloc_cmd()
791 prepare_to_wait(&nq->wait, &wait, TASK_UNINTERRUPTIBLE); in alloc_cmd()
793 finish_wait(&nq->wait, &wait); in alloc_cmd()
799 int queue_mode = cmd->nq->dev->queue_mode; in end_cmd()
823 ktime_t kt = cmd->nq->dev->completion_nsec; in null_cmd_end_timer()
1263 struct nullb *nullb = cmd->nq->dev->nullb; in null_handle_rq()
1290 struct nullb *nullb = cmd->nq->dev->nullb; in null_handle_bio()
1331 struct nullb_device *dev = cmd->nq->dev; in null_handle_throttled()
1354 struct badblocks *bb = &cmd->nq->dev->badblocks; in null_handle_badblocks()
1369 struct nullb_device *dev = cmd->nq->dev; in null_handle_memory_backed()
1385 struct nullb_device *dev = cmd->nq->dev; in nullb_zero_read_cmd_buffer()
1412 switch (cmd->nq->dev->irqmode) { in nullb_complete_cmd()
1414 switch (cmd->nq->dev->queue_mode) { in nullb_complete_cmd()
1439 struct nullb_device *dev = cmd->nq->dev; in null_process_cmd()
1457 struct nullb_device *dev = cmd->nq->dev; in null_handle_cmd()
1528 struct nullb_queue *nq = nullb_to_queue(nullb); in null_submit_bio() local
1530 null_handle_cmd(alloc_cmd(nq, bio), sector, nr_sectors, bio_op(bio)); in null_submit_bio()
1606 struct nullb_queue *nq = hctx->driver_data; in null_poll() local
1610 spin_lock(&nq->poll_lock); in null_poll()
1611 list_splice_init(&nq->poll_list, &list); in null_poll()
1612 spin_unlock(&nq->poll_lock); in null_poll()
1640 struct nullb_queue *nq = hctx->driver_data; in null_timeout_rq() local
1642 spin_lock(&nq->poll_lock); in null_timeout_rq()
1644 spin_unlock(&nq->poll_lock); in null_timeout_rq()
1664 struct nullb_queue *nq = hctx->driver_data; in null_queue_rq() local
1671 if (!is_poll && nq->dev->irqmode == NULL_IRQ_TIMER) { in null_queue_rq()
1677 cmd->nq = nq; in null_queue_rq()
1687 nq->requeue_selection++; in null_queue_rq()
1688 if (nq->requeue_selection & 1) in null_queue_rq()
1697 spin_lock(&nq->poll_lock); in null_queue_rq()
1698 list_add_tail(&bd->rq->queuelist, &nq->poll_list); in null_queue_rq()
1699 spin_unlock(&nq->poll_lock); in null_queue_rq()
1708 static void cleanup_queue(struct nullb_queue *nq) in cleanup_queue() argument
1710 bitmap_free(nq->tag_map); in cleanup_queue()
1711 kfree(nq->cmds); in cleanup_queue()
1726 struct nullb_queue *nq = hctx->driver_data; in null_exit_hctx() local
1727 struct nullb *nullb = nq->dev->nullb; in null_exit_hctx()
1732 static void null_init_queue(struct nullb *nullb, struct nullb_queue *nq) in null_init_queue() argument
1734 init_waitqueue_head(&nq->wait); in null_init_queue()
1735 nq->queue_depth = nullb->queue_depth; in null_init_queue()
1736 nq->dev = nullb->dev; in null_init_queue()
1737 INIT_LIST_HEAD(&nq->poll_list); in null_init_queue()
1738 spin_lock_init(&nq->poll_lock); in null_init_queue()
1745 struct nullb_queue *nq; in null_init_hctx() local
1752 nq = &nullb->queues[hctx_idx]; in null_init_hctx()
1753 hctx->driver_data = nq; in null_init_hctx()
1754 null_init_queue(nullb, nq); in null_init_hctx()
1834 static int setup_commands(struct nullb_queue *nq) in setup_commands() argument
1839 nq->cmds = kcalloc(nq->queue_depth, sizeof(*cmd), GFP_KERNEL); in setup_commands()
1840 if (!nq->cmds) in setup_commands()
1843 nq->tag_map = bitmap_zalloc(nq->queue_depth, GFP_KERNEL); in setup_commands()
1844 if (!nq->tag_map) { in setup_commands()
1845 kfree(nq->cmds); in setup_commands()
1849 for (i = 0; i < nq->queue_depth; i++) { in setup_commands()
1850 cmd = &nq->cmds[i]; in setup_commands()
1875 struct nullb_queue *nq; in init_driver_queues() local
1879 nq = &nullb->queues[i]; in init_driver_queues()
1881 null_init_queue(nullb, nq); in init_driver_queues()
1883 ret = setup_commands(nq); in init_driver_queues()