History

Merge branch 'nvme-5.2-rc2' of git://git.infradead.org/nvme into for-linus

Pull NVMe changes from Keith. * 'nvme-5.2-rc2' of git://git.infradead.org/nvme: nvme-pci: use blk-mq mapping for unmanaged irqs nvme: update MAINTAINERS nvme: copy MTFA field from identify controller nvme: fix memory leak for power latency tolerance nvme: release namespace SRCU protection before performing controller ioctls nvme: merge nvme_ns_ioctl into nvme_ioctl nvme: remove the ifdef around nvme_nvm_ioctl nvme: fix srcu locking on error return in nvme_get_ns_from_disk nvme: Fix known effects nvme-pci: Sync queues on reset nvme-pci: Unblock reset_work on IO failure nvme-pci: Don't disable on timeout in reset state nvme-pci: Fix controller freeze wait disabling

Jens Axboe committed 7 years ago

Commit 096c7a62 parents 004d564 cb9e0e54 files · +77 −42Browse files

Unified · Split

4 files
  1. MAINTAINERS +1 −1
  2. drivers/nvme/host/core.c +61 −28
  3. drivers/nvme/host/nvme.h +1 −0
  4. drivers/nvme/host/pci.c +14 −13
MAINTAINERS+1−1
@@ -11227,7 +11227,7 @@ F: drivers/video/fbdev/riva/ · 11226 unmodified lines
1122711227 F: drivers/video/fbdev/nvidia/
1122811228
1122911229 NVM EXPRESS DRIVER
11230−M: Keith Busch <keith.busch@intel.com>
11230+M: Keith Busch <kbusch@kernel.org>
1123111231 M: Jens Axboe <axboe@fb.com>
1123211232 M: Christoph Hellwig <hch@lst.de>
1123311233 M: Sagi Grimberg <sagi@grimberg.me>
drivers/nvme/host/core.c+61−28
@@ -1257,9 +1257,9 @@ static u32 nvme_passthru_start(struct nvme_ctrl *ctrl, struct nvme_ns *ns, · 1256 unmodified lines
12571257 return 0;
12581258 }
12591259
1260− effects |= nvme_known_admin_effects(opcode);
12611260 if (ctrl->effects)
12621261 effects = le32_to_cpu(ctrl->effects->acs[opcode]);
1262+ effects |= nvme_known_admin_effects(opcode);
12631263
12641264 /*
12651265 * For simplicity, IO to all namespaces is quiesced even if the command
@@ -1361,9 +1361,14 @@ static struct nvme_ns *nvme_get_ns_from_disk(struct gendisk *disk, · 95 unmodified lines
13611361 {
13621362 #ifdef CONFIG_NVME_MULTIPATH
13631363 if (disk->fops == &nvme_ns_head_ops) {
1364+ struct nvme_ns *ns;
1365+
13641366 *head = disk->private_data;
13651367 *srcu_idx = srcu_read_lock(&(*head)->srcu);
1366− return nvme_find_path(*head);
1368+ ns = nvme_find_path(*head);
1369+ if (!ns)
1370+ srcu_read_unlock(&(*head)->srcu, *srcu_idx);
1371+ return ns;
13671372 }
13681373 #endif
13691374 *head = NULL;
@@ -1377,42 +1382,56 @@ static void nvme_put_ns_from_disk(struct nvme_ns_head *head, int idx) · 7 unmodified lines
13771382 srcu_read_unlock(&head->srcu, idx);
13781383 }
13791384
1380−static int nvme_ns_ioctl(struct nvme_ns *ns, unsigned cmd, unsigned long arg)
1385+static int nvme_ioctl(struct block_device *bdev, fmode_t mode,
1386+ unsigned int cmd, unsigned long arg)
13811387 {
1388+ struct nvme_ns_head *head = NULL;
1389+ void __user *argp = (void __user *)arg;
1390+ struct nvme_ns *ns;
1391+ int srcu_idx, ret;
1392+
1393+ ns = nvme_get_ns_from_disk(bdev->bd_disk, &head, &srcu_idx);
1394+ if (unlikely(!ns))
1395+ return -EWOULDBLOCK;
1396+
1397+ /*
1398+ * Handle ioctls that apply to the controller instead of the namespace
1399+ * seperately and drop the ns SRCU reference early. This avoids a
1400+ * deadlock when deleting namespaces using the passthrough interface.
1401+ */
1402+ if (cmd == NVME_IOCTL_ADMIN_CMD || is_sed_ioctl(cmd)) {
1403+ struct nvme_ctrl *ctrl = ns->ctrl;
1404+
1405+ nvme_get_ctrl(ns->ctrl);
1406+ nvme_put_ns_from_disk(head, srcu_idx);
1407+
1408+ if (cmd == NVME_IOCTL_ADMIN_CMD)
1409+ ret = nvme_user_cmd(ctrl, NULL, argp);
1410+ else
1411+ ret = sed_ioctl(ctrl->opal_dev, cmd, argp);
1412+
1413+ nvme_put_ctrl(ctrl);
1414+ return ret;
1415+ }
1416+
13821417 switch (cmd) {
13831418 case NVME_IOCTL_ID:
13841419 force_successful_syscall_return();
1385− return ns->head->ns_id;
1386− case NVME_IOCTL_ADMIN_CMD:
1387− return nvme_user_cmd(ns->ctrl, NULL, (void __user *)arg);
1420+ ret = ns->head->ns_id;
1421+ break;
13881422 case NVME_IOCTL_IO_CMD:
1389− return nvme_user_cmd(ns->ctrl, ns, (void __user *)arg);
1423+ ret = nvme_user_cmd(ns->ctrl, ns, argp);
1424+ break;
13901425 case NVME_IOCTL_SUBMIT_IO:
1391− return nvme_submit_io(ns, (void __user *)arg);
1426+ ret = nvme_submit_io(ns, argp);
1427+ break;
13921428 default:
1393−#ifdef CONFIG_NVM
13941429 if (ns->ndev)
1395− return nvme_nvm_ioctl(ns, cmd, arg);
1396−#endif
1397− if (is_sed_ioctl(cmd))
1398− return sed_ioctl(ns->ctrl->opal_dev, cmd,
1399− (void __user *) arg);
1400− return -ENOTTY;
1430+ ret = nvme_nvm_ioctl(ns, cmd, arg);
1431+ else
1432+ ret = -ENOTTY;
14011433 }
1402−}
1403−
1404−static int nvme_ioctl(struct block_device *bdev, fmode_t mode,
1405− unsigned int cmd, unsigned long arg)
1406−{
1407− struct nvme_ns_head *head = NULL;
1408− struct nvme_ns *ns;
1409− int srcu_idx, ret;
14101434
1411− ns = nvme_get_ns_from_disk(bdev->bd_disk, &head, &srcu_idx);
1412− if (unlikely(!ns))
1413− ret = -EWOULDBLOCK;
1414− else
1415− ret = nvme_ns_ioctl(ns, cmd, arg);
14161435 nvme_put_ns_from_disk(head, srcu_idx);
14171436 return ret;
14181437 }
@@ -2557,6 +2576,7 @@ int nvme_init_identify(struct nvme_ctrl *ctrl) · 1138 unmodified lines
25572576
25582577 ctrl->oacs = le16_to_cpu(id->oacs);
25592578 ctrl->oncs = le16_to_cpu(id->oncs);
2579+ ctrl->mtfa = le16_to_cpu(id->mtfa);
25602580 ctrl->oaes = le32_to_cpu(id->oaes);
25612581 atomic_set(&ctrl->abort_limit, id->acl + 1);
25622582 ctrl->vwc = id->vwc;
@@ -3681,6 +3701,7 @@ EXPORT_SYMBOL_GPL(nvme_start_ctrl); · 1118 unmodified lines
36813701
36823702 void nvme_uninit_ctrl(struct nvme_ctrl *ctrl)
36833703 {
3704+ dev_pm_qos_hide_latency_tolerance(ctrl->device);
36843705 cdev_device_del(&ctrl->cdev, ctrl->device);
36853706 }
36863707 EXPORT_SYMBOL_GPL(nvme_uninit_ctrl);
@@ -3880,6 +3901,18 @@ void nvme_start_queues(struct nvme_ctrl *ctrl) · 193 unmodified lines
38803901 }
38813902 EXPORT_SYMBOL_GPL(nvme_start_queues);
38823903
3904+
3905+void nvme_sync_queues(struct nvme_ctrl *ctrl)
3906+{
3907+ struct nvme_ns *ns;
3908+
3909+ down_read(&ctrl->namespaces_rwsem);
3910+ list_for_each_entry(ns, &ctrl->namespaces, list)
3911+ blk_sync_queue(ns->queue);
3912+ up_read(&ctrl->namespaces_rwsem);
3913+}
3914+EXPORT_SYMBOL_GPL(nvme_sync_queues);
3915+
38833916 /*
38843917 * Check we didn't inadvertently grow the command structure sizes:
38853918 */
drivers/nvme/host/nvme.h+1−0
@@ -441,6 +441,7 @@ void nvme_complete_async_event(struct nvme_ctrl *ctrl, __le16 status, · 440 unmodified lines
441441 void nvme_stop_queues(struct nvme_ctrl *ctrl);
442442 void nvme_start_queues(struct nvme_ctrl *ctrl);
443443 void nvme_kill_queues(struct nvme_ctrl *ctrl);
444+void nvme_sync_queues(struct nvme_ctrl *ctrl);
444445 void nvme_unfreeze(struct nvme_ctrl *ctrl);
445446 void nvme_wait_freeze(struct nvme_ctrl *ctrl);
446447 void nvme_wait_freeze_timeout(struct nvme_ctrl *ctrl, long timeout);
drivers/nvme/host/pci.c+14−13
@@ -464,7 +464,7 @@ static int nvme_pci_map_queues(struct blk_mq_tag_set *set) · 463 unmodified lines
464464 * affinity), so use the regular blk-mq cpu mapping
465465 */
466466 map->queue_offset = qoff;
467− if (i != HCTX_TYPE_POLL)
467+ if (i != HCTX_TYPE_POLL && offset)
468468 blk_mq_pci_map_queues(map, to_pci_dev(dev->dev), offset);
469469 else
470470 blk_mq_map_queues(map);
@@ -1257,7 +1257,6 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req, bool reserved) · 786 unmodified lines
12571257 struct nvme_dev *dev = nvmeq->dev;
12581258 struct request *abort_req;
12591259 struct nvme_command cmd;
1260− bool shutdown = false;
12611260 u32 csts = readl(dev->bar + NVME_REG_CSTS);
12621261
12631262 /* If PCI error recovery process is happening, we cannot reset or
@@ -1294,17 +1293,18 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req, bool reserved) · 30 unmodified lines
12941293 * shutdown, so we return BLK_EH_DONE.
12951294 */
12961295 switch (dev->ctrl.state) {
1297− case NVME_CTRL_DELETING:
1298− shutdown = true;
1299− /* fall through */
13001296 case NVME_CTRL_CONNECTING:
1301− case NVME_CTRL_RESETTING:
1297+ nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_DELETING);
1298+ /* fall through */
1299+ case NVME_CTRL_DELETING:
13021300 dev_warn_ratelimited(dev->ctrl.device,
13031301 "I/O %d QID %d timeout, disable controller\n",
13041302 req->tag, nvmeq->qid);
1305− nvme_dev_disable(dev, shutdown);
1303+ nvme_dev_disable(dev, true);
13061304 nvme_req(req)->flags |= NVME_REQ_CANCELLED;
13071305 return BLK_EH_DONE;
1306+ case NVME_CTRL_RESETTING:
1307+ return BLK_EH_RESET_TIMER;
13081308 default:
13091309 break;
13101310 }
@@ -2376,7 +2376,7 @@ static void nvme_pci_disable(struct nvme_dev *dev) · 1065 unmodified lines
23762376
23772377 static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown)
23782378 {
2379− bool dead = true;
2379+ bool dead = true, freeze = false;
23802380 struct pci_dev *pdev = to_pci_dev(dev->dev);
23812381
23822382 mutex_lock(&dev->shutdown_lock);
@@ -2384,8 +2384,10 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown) · 1 unmodified line
23842384 u32 csts = readl(dev->bar + NVME_REG_CSTS);
23852385
23862386 if (dev->ctrl.state == NVME_CTRL_LIVE ||
2387− dev->ctrl.state == NVME_CTRL_RESETTING)
2387+ dev->ctrl.state == NVME_CTRL_RESETTING) {
2388+ freeze = true;
23882389 nvme_start_freeze(&dev->ctrl);
2390+ }
23892391 dead = !!((csts & NVME_CSTS_CFS) || !(csts & NVME_CSTS_RDY) ||
23902392 pdev->error_state != pci_channel_io_normal);
23912393 }
@@ -2394,10 +2396,8 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown) · 2 unmodified lines
23942396 * Give the controller a chance to complete all entered requests if
23952397 * doing a safe shutdown.
23962398 */
2397− if (!dead) {
2398− if (shutdown)
2399− nvme_wait_freeze_timeout(&dev->ctrl, NVME_IO_TIMEOUT);
2400− }
2399+ if (!dead && shutdown && freeze)
2400+ nvme_wait_freeze_timeout(&dev->ctrl, NVME_IO_TIMEOUT);
24012401
24022402 nvme_stop_queues(&dev->ctrl);
24032403
@@ -2492,6 +2492,7 @@ static void nvme_reset_work(struct work_struct *work) · 88 unmodified lines
24922492 */
24932493 if (dev->ctrl.ctrl_config & NVME_CC_ENABLE)
24942494 nvme_dev_disable(dev, false);
2495+ nvme_sync_queues(&dev->ctrl);
24952496
24962497 mutex_lock(&dev->shutdown_lock);
24972498 result = nvme_pci_enable(dev);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t