Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvme: Boot as soon as the boot controller has been probed
@ 2020-11-08  4:09 Bart Van Assche
  2020-11-08  8:24 ` Greg KH
                   ` (3 more replies)
  0 siblings, 4 replies; 18+ messages in thread
From: Bart Van Assche @ 2020-11-08  4:09 UTC (permalink / raw)
  To: Keith Busch, Sagi Grimberg
  Cc: Greg KH, Mikulas Patocka, Christoph Hellwig, linux-nvme,
	Bart Van Assche

The following two issues have been introduced by commit 1811977568e0
("nvme/pci: Use async_schedule for initial reset work"):
- The boot process waits until all NVMe controllers have been probed
  instead of only waiting until the boot controller has been probed.
  This slows down the boot process.
- Some of the controller probing work happens asynchronously without
  the device core being aware of this.

Hence this patch that makes all probing work happen from nvme_probe()
and that tells the device core to probe multiple NVMe controllers
concurrently by setting PROBE_PREFER_ASYNCHRONOUS.

Cc: Mikulas Patocka <mpatocka@redhat.com>
Cc: Keith Busch <keith.busch@intel.com>
Cc: Greg KH <gregkh@linuxfoundation.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/nvme/host/pci.c | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 0578ff253c47..703bb3aee817 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -6,7 +6,6 @@
 
 #include <linux/acpi.h>
 #include <linux/aer.h>
-#include <linux/async.h>
 #include <linux/blkdev.h>
 #include <linux/blk-mq.h>
 #include <linux/blk-mq-pci.h>
@@ -2821,15 +2820,6 @@ static inline bool nvme_acpi_storage_d3(struct pci_dev *dev)
 }
 #endif /* CONFIG_ACPI */
 
-static void nvme_async_probe(void *data, async_cookie_t cookie)
-{
-	struct nvme_dev *dev = data;
-
-	flush_work(&dev->ctrl.reset_work);
-	flush_work(&dev->ctrl.scan_work);
-	nvme_put_ctrl(&dev->ctrl);
-}
-
 static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 {
 	int node, result = -ENOMEM;
@@ -2903,8 +2893,16 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
 	dev_info(dev->ctrl.device, "pci function %s\n", dev_name(&pdev->dev));
 
-	nvme_reset_ctrl(&dev->ctrl);
-	async_schedule(nvme_async_probe, dev);
+	if (nvme_reset_ctrl(&dev->ctrl) == 0) {
+		/*
+		 * Since reset_work is scheduled on the context of
+		 * nvme_reset_wq and since that workqueue is not used for
+		 * probing devices, waiting until reset_work from nvme_probe()
+		 * is fine.
+		 */
+		flush_work(&dev->ctrl.reset_work);
+	}
+	nvme_put_ctrl(&dev->ctrl);
 
 	return 0;
 
@@ -3221,11 +3219,12 @@ static struct pci_driver nvme_driver = {
 	.probe		= nvme_probe,
 	.remove		= nvme_remove,
 	.shutdown	= nvme_shutdown,
-#ifdef CONFIG_PM_SLEEP
 	.driver		= {
+#ifdef CONFIG_PM_SLEEP
 		.pm	= &nvme_dev_pm_ops,
-	},
 #endif
+		.probe_type	= PROBE_PREFER_ASYNCHRONOUS,
+	},
 	.sriov_configure = pci_sriov_configure_simple,
 	.err_handler	= &nvme_err_handler,
 };

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2020-11-19 20:18 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-08  4:09 [PATCH] nvme: Boot as soon as the boot controller has been probed Bart Van Assche
2020-11-08  8:24 ` Greg KH
2020-11-08 22:31   ` Keith Busch
2020-11-08 23:35     ` Bart Van Assche
2020-11-09  2:35       ` Keith Busch
2020-11-09  4:00         ` Bart Van Assche
2020-11-09 15:05           ` Keith Busch
2020-11-10  2:51             ` Bart Van Assche
2020-11-10  3:12               ` Keith Busch
2020-11-08 19:13 ` Sagi Grimberg
2020-11-08 19:18   ` Greg KH
2020-11-08 23:00   ` Bart Van Assche
2020-11-09  3:04 ` Keith Busch
2020-11-11 19:19 ` Keith Busch
2020-11-12  4:26   ` Bart Van Assche
2020-11-12 14:20     ` Keith Busch
2020-11-19  3:08       ` Bart Van Assche
2020-11-19 20:18         ` Keith Busch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox