diff options
| author | Jens Axboe <axboe@kernel.dk> | 2019-02-06 10:43:07 -0500 |
|---|---|---|
| committer | Jens Axboe <axboe@kernel.dk> | 2019-02-06 10:43:07 -0500 |
| commit | d592974f8c32d3e3110c693145c4cd8730779839 (patch) | |
| tree | d71d5b7665464c904c72b4715f1ba60bf7fdc0b6 | |
| parent | ec51f8ee1e63498e9f521ec0e5a6d04622bb2c67 (diff) | |
| parent | 5c959d73dba6495ec01d04c206ee679d61ccb2b0 (diff) | |
Merge branch 'nvme-5.0' of git://git.infradead.org/nvme into for-linus
Pull NVMe fixes from Christoph for this release.
* 'nvme-5.0' of git://git.infradead.org/nvme:
nvme-pci: fix rapid add remove sequence
nvme: lock NS list changes while handling command effects
| -rw-r--r-- | drivers/nvme/host/core.c | 8 | ||||
| -rw-r--r-- | drivers/nvme/host/nvme.h | 1 | ||||
| -rw-r--r-- | drivers/nvme/host/pci.c | 22 |
3 files changed, 20 insertions, 11 deletions
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 150e49723c15..6a9dd68c0f4f 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c | |||
| @@ -1253,6 +1253,7 @@ static u32 nvme_passthru_start(struct nvme_ctrl *ctrl, struct nvme_ns *ns, | |||
| 1253 | * effects say only one namespace is affected. | 1253 | * effects say only one namespace is affected. |
| 1254 | */ | 1254 | */ |
| 1255 | if (effects & (NVME_CMD_EFFECTS_LBCC | NVME_CMD_EFFECTS_CSE_MASK)) { | 1255 | if (effects & (NVME_CMD_EFFECTS_LBCC | NVME_CMD_EFFECTS_CSE_MASK)) { |
| 1256 | mutex_lock(&ctrl->scan_lock); | ||
| 1256 | nvme_start_freeze(ctrl); | 1257 | nvme_start_freeze(ctrl); |
| 1257 | nvme_wait_freeze(ctrl); | 1258 | nvme_wait_freeze(ctrl); |
| 1258 | } | 1259 | } |
| @@ -1281,8 +1282,10 @@ static void nvme_passthru_end(struct nvme_ctrl *ctrl, u32 effects) | |||
| 1281 | */ | 1282 | */ |
| 1282 | if (effects & NVME_CMD_EFFECTS_LBCC) | 1283 | if (effects & NVME_CMD_EFFECTS_LBCC) |
| 1283 | nvme_update_formats(ctrl); | 1284 | nvme_update_formats(ctrl); |
| 1284 | if (effects & (NVME_CMD_EFFECTS_LBCC | NVME_CMD_EFFECTS_CSE_MASK)) | 1285 | if (effects & (NVME_CMD_EFFECTS_LBCC | NVME_CMD_EFFECTS_CSE_MASK)) { |
| 1285 | nvme_unfreeze(ctrl); | 1286 | nvme_unfreeze(ctrl); |
| 1287 | mutex_unlock(&ctrl->scan_lock); | ||
| 1288 | } | ||
| 1286 | if (effects & NVME_CMD_EFFECTS_CCC) | 1289 | if (effects & NVME_CMD_EFFECTS_CCC) |
| 1287 | nvme_init_identify(ctrl); | 1290 | nvme_init_identify(ctrl); |
| 1288 | if (effects & (NVME_CMD_EFFECTS_NIC | NVME_CMD_EFFECTS_NCC)) | 1291 | if (effects & (NVME_CMD_EFFECTS_NIC | NVME_CMD_EFFECTS_NCC)) |
| @@ -3401,6 +3404,7 @@ static void nvme_scan_work(struct work_struct *work) | |||
| 3401 | if (nvme_identify_ctrl(ctrl, &id)) | 3404 | if (nvme_identify_ctrl(ctrl, &id)) |
| 3402 | return; | 3405 | return; |
| 3403 | 3406 | ||
| 3407 | mutex_lock(&ctrl->scan_lock); | ||
| 3404 | nn = le32_to_cpu(id->nn); | 3408 | nn = le32_to_cpu(id->nn); |
| 3405 | if (ctrl->vs >= NVME_VS(1, 1, 0) && | 3409 | if (ctrl->vs >= NVME_VS(1, 1, 0) && |
| 3406 | !(ctrl->quirks & NVME_QUIRK_IDENTIFY_CNS)) { | 3410 | !(ctrl->quirks & NVME_QUIRK_IDENTIFY_CNS)) { |
| @@ -3409,6 +3413,7 @@ static void nvme_scan_work(struct work_struct *work) | |||
| 3409 | } | 3413 | } |
| 3410 | nvme_scan_ns_sequential(ctrl, nn); | 3414 | nvme_scan_ns_sequential(ctrl, nn); |
| 3411 | out_free_id: | 3415 | out_free_id: |
| 3416 | mutex_unlock(&ctrl->scan_lock); | ||
| 3412 | kfree(id); | 3417 | kfree(id); |
| 3413 | down_write(&ctrl->namespaces_rwsem); | 3418 | down_write(&ctrl->namespaces_rwsem); |
| 3414 | list_sort(NULL, &ctrl->namespaces, ns_cmp); | 3419 | list_sort(NULL, &ctrl->namespaces, ns_cmp); |
| @@ -3652,6 +3657,7 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev, | |||
| 3652 | 3657 | ||
| 3653 | ctrl->state = NVME_CTRL_NEW; | 3658 | ctrl->state = NVME_CTRL_NEW; |
| 3654 | spin_lock_init(&ctrl->lock); | 3659 | spin_lock_init(&ctrl->lock); |
| 3660 | mutex_init(&ctrl->scan_lock); | ||
| 3655 | INIT_LIST_HEAD(&ctrl->namespaces); | 3661 | INIT_LIST_HEAD(&ctrl->namespaces); |
| 3656 | init_rwsem(&ctrl->namespaces_rwsem); | 3662 | init_rwsem(&ctrl->namespaces_rwsem); |
| 3657 | ctrl->dev = dev; | 3663 | ctrl->dev = dev; |
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index ab961bdeea89..c4a1bb41abf0 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h | |||
| @@ -154,6 +154,7 @@ struct nvme_ctrl { | |||
| 154 | enum nvme_ctrl_state state; | 154 | enum nvme_ctrl_state state; |
| 155 | bool identified; | 155 | bool identified; |
| 156 | spinlock_t lock; | 156 | spinlock_t lock; |
| 157 | struct mutex scan_lock; | ||
| 157 | const struct nvme_ctrl_ops *ops; | 158 | const struct nvme_ctrl_ops *ops; |
| 158 | struct request_queue *admin_q; | 159 | struct request_queue *admin_q; |
| 159 | struct request_queue *connect_q; | 160 | struct request_queue *connect_q; |
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 9bc585415d9b..022ea1ee63f8 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c | |||
| @@ -2557,16 +2557,7 @@ static void nvme_reset_work(struct work_struct *work) | |||
| 2557 | if (dev->ctrl.ctrl_config & NVME_CC_ENABLE) | 2557 | if (dev->ctrl.ctrl_config & NVME_CC_ENABLE) |
| 2558 | nvme_dev_disable(dev, false); | 2558 | nvme_dev_disable(dev, false); |
| 2559 | 2559 | ||
| 2560 | /* | 2560 | mutex_lock(&dev->shutdown_lock); |
| 2561 | * Introduce CONNECTING state from nvme-fc/rdma transports to mark the | ||
| 2562 | * initializing procedure here. | ||
| 2563 | */ | ||
| 2564 | if (!nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_CONNECTING)) { | ||
| 2565 | dev_warn(dev->ctrl.device, | ||
| 2566 | "failed to mark controller CONNECTING\n"); | ||
| 2567 | goto out; | ||
| 2568 | } | ||
| 2569 | |||
| 2570 | result = nvme_pci_enable(dev); | 2561 | result = nvme_pci_enable(dev); |
| 2571 | if (result) | 2562 | if (result) |
| 2572 | goto out; | 2563 | goto out; |
| @@ -2585,6 +2576,17 @@ static void nvme_reset_work(struct work_struct *work) | |||
| 2585 | */ | 2576 | */ |
| 2586 | dev->ctrl.max_hw_sectors = NVME_MAX_KB_SZ << 1; | 2577 | dev->ctrl.max_hw_sectors = NVME_MAX_KB_SZ << 1; |
| 2587 | dev->ctrl.max_segments = NVME_MAX_SEGS; | 2578 | dev->ctrl.max_segments = NVME_MAX_SEGS; |
| 2579 | mutex_unlock(&dev->shutdown_lock); | ||
| 2580 | |||
| 2581 | /* | ||
| 2582 | * Introduce CONNECTING state from nvme-fc/rdma transports to mark the | ||
| 2583 | * initializing procedure here. | ||
| 2584 | */ | ||
| 2585 | if (!nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_CONNECTING)) { | ||
| 2586 | dev_warn(dev->ctrl.device, | ||
| 2587 | "failed to mark controller CONNECTING\n"); | ||
| 2588 | goto out; | ||
| 2589 | } | ||
| 2588 | 2590 | ||
| 2589 | result = nvme_init_identify(&dev->ctrl); | 2591 | result = nvme_init_identify(&dev->ctrl); |
| 2590 | if (result) | 2592 | if (result) |
