nvme-fc: replace ida_simple[get|remove] with the simler ida_[alloc|free]
[linux-2.6-microblaze.git] / drivers / nvme / host / fc.c
index aa14ad9..96a5d7f 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/nvme-fc.h>
 #include "fc.h"
 #include <scsi/scsi_transport_fc.h>
+#include <linux/blk-mq-pci.h>
 
 /* *************************** Data Structures/Defines ****************** */
 
@@ -258,7 +259,7 @@ nvme_fc_free_lport(struct kref *ref)
                complete(&nvme_fc_unload_proceed);
        spin_unlock_irqrestore(&nvme_fc_lock, flags);
 
-       ida_simple_remove(&nvme_fc_local_port_cnt, lport->localport.port_num);
+       ida_free(&nvme_fc_local_port_cnt, lport->localport.port_num);
        ida_destroy(&lport->endp_cnt);
 
        put_device(lport->dev);
@@ -398,7 +399,7 @@ nvme_fc_register_localport(struct nvme_fc_port_info *pinfo,
                goto out_reghost_failed;
        }
 
-       idx = ida_simple_get(&nvme_fc_local_port_cnt, 0, 0, GFP_KERNEL);
+       idx = ida_alloc(&nvme_fc_local_port_cnt, GFP_KERNEL);
        if (idx < 0) {
                ret = -ENOSPC;
                goto out_fail_kfree;
@@ -438,7 +439,7 @@ nvme_fc_register_localport(struct nvme_fc_port_info *pinfo,
        return 0;
 
 out_ida_put:
-       ida_simple_remove(&nvme_fc_local_port_cnt, idx);
+       ida_free(&nvme_fc_local_port_cnt, idx);
 out_fail_kfree:
        kfree(newrec);
 out_reghost_failed:
@@ -534,7 +535,7 @@ nvme_fc_free_rport(struct kref *ref)
        spin_unlock_irqrestore(&nvme_fc_lock, flags);
 
        WARN_ON(!list_empty(&rport->disc_list));
-       ida_simple_remove(&lport->endp_cnt, rport->remoteport.port_num);
+       ida_free(&lport->endp_cnt, rport->remoteport.port_num);
 
        kfree(rport);
 
@@ -712,7 +713,7 @@ nvme_fc_register_remoteport(struct nvme_fc_local_port *localport,
                goto out_lport_put;
        }
 
-       idx = ida_simple_get(&lport->endp_cnt, 0, 0, GFP_KERNEL);
+       idx = ida_alloc(&lport->endp_cnt, GFP_KERNEL);
        if (idx < 0) {
                ret = -ENOSPC;
                goto out_kfree_rport;
@@ -2382,7 +2383,7 @@ nvme_fc_ctrl_free(struct kref *ref)
        list_del(&ctrl->ctrl_list);
        spin_unlock_irqrestore(&ctrl->rport->lock, flags);
 
-       blk_mq_unquiesce_queue(ctrl->ctrl.admin_q);
+       nvme_start_admin_queue(&ctrl->ctrl);
        blk_cleanup_queue(ctrl->ctrl.admin_q);
        blk_cleanup_queue(ctrl->ctrl.fabrics_q);
        blk_mq_free_tag_set(&ctrl->admin_tag_set);
@@ -2392,7 +2393,7 @@ nvme_fc_ctrl_free(struct kref *ref)
        put_device(ctrl->dev);
        nvme_fc_rport_put(ctrl->rport);
 
-       ida_simple_remove(&nvme_fc_ctrl_cnt, ctrl->cnum);
+       ida_free(&nvme_fc_ctrl_cnt, ctrl->cnum);
        if (ctrl->ctrl.opts)
                nvmf_free_options(ctrl->ctrl.opts);
        kfree(ctrl);
@@ -2510,7 +2511,7 @@ __nvme_fc_abort_outstanding_ios(struct nvme_fc_ctrl *ctrl, bool start_queues)
        /*
         * clean up the admin queue. Same thing as above.
         */
-       blk_mq_quiesce_queue(ctrl->ctrl.admin_q);
+       nvme_stop_admin_queue(&ctrl->ctrl);
        blk_sync_queue(ctrl->ctrl.admin_q);
        blk_mq_tagset_busy_iter(&ctrl->admin_tag_set,
                                nvme_fc_terminate_exchange, &ctrl->ctrl);
@@ -2841,6 +2842,28 @@ nvme_fc_complete_rq(struct request *rq)
        nvme_fc_ctrl_put(ctrl);
 }
 
+static int nvme_fc_map_queues(struct blk_mq_tag_set *set)
+{
+       struct nvme_fc_ctrl *ctrl = set->driver_data;
+       int i;
+
+       for (i = 0; i < set->nr_maps; i++) {
+               struct blk_mq_queue_map *map = &set->map[i];
+
+               if (!map->nr_queues) {
+                       WARN_ON(i == HCTX_TYPE_DEFAULT);
+                       continue;
+               }
+
+               /* Call LLDD map queue functionality if defined */
+               if (ctrl->lport->ops->map_queues)
+                       ctrl->lport->ops->map_queues(&ctrl->lport->localport,
+                                                    map);
+               else
+                       blk_mq_map_queues(map);
+       }
+       return 0;
+}
 
 static const struct blk_mq_ops nvme_fc_mq_ops = {
        .queue_rq       = nvme_fc_queue_rq,
@@ -2849,6 +2872,7 @@ static const struct blk_mq_ops nvme_fc_mq_ops = {
        .exit_request   = nvme_fc_exit_request,
        .init_hctx      = nvme_fc_init_hctx,
        .timeout        = nvme_fc_timeout,
+       .map_queues     = nvme_fc_map_queues,
 };
 
 static int
@@ -3095,7 +3119,7 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl)
        ctrl->ctrl.max_hw_sectors = ctrl->ctrl.max_segments <<
                                                (ilog2(SZ_4K) - 9);
 
-       blk_mq_unquiesce_queue(ctrl->ctrl.admin_q);
+       nvme_start_admin_queue(&ctrl->ctrl);
 
        ret = nvme_init_ctrl_finish(&ctrl->ctrl);
        if (ret || test_bit(ASSOC_FAILED, &ctrl->flags))
@@ -3249,7 +3273,7 @@ nvme_fc_delete_association(struct nvme_fc_ctrl *ctrl)
        nvme_fc_free_queue(&ctrl->queues[0]);
 
        /* re-enable the admin_q so anything new can fast fail */
-       blk_mq_unquiesce_queue(ctrl->ctrl.admin_q);
+       nvme_start_admin_queue(&ctrl->ctrl);
 
        /* resume the io queues so that things will fast fail */
        nvme_start_queues(&ctrl->ctrl);
@@ -3448,7 +3472,7 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,
                goto out_fail;
        }
 
-       idx = ida_simple_get(&nvme_fc_ctrl_cnt, 0, 0, GFP_KERNEL);
+       idx = ida_alloc(&nvme_fc_ctrl_cnt, GFP_KERNEL);
        if (idx < 0) {
                ret = -ENOSPC;
                goto out_free_ctrl;
@@ -3572,7 +3596,7 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,
 
        dev_info(ctrl->ctrl.device,
                "NVME-FC{%d}: new ctrl: NQN \"%s\"\n",
-               ctrl->cnum, ctrl->ctrl.opts->subsysnqn);
+               ctrl->cnum, nvmf_ctrl_subsysnqn(&ctrl->ctrl));
 
        return &ctrl->ctrl;
 
@@ -3611,7 +3635,7 @@ out_free_queues:
        kfree(ctrl->queues);
 out_free_ida:
        put_device(ctrl->dev);
-       ida_simple_remove(&nvme_fc_ctrl_cnt, ctrl->cnum);
+       ida_free(&nvme_fc_ctrl_cnt, ctrl->cnum);
 out_free_ctrl:
        kfree(ctrl);
 out_fail: