|
@@ -102,11 +102,6 @@ struct nvme_dev {
|
|
|
dma_addr_t cmb_dma_addr;
|
|
|
u64 cmb_size;
|
|
|
u32 cmbsz;
|
|
|
- unsigned long flags;
|
|
|
-
|
|
|
-#define NVME_CTRL_RESETTING 0
|
|
|
-#define NVME_CTRL_REMOVING 1
|
|
|
-
|
|
|
struct nvme_ctrl ctrl;
|
|
|
struct completion ioq_wait;
|
|
|
};
|
|
@@ -277,9 +272,8 @@ static void nvme_queue_scan(struct nvme_dev *dev)
|
|
|
* Do not queue new scan work when a controller is reset during
|
|
|
* removal.
|
|
|
*/
|
|
|
- if (test_bit(NVME_CTRL_REMOVING, &dev->flags))
|
|
|
- return;
|
|
|
- queue_work(nvme_workq, &dev->scan_work);
|
|
|
+ if (dev->ctrl.state != NVME_CTRL_DELETING)
|
|
|
+ queue_work(nvme_workq, &dev->scan_work);
|
|
|
}
|
|
|
|
|
|
static void nvme_complete_async_event(struct nvme_dev *dev,
|
|
@@ -901,7 +895,7 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req, bool reserved)
|
|
|
* cancellation error. All outstanding requests are completed on
|
|
|
* shutdown, so we return BLK_EH_HANDLED.
|
|
|
*/
|
|
|
- if (test_bit(NVME_CTRL_RESETTING, &dev->flags)) {
|
|
|
+ if (dev->ctrl.state == NVME_CTRL_RESETTING) {
|
|
|
dev_warn(dev->ctrl.device,
|
|
|
"I/O %d QID %d timeout, disable controller\n",
|
|
|
req->tag, nvmeq->qid);
|
|
@@ -1835,7 +1829,7 @@ static void nvme_reset_work(struct work_struct *work)
|
|
|
struct nvme_dev *dev = container_of(work, struct nvme_dev, reset_work);
|
|
|
int result = -ENODEV;
|
|
|
|
|
|
- if (WARN_ON(test_bit(NVME_CTRL_RESETTING, &dev->flags)))
|
|
|
+ if (WARN_ON(dev->ctrl.state == NVME_CTRL_RESETTING))
|
|
|
goto out;
|
|
|
|
|
|
/*
|
|
@@ -1845,7 +1839,8 @@ static void nvme_reset_work(struct work_struct *work)
|
|
|
if (dev->ctrl.ctrl_config & NVME_CC_ENABLE)
|
|
|
nvme_dev_disable(dev, false);
|
|
|
|
|
|
- set_bit(NVME_CTRL_RESETTING, &dev->flags);
|
|
|
+ if (!nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_RESETTING))
|
|
|
+ goto out;
|
|
|
|
|
|
result = nvme_pci_enable(dev);
|
|
|
if (result)
|
|
@@ -1894,7 +1889,10 @@ static void nvme_reset_work(struct work_struct *work)
|
|
|
nvme_dev_add(dev);
|
|
|
}
|
|
|
|
|
|
- clear_bit(NVME_CTRL_RESETTING, &dev->flags);
|
|
|
+ if (!nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_LIVE)) {
|
|
|
+ dev_warn(dev->ctrl.device, "failed to mark controller live\n");
|
|
|
+ goto out;
|
|
|
+ }
|
|
|
return;
|
|
|
|
|
|
out:
|
|
@@ -2067,7 +2065,8 @@ static void nvme_remove(struct pci_dev *pdev)
|
|
|
|
|
|
del_timer_sync(&dev->watchdog_timer);
|
|
|
|
|
|
- set_bit(NVME_CTRL_REMOVING, &dev->flags);
|
|
|
+ nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_DELETING);
|
|
|
+
|
|
|
pci_set_drvdata(pdev, NULL);
|
|
|
flush_work(&dev->async_work);
|
|
|
flush_work(&dev->scan_work);
|