diff options
author | Christoph Hellwig <hch@lst.de> | 2015-10-02 18:49:23 +0200 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2015-10-09 10:40:36 -0600 |
commit | 90667892c5a78b47080359883a569a260e9e87ed (patch) | |
tree | 183972dd064dce2d0dc83a4548a9a225a09c54a3 /drivers/block | |
parent | 77b50d9e15e113fdb871218aa0f2e3bed12ee731 (diff) | |
download | op-kernel-dev-90667892c5a78b47080359883a569a260e9e87ed.zip op-kernel-dev-90667892c5a78b47080359883a569a260e9e87ed.tar.gz |
nvme: factor reset code into a common helper
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/nvme-core.c | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c index 509ad4b..e03a95b 100644 --- a/drivers/block/nvme-core.c +++ b/drivers/block/nvme-core.c @@ -84,6 +84,7 @@ static wait_queue_head_t nvme_kthread_wait; static struct class *nvme_class; +static int __nvme_reset(struct nvme_dev *dev); static int nvme_reset(struct nvme_dev *dev); static int nvme_process_cq(struct nvme_queue *nvmeq); @@ -1276,17 +1277,13 @@ static void nvme_abort_req(struct request *req) struct nvme_command cmd; if (!nvmeq->qid || cmd_rq->aborted) { - unsigned long flags; - - spin_lock_irqsave(&dev_list_lock, flags); - if (work_busy(&dev->reset_work)) - goto out; - list_del_init(&dev->node); - dev_warn(dev->dev, "I/O %d QID %d timeout, reset controller\n", - req->tag, nvmeq->qid); - queue_work(nvme_workq, &dev->reset_work); - out: - spin_unlock_irqrestore(&dev_list_lock, flags); + spin_lock(&dev_list_lock); + if (!__nvme_reset(dev)) { + dev_warn(dev->dev, + "I/O %d QID %d timeout, reset controller\n", + req->tag, nvmeq->qid); + } + spin_unlock(&dev_list_lock); return; } @@ -2081,13 +2078,11 @@ static int nvme_kthread(void *data) if ((dev->subsystem && (csts & NVME_CSTS_NSSRO)) || csts & NVME_CSTS_CFS) { - if (work_busy(&dev->reset_work)) - continue; - list_del_init(&dev->node); - dev_warn(dev->dev, - "Failed status: %x, reset controller\n", - readl(&dev->bar->csts)); - queue_work(nvme_workq, &dev->reset_work); + if (!__nvme_reset(dev)) { + dev_warn(dev->dev, + "Failed status: %x, reset controller\n", + readl(&dev->bar->csts)); + } continue; } for (i = 0; i < dev->queue_count; i++) { @@ -3074,19 +3069,24 @@ static void nvme_reset_work(struct work_struct *ws) schedule_work(&dev->probe_work); } +static int __nvme_reset(struct nvme_dev *dev) +{ + if (work_pending(&dev->reset_work)) + return -EBUSY; + list_del_init(&dev->node); + queue_work(nvme_workq, &dev->reset_work); + return 0; +} + static int nvme_reset(struct nvme_dev *dev) { - int ret = -EBUSY; + int ret; if (!dev->admin_q || blk_queue_dying(dev->admin_q)) return -ENODEV; spin_lock(&dev_list_lock); - if (!work_pending(&dev->reset_work)) { - list_del_init(&dev->node); - queue_work(nvme_workq, &dev->reset_work); - ret = 0; - } + ret = __nvme_reset(dev); spin_unlock(&dev_list_lock); if (!ret) { |