[PATCH] nvme: Boot as soon as the boot controller has been probed
Bart Van Assche
bvanassche at acm.org
Sat Nov 7 23:09:03 EST 2020
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 at redhat.com>
Cc: Keith Busch <keith.busch at intel.com>
Cc: Greg KH <gregkh at linuxfoundation.org>
Signed-off-by: Bart Van Assche <bvanassche at 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,
};
More information about the Linux-nvme
mailing list