Skip to contentSkip to conversation

Make NVME shutdown two-pass - Version 3

PATCH In review Jeremy Allison 6 participants 22 messages Dec 21, 2023 – Jan 8, 2024

Subsystems (5)
PCI Driver core NVMe NVMe target +1 more subsystems
lore
Share & tools
lore
#0 lore raw

This is version 3 of a patchset originally written by Tanjore Suresh <[email protected]> to make shutdown of nvme devices two-pass.

Changes from version 2:

1). As requested by Christoph Hellwig, don't add shutdown_pre() shutdown_post() methods, only add a shutdown_wait() method to prevent clutter in the interfaces. Two pass shutdown is only done if both shutdown() and shutdown_wait() methods are defined.

2). As requested by Christoph Hellwig, split out the addition of the 'enum shutdown_type' into a separate patch to make the subsequent changes clearer.

3). Use 'two-pass' instead of async in the interface documentation. This isn't truly async as there's no notification on completion.

-------------------------------------------------------------
Currently the Linux nvme driver shutdown code steps through each connected drive, sets the NVME_CC_SHN_NORMAL (normal shutdown) flag and then polls the given drive waiting for the response NVME_CSTS_SHST_CMPLT flag (shutdown complete).

Each drive is taking around 13 seconds to respond to this.

The customer has 20+ drives on the box so this time adds up on shutdown when the nvme driver is being shut down.

This patchset changes shutdown to proceed in parallel, so the NVME_CC_SHN_NORMAL (normal shutdown) flag is sent to all drives first, and then it polls waiting for the NVME_CSTS_SHST_CMPLT flag (shutdown complete) for all drives.

In the specific customer case it reduces the NVME shutdown time from over 300 seconds to around 15 seconds.
-------------------------------------------------------------

Thanks for your consideration,

Jeremy Allison.
CIQ / Samba Team.

#1 lore raw

PATCH 1/4 driver core: Support two-pass driver shutdown

From: Tanjore Suresh <[email protected]>

This changes the bus driver interface with an additional entry point to enable devices to implement two-pass shutdown. The existing synchronous interface to shutdown is called, and if a shutdown_wait method is defined the device is moved to an alternate list.

Once the shutdown method is called for all devices, the shutdown_wait method is then called synchronously for all devices on the alternate list.

---
 drivers/base/core.c        | 35 +++++++++++++++++++++++++++++++++++
 include/linux/device/bus.h |  6 +++++-
 2 files changed, 40 insertions(+), 1 deletion(-)
drivers/base/core.c +35 -0
index 67ba592afc77..a66988cbaad1 100644
@@ -4725,6 +4725,7 @@ EXPORT_SYMBOL_GPL(device_change_owner);
 void device_shutdown(void)
 {
 	struct device *dev, *parent;
+	LIST_HEAD(shutdown_wait_list);
 
 	wait_for_device_probe();
 	device_block_probing();
@@ -4769,10 +4770,15 @@ void device_shutdown(void)
 				dev_info(dev, "shutdown_pre\n");
 			dev->class->shutdown_pre(dev);
 		}
+
 		if (dev->bus && dev->bus->shutdown) {
 			if (initcall_debug)
 				dev_info(dev, "shutdown\n");
 			dev->bus->shutdown(dev);
+			/* Only put the device on the shutdown_wait_list
+			 * if a shutdown_wait() method is also defined. */
+			if (dev->bus->shutdown_wait)
+				list_add(&dev->kobj.entry, &shutdown_wait_list);
 		} else if (dev->driver && dev->driver->shutdown) {
 			if (initcall_debug)
 				dev_info(dev, "shutdown\n");
@@ -4789,6 +4795,35 @@ void device_shutdown(void)
 		spin_lock(&devices_kset->list_lock);
 	}
 	spin_unlock(&devices_kset->list_lock);
+
+	/*
+	 * Second pass only for devices that have configured
+	 * a shutdown_wait() method.
+	 */
+	while (!list_empty(&shutdown_wait_list)) {
+		dev = list_entry(shutdown_wait_list.next, struct device,
+				kobj.entry);
+		parent = get_device(dev->parent);
+		get_device(dev);
+		/*
+		 * Make sure the device is off the  list
+		 */
+		list_del_init(&dev->kobj.entry);
+		if (parent)
+			device_lock(parent);
+		device_lock(dev);
+		if (dev->bus && dev->bus->shutdown_wait) {
+			if (initcall_debug)
+				dev_info(dev,
+				"shutdown_wait called\n");
+			dev->bus->shutdown_wait(dev);
+		}
+		device_unlock(dev);
+		if (parent)
+			device_unlock(parent);
+		put_device(dev);
+		put_device(parent);
+	}
 }
 
 /*
include/linux/device/bus.h +5 -1
index ae10c4322754..6f192221b551 100644
@@ -48,7 +48,10 @@ struct fwnode_handle;
  *		will never get called until they do.
  * @remove:	Called when a device removed from this bus.
  * @shutdown:	Called at shut-down time to quiesce the device.
- *
+ * @shutdown_wait:	If this method exists, devices are stored on a separate
+ * 			list after shutdown() has been called and
+ * 			shutdown_wait() is called synchronously on each device
+ * 			in this list in turn.
  * @online:	Called to put the device back online (after offlining it).
  * @offline:	Called to put the device offline for hot-removal. May fail.
  *
@@ -90,6 +93,7 @@ struct bus_type {
 	void (*sync_state)(struct device *dev);
 	void (*remove)(struct device *dev);
 	void (*shutdown)(struct device *dev);
+	void (*shutdown_wait)(struct device *dev);
 
 	int (*online)(struct device *dev);
 	int (*offline)(struct device *dev);
Signature · 1 line
2.39.3
maintainer Acked-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] driver core: Support two-pass driver shutdown

Quoted 7 lines · Jeremy Allison

From: Tanjore Suresh <[email protected]>

This changes the bus driver interface with an additional entry point to enable devices to implement two-pass shutdown. The existing synchronous interface to shutdown is called, and if a shutdown_wait method is defined the device is moved to an alternate list.

Quoted 6 lines

Once the shutdown method is called for all devices, the shutdown_wait method is then called synchronously for all devices on the alternate list.

#3 lore raw

Re: [PATCH 1/4] driver core: Support two-pass driver shutdown

In reply to Jeremy Allison
Quoted 10 lines · Jeremy Allison

From: Tanjore Suresh <[email protected]>

This changes the bus driver interface with an additional entry point to enable devices to implement two-pass shutdown. The existing synchronous interface to shutdown is called, and if a shutdown_wait method is defined the device is moved to an alternate list.

Once the shutdown method is called for all devices, the shutdown_wait method is then called synchronously for all devices on the alternate list.

Christoph and Sagi noted that the objective is similar to "fire now and wait for completion later."

Would it be practical to actually *do* that, e.g., add a global shutdown workqueue, have the .shutdown() method of nvme and similar drivers add items to it, and have the driver core wait until everything on that workqueue has completed?

But I'm not a workqueue expert and I do see the scary warning at
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/workqueue.h?id=v6.6#n619,
about not flushing system-wide workqueues, so maybe this wouldn't be workable.

Bjorn

maintainer
#4 lore raw

Re: [PATCH 1/4] driver core: Support two-pass driver shutdown

Quoted 20 lines
Quoted 11 lines

From: Tanjore Suresh <[email protected]>

This changes the bus driver interface with an additional entry point to enable devices to implement two-pass shutdown. The existing synchronous interface to shutdown is called, and if a shutdown_wait method is defined the device is moved to an alternate list.

Once the shutdown method is called for all devices, the shutdown_wait method is then called synchronously for all devices on the alternate list.

Christoph and Sagi noted that the objective is similar to "fire now and wait for completion later."

Would it be practical to actually *do* that, e.g., add a global shutdown workqueue, have the .shutdown() method of nvme and similar drivers add items to it, and have the driver core wait until everything on that workqueue has completed?

Quoted 4 lines

But I'm not a workqueue expert and I do see the scary warning at
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/workqueue.h?id=v6.6#n619,
about not flushing system-wide workqueues, so maybe this wouldn't be workable.

I don't think that a workqueue is necessary. What I do think that we should document somewhere that .shutdown() can be synchronous or asynchronous when paired with .shutdown_wait().

#5 lore raw

Re: [PATCH 1/4] driver core: Support two-pass driver shutdown

Quoted 20 lines · Sagi Grimberg
Quoted 20 lines
Quoted 11 lines

From: Tanjore Suresh <[email protected]>

This changes the bus driver interface with an additional entry point to enable devices to implement two-pass shutdown. The existing synchronous interface to shutdown is called, and if a shutdown_wait method is defined the device is moved to an alternate list.

Once the shutdown method is called for all devices, the shutdown_wait method is then called synchronously for all devices on the alternate list.

Christoph and Sagi noted that the objective is similar to "fire now and wait for completion later."

Would it be practical to actually *do* that, e.g., add a global shutdown workqueue, have the .shutdown() method of nvme and similar drivers add items to it, and have the driver core wait until everything on that workqueue has completed?

Quoted 8 lines
Quoted 4 lines

But I'm not a workqueue expert and I do see the scary warning at
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/workqueue.h?id=v6.6#n619,
about not flushing system-wide workqueues, so maybe this wouldn't be workable.

I don't think that a workqueue is necessary. What I do think that we should document somewhere that .shutdown() can be synchronous or asynchronous when paired with .shutdown_wait().

It's not exactly asynchronous when paired with .shutdown_wait(). That's why I used the phrase "two-pass" instead of asynchronous.

Also, I already added this documentation:

+ * @shutdown_wait: Optional driver callback to allow two-pass shutdown.

in the struct pci_driver comment definition in one of the previous patches.

#6 lore raw

Re: [PATCH 1/4] driver core: Support two-pass driver shutdown

Quoted 2 lines · Jeremy Allison

It's not exactly asynchronous when paired with .shutdown_wait(). That's why I used the phrase "two-pass" instead of asynchronous.

Yes, that's actually a much more descriptive term.

#7 lore raw

Re: [PATCH 1/4] driver core: Support two-pass driver shutdown

In reply to Bjorn Helgaas
Quoted 20 lines · Bjorn Helgaas
Quoted 10 lines · Jeremy Allison

From: Tanjore Suresh <[email protected]>

This changes the bus driver interface with an additional entry point to enable devices to implement two-pass shutdown. The existing synchronous interface to shutdown is called, and if a shutdown_wait method is defined the device is moved to an alternate list.

Once the shutdown method is called for all devices, the shutdown_wait method is then called synchronously for all devices on the alternate list.

Christoph and Sagi noted that the objective is similar to "fire now and wait for completion later."

Would it be practical to actually *do* that, e.g., add a global shutdown workqueue, have the .shutdown() method of nvme and similar drivers add items to it, and have the driver core wait until everything on that workqueue has completed?

Quoted 4 lines

But I'm not a workqueue expert and I do see the scary warning at
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/workqueue.h?id=v6.6#n619,
about not flushing system-wide workqueues, so maybe this wouldn't be workable.

This is a bigger change than I'm comfortable with (or indeed understand :-) right now. Can we fix the immediate problem first please and then look for improvements later ?

#8 lore raw

Re: [PATCH 1/4] driver core: Support two-pass driver shutdown

Quoted 9 lines · Jeremy Allison
Quoted 4 lines

But I'm not a workqueue expert and I do see the scary warning at
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/workqueue.h?id=v6.6#n619,
about not flushing system-wide workqueues, so maybe this wouldn't be workable.

This is a bigger change than I'm comfortable with (or indeed understand :-) right now. Can we fix the immediate problem first please and then look for improvements later ?

It's also a lot less efficient. Assuming NVMe isn't alone and other hardware interfaces also have a shutdown/disable busy wait (and I've seen quite a few that do) as their limiting factor the two-pass shutdown seems much nicer than spawning tons of work items.

#9 lore raw

Re: [PATCH 1/4] driver core: Support two-pass driver shutdown

Quoted 11 lines · Christoph Hellwig
Quoted 9 lines · Jeremy Allison
Quoted 4 lines

But I'm not a workqueue expert and I do see the scary warning at
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/workqueue.h?id=v6.6#n619,
about not flushing system-wide workqueues, so maybe this wouldn't be workable.

This is a bigger change than I'm comfortable with (or indeed understand :-) right now. Can we fix the immediate problem first please and then look for improvements later ?

Quoted 4 lines

It's also a lot less efficient. Assuming NVMe isn't alone and other hardware interfaces also have a shutdown/disable busy wait (and I've seen quite a few that do) as their limiting factor the two-pass shutdown seems much nicer than spawning tons of work items.

Here's the essence of the two-pass proposal, adding .shutdown_wait():

    device_shutdown
      for_each_device
        dev->bus->shutdown()
          ...
            nvme_shutdown
              nvme_disable_prepare_reset
                nvme_dev_disable
                  nvme_disable_ctrl
  +                 case NVME_DISABLE_SHUTDOWN_ASYNC:
  +                   return;
  +                 case NVME_DISABLE_SHUTDOWN_SYNC:
                      nvme_wait_ready(...);

+ if (dev->bus->shutdown_wait)
+ list_add(&shutdown_wait_list)
+
+ for_each(&shutdown_wait_list)
+ dev->bus->shutdown_wait()
+ pci_device_shutdown_wait
+ nvme_shutdown_wait
+ nvme_wait_ready(...)

FWIW, what I imagined was something like this, where we don't add .shutdown_wait(), but any .shutdown() method could become asynchronous by queuing a work item to do the wait:

+ nvme_wait_ready_work
+ nvme_wait_ready(...)

device_shutdown

  +   async_shutdown_wq = create_workqueue("async_shutdown");
      for_each_device
        dev->bus->shutdown()
          ...
            nvme_shutdown
              nvme_disable_prepare_reset
                nvme_dev_disable
                  nvme_disable_ctrl
  +                 case NVME_DISABLE_SHUTDOWN_ASYNC:
  +                   queue_work(async_shutdown_wq, &nvme_wait_ready_work)
  +                   return;
  +                 case NVME_DISABLE_SHUTDOWN_SYNC:
                      nvme_wait_ready(...);

+
+ destroy_workqueue(async_shutdown_wq);

This is a bit of hand waving because I'm not a workqueue expert, but it seems like basically the same amount of overhead without having to add .shutdown_wait() to the bus_type and the pci_driver.

Bjorn

#10 lore raw

Re: [PATCH 1/4] driver core: Support two-pass driver shutdown

Quoted 3 lines · Bjorn Helgaas

This is a bit of hand waving because I'm not a workqueue expert, but it seems like basically the same amount of overhead without having to add .shutdown_wait() to the bus_type and the pci_driver.

It spawns a new work for the busy wait for the shutdown. That's not a very efficient programming model.

#11 lore raw

PATCH 2/4 PCI: Support two-pass shutdown

In reply to Jeremy Allison

From: Tanjore Suresh <[email protected]>

Enhances the base PCI driver to add support for two-pass shutdown. Adds shutdown_wait() method.

Assume a device takes n secs to shutdown. If a machine has been populated with M such devices, the total time spent in shutting down all the devices will be M * n secs if the shutdown is done synchronously. For example, if NVMe PCI Controllers take 5 secs to shutdown and if there are 16 such NVMe controllers in a system, system will spend a total of 80 secs to shutdown all
NVMe devices in that system.

In order to speed up the shutdown time, a two-pass interface to shutdown has been implemented. The caller calls the shutdown method for each device in turn to allow a shutdown request to be sent, then the caller walks the list of devices and calls shutdown_wait() to synchronously wait for the shutdown to complete.

In the NVMe case above, all 16 devices will process the shutdown in parallel taking the total time to shutdown down to the time for one NVMe PCI Controller to shut down.

This will significantly reduce the machine reboot time.

---
 drivers/pci/pci-driver.c | 9 +++++++++
 include/linux/pci.h      | 2 ++
 2 files changed, 11 insertions(+)
drivers/pci/pci-driver.c +9 -0
index 51ec9e7e784f..257bbb04c806 100644
@@ -547,6 +547,14 @@ static int pci_restore_standard_config(struct pci_dev *pci_dev)
 }
 #endif /* CONFIG_PM_SLEEP */
 
+static void pci_device_shutdown_wait(struct device *dev)
+{
+	struct pci_dev *pci_dev = to_pci_dev(dev);
+	struct pci_driver *drv = pci_dev->driver;
+
+	if (drv && drv->shutdown_wait)
+		drv->shutdown_wait(pci_dev);
+}
 #ifdef CONFIG_PM
 
 /* Auxiliary functions used for system resume and run-time resume */
@@ -1682,6 +1690,7 @@ struct bus_type pci_bus_type = {
 	.probe		= pci_device_probe,
 	.remove		= pci_device_remove,
 	.shutdown	= pci_device_shutdown,
+	.shutdown_wait	= pci_device_shutdown_wait,
 	.dev_groups	= pci_dev_groups,
 	.bus_groups	= pci_bus_groups,
 	.drv_groups	= pci_drv_groups,
include/linux/pci.h +2 -0
index 60ca768bc867..e3ba7043c7de 100644
@@ -917,6 +917,7 @@ struct module;
  *		Useful for enabling wake-on-lan (NIC) or changing
  *		the power state of a device before reboot.
  *		e.g. drivers/net/e100.c.
+ * @shutdown_wait: Optional driver callback to allow two-pass shutdown.
  * @sriov_configure: Optional driver callback to allow configuration of
  *		number of VFs to enable via sysfs "sriov_numvfs" file.
  * @sriov_set_msix_vec_count: PF Driver callback to change number of MSI-X
@@ -948,6 +949,7 @@ struct pci_driver {
 	int  (*suspend)(struct pci_dev *dev, pm_message_t state);	/* Device suspended */
 	int  (*resume)(struct pci_dev *dev);	/* Device woken up */
 	void (*shutdown)(struct pci_dev *dev);
+	void (*shutdown_wait)(struct pci_dev *dev);
 	int  (*sriov_configure)(struct pci_dev *dev, int num_vfs); /* On PF */
 	int  (*sriov_set_msix_vec_count)(struct pci_dev *vf, int msix_vec_count); /* On PF */
 	u32  (*sriov_get_vf_total_msix)(struct pci_dev *pf);
Signature · 1 line
2.39.3
#12 lore raw

PATCH 3/4 Change 'bool shutdown' into an enum shutdown_type { NVME_DISABLE_RESET = 0, NVME_DISABLE_SHUTDOWN_SYNC = 1 }.

In reply to Jeremy Allison

Convert nvme_disable_ctrl() and nvme_dev_disable() inside drivers/nvme/host/pci.c to use this

bool shutdown = false == NVME_DISABLE_RESET bool shutdown = true == NVME_DISABLE_SHUTDOWN_SYNC.

This will make it easier to add a third request: NVME_DISABLE_SHUTDOWN_ASNYC later.

As nvme_disable_ctrl() is used outside of drivers/nvme/host/pci.c, convert the callers of nvme_disable_ctrl() to this convention too.

---
 drivers/nvme/host/apple.c  |  4 ++--
 drivers/nvme/host/core.c   |  6 +++---
 drivers/nvme/host/nvme.h   |  7 +++++-
 drivers/nvme/host/pci.c    | 44 +++++++++++++++++++-------------------
 drivers/nvme/host/rdma.c   |  3 ++-
 drivers/nvme/host/tcp.c    |  3 ++-
 drivers/nvme/target/loop.c |  2 +-
 7 files changed, 38 insertions(+), 31 deletions(-)
drivers/nvme/host/apple.c +2 -2
index 596bb11eeba5..764639ede41d 100644
@@ -844,8 +844,8 @@ static void apple_nvme_disable(struct apple_nvme *anv, bool shutdown)
 		 * NVMe disabled state, after a clean shutdown).
 		 */
 		if (shutdown)
-			nvme_disable_ctrl(&anv->ctrl, shutdown);
-		nvme_disable_ctrl(&anv->ctrl, false);
+			nvme_disable_ctrl(&anv->ctrl, NVME_DISABLE_SHUTDOWN_SYNC);
+		nvme_disable_ctrl(&anv->ctrl, NVME_DISABLE_RESET);
 	}
 
 	WRITE_ONCE(anv->ioq.enabled, false);
drivers/nvme/host/core.c +3 -3
index d144d1acb09a..bc7040da8e74 100644
@@ -2211,12 +2211,12 @@ static int nvme_wait_ready(struct nvme_ctrl *ctrl, u32 mask, u32 val,
 	return ret;
 }
 
-int nvme_disable_ctrl(struct nvme_ctrl *ctrl, bool shutdown)
+int nvme_disable_ctrl(struct nvme_ctrl *ctrl, enum shutdown_type shutdown_type)
 {
 	int ret;
 
 	ctrl->ctrl_config &= ~NVME_CC_SHN_MASK;
-	if (shutdown)
+	if (shutdown_type == NVME_DISABLE_SHUTDOWN_SYNC)
 		ctrl->ctrl_config |= NVME_CC_SHN_NORMAL;
 	else
 		ctrl->ctrl_config &= ~NVME_CC_ENABLE;
@@ -2225,7 +2225,7 @@ int nvme_disable_ctrl(struct nvme_ctrl *ctrl, bool shutdown)
 	if (ret)
 		return ret;
 
-	if (shutdown) {
+	if (shutdown_type == NVME_DISABLE_SHUTDOWN_SYNC) {
 		return nvme_wait_ready(ctrl, NVME_CSTS_SHST_MASK,
 				       NVME_CSTS_SHST_CMPLT,
 				       ctrl->shutdown_timeout, "shutdown");
drivers/nvme/host/nvme.h +6 -1
index 3dbd187896d8..d880f1ee08d4 100644
@@ -187,6 +187,11 @@ enum {
 	NVME_MPATH_IO_STATS		= (1 << 2),
 };
 
+enum shutdown_type {
+	NVME_DISABLE_RESET = 0,
+	NVME_DISABLE_SHUTDOWN_SYNC = 1
+};
+
 static inline struct nvme_request *nvme_req(struct request *req)
 {
 	return blk_mq_rq_to_pdu(req);
@@ -750,7 +755,7 @@ void nvme_cancel_tagset(struct nvme_ctrl *ctrl);
 void nvme_cancel_admin_tagset(struct nvme_ctrl *ctrl);
 bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl,
 		enum nvme_ctrl_state new_state);
-int nvme_disable_ctrl(struct nvme_ctrl *ctrl, bool shutdown);
+int nvme_disable_ctrl(struct nvme_ctrl *ctrl, enum shutdown_type shutdown_type);
 int nvme_enable_ctrl(struct nvme_ctrl *ctrl);
 int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,
 		const struct nvme_ctrl_ops *ops, unsigned long quirks);
drivers/nvme/host/pci.c +22 -22

168 lines not on this page · raw message

drivers/nvme/host/rdma.c +2 -1
index bc90ec3c51b0..b969ab23a55b 100644
@@ -2136,7 +2136,8 @@ static void nvme_rdma_shutdown_ctrl(struct nvme_rdma_ctrl *ctrl, bool shutdown)
 {
 	nvme_rdma_teardown_io_queues(ctrl, shutdown);
 	nvme_quiesce_admin_queue(&ctrl->ctrl);
-	nvme_disable_ctrl(&ctrl->ctrl, shutdown);
+	nvme_disable_ctrl(&ctrl->ctrl, shutdown ?
+		NVME_DISABLE_SHUTDOWN_SYNC : NVME_DISABLE_RESET);
 	nvme_rdma_teardown_admin_queue(ctrl, shutdown);
 }
 
drivers/nvme/host/tcp.c +2 -1
index d79811cfa0ce..e3f4541abccd 100644
@@ -2292,7 +2292,8 @@ static void nvme_tcp_teardown_ctrl(struct nvme_ctrl *ctrl, bool shutdown)
 {
 	nvme_tcp_teardown_io_queues(ctrl, shutdown);
 	nvme_quiesce_admin_queue(ctrl);
-	nvme_disable_ctrl(ctrl, shutdown);
+	nvme_disable_ctrl(ctrl, shutdown ?
+		NVME_DISABLE_SHUTDOWN_SYNC : NVME_DISABLE_RESET);
 	nvme_tcp_teardown_admin_queue(ctrl, shutdown);
 }
 
drivers/nvme/target/loop.c +1 -1
index 9cb434c58075..6cb6e7c6bdd1 100644
@@ -401,7 +401,7 @@ static void nvme_loop_shutdown_ctrl(struct nvme_loop_ctrl *ctrl)
 
 	nvme_quiesce_admin_queue(&ctrl->ctrl);
 	if (ctrl->ctrl.state == NVME_CTRL_LIVE)
-		nvme_disable_ctrl(&ctrl->ctrl, true);
+		nvme_disable_ctrl(&ctrl->ctrl, NVME_DISABLE_SHUTDOWN_SYNC);
 
 	nvme_cancel_admin_tagset(&ctrl->ctrl);
 	nvme_loop_destroy_admin_queue(ctrl);
Signature · 1 line
2.39.3
#13 lore raw

Re: [PATCH 3/4] Change 'bool shutdown' into an enum shutdown_type { NVME_DISABLE_RESET = 0, NVME_DISABLE_SHUTDOWN_SYNC = 1 }.

The subject might be overly detailed and doesn't match the "nvme: ..." prefix convention of drivers/nvme/. Maybe it was intended as part of the commit log?

Quoted 23 lines · Jeremy Allison

Convert nvme_disable_ctrl() and nvme_dev_disable() inside drivers/nvme/host/pci.c to use this

bool shutdown = false == NVME_DISABLE_RESET bool shutdown = true == NVME_DISABLE_SHUTDOWN_SYNC.

This will make it easier to add a third request: NVME_DISABLE_SHUTDOWN_ASNYC later.

As nvme_disable_ctrl() is used outside of drivers/nvme/host/pci.c, convert the callers of nvme_disable_ctrl() to this convention too.

---
 drivers/nvme/host/apple.c  |  4 ++--
 drivers/nvme/host/core.c   |  6 +++---
 drivers/nvme/host/nvme.h   |  7 +++++-
 drivers/nvme/host/pci.c    | 44 +++++++++++++++++++-------------------
 drivers/nvme/host/rdma.c   |  3 ++-
 drivers/nvme/host/tcp.c    |  3 ++-
 drivers/nvme/target/loop.c |  2 +-
 7 files changed, 38 insertions(+), 31 deletions(-)

...

#14 lore raw

Re: [PATCH 3/4] Change 'bool shutdown' into an enum shutdown_type { NVME_DISABLE_RESET = 0, NVME_DISABLE_SHUTDOWN_SYNC = 1 }.

Quoted 3 lines · Bjorn Helgaas

The subject might be overly detailed and doesn't match the "nvme: ..." prefix convention of drivers/nvme/. Maybe it was intended as part of the commit log?

I'll fix that, thanks !

#15 lore raw

PATCH 4/4 nvme: Add two-pass shutdown support

In reply to Jeremy Allison

This works with the two-pass shutdown mechanism setup for the PCI drivers and participates to provide the shutdown_wait method at the pci_driver structure level.

Adds the new NVME_DISABLE_SHUTDOWN_ASYNC to enum shutdown_type. Changes the nvme shutdown() method to set the NVME_CC_SHN_NORMAL bit and then return to the caller when requested by NVME_DISABLE_SHUTDOWN_ASYNC.

nvme_shutdown_wait() is added to call an internal nvme_wait_for_shutdown_cmpl() function to synchronously wait for the device to wait for the NVME_CSTS_SHST_CMPLT bit.

This change speeds up the shutdown in a system which hosts many controllers.

---
 drivers/nvme/host/core.c | 29 +++++++++++++++++++++++++++--
 drivers/nvme/host/nvme.h |  4 +++-
 drivers/nvme/host/pci.c  | 24 ++++++++++++++++++++++--
 3 files changed, 52 insertions(+), 5 deletions(-)
drivers/nvme/host/core.c +27 -2
index bc7040da8e74..2ebcd40106b7 100644
@@ -2216,7 +2216,7 @@ int nvme_disable_ctrl(struct nvme_ctrl *ctrl, enum shutdown_type shutdown_type)
 	int ret;
 
 	ctrl->ctrl_config &= ~NVME_CC_SHN_MASK;
-	if (shutdown_type == NVME_DISABLE_SHUTDOWN_SYNC)
+	if (shutdown_type != NVME_DISABLE_RESET)
 		ctrl->ctrl_config |= NVME_CC_SHN_NORMAL;
 	else
 		ctrl->ctrl_config &= ~NVME_CC_ENABLE;
@@ -2225,10 +2225,24 @@ int nvme_disable_ctrl(struct nvme_ctrl *ctrl, enum shutdown_type shutdown_type)
 	if (ret)
 		return ret;
 
-	if (shutdown_type == NVME_DISABLE_SHUTDOWN_SYNC) {
+	switch (shutdown_type) {
+	case NVME_DISABLE_SHUTDOWN_ASYNC:
+		/*
+		 * nvme_wait_for_shutdown_cmpl() will read the reply for this.
+		*/
+		return ret;
+	case NVME_DISABLE_SHUTDOWN_SYNC:
+		/*
+		 * Spin on the read of the control register.
+		 */
 		return nvme_wait_ready(ctrl, NVME_CSTS_SHST_MASK,
 				       NVME_CSTS_SHST_CMPLT,
 				       ctrl->shutdown_timeout, "shutdown");
+	case NVME_DISABLE_RESET:
+		/*
+		 * Doing a reset here. Handle below.
+		 */
+		break;
 	}
 	if (ctrl->quirks & NVME_QUIRK_DELAY_BEFORE_CHK_RDY)
 		msleep(NVME_QUIRK_DELAY_AMOUNT);
@@ -2237,6 +2251,17 @@ int nvme_disable_ctrl(struct nvme_ctrl *ctrl, enum shutdown_type shutdown_type)
 }
 EXPORT_SYMBOL_GPL(nvme_disable_ctrl);
 
+int nvme_wait_for_shutdown_cmpl(struct nvme_ctrl *ctrl)
+{
+	ctrl->ctrl_config &= ~NVME_CC_SHN_MASK;
+	ctrl->ctrl_config |= NVME_CC_SHN_NORMAL;
+
+	return nvme_wait_ready(ctrl, NVME_CSTS_SHST_MASK,
+			       NVME_CSTS_SHST_CMPLT,
+			       ctrl->shutdown_timeout, "shutdown");
+}
+EXPORT_SYMBOL_GPL(nvme_wait_for_shutdown_cmpl);
+
 int nvme_enable_ctrl(struct nvme_ctrl *ctrl)
 {
 	unsigned dev_page_min;
drivers/nvme/host/nvme.h +3 -1
index d880f1ee08d4..adbff23532de 100644
@@ -189,7 +189,8 @@ enum {
 
 enum shutdown_type {
 	NVME_DISABLE_RESET = 0,
-	NVME_DISABLE_SHUTDOWN_SYNC = 1
+	NVME_DISABLE_SHUTDOWN_SYNC = 1,
+	NVME_DISABLE_SHUTDOWN_ASYNC = 2
 };
 
 static inline struct nvme_request *nvme_req(struct request *req)
@@ -756,6 +757,7 @@ void nvme_cancel_admin_tagset(struct nvme_ctrl *ctrl);
 bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl,
 		enum nvme_ctrl_state new_state);
 int nvme_disable_ctrl(struct nvme_ctrl *ctrl, enum shutdown_type shutdown_type);
+int nvme_wait_for_shutdown_cmpl(struct nvme_ctrl *ctrl);
 int nvme_enable_ctrl(struct nvme_ctrl *ctrl);
 int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,
 		const struct nvme_ctrl_ops *ops, unsigned long quirks);
drivers/nvme/host/pci.c +22 -2
index 77b015affb0b..9cb4436710dd 100644
@@ -2586,7 +2586,7 @@ static void nvme_dev_disable(struct nvme_dev *dev, enum shutdown_type shutdown_t
 		 * Give the controller a chance to complete all entered requests
 		 * if doing a safe shutdown.
 		 */
-		if (!dead && (shutdown_type == NVME_DISABLE_SHUTDOWN_SYNC))
+		if (!dead && (shutdown_type != NVME_DISABLE_RESET))
 			nvme_wait_freeze_timeout(&dev->ctrl, NVME_IO_TIMEOUT);
 	}
 
@@ -3100,7 +3100,26 @@ static void nvme_shutdown(struct pci_dev *pdev)
 {
 	struct nvme_dev *dev = pci_get_drvdata(pdev);
 
-	nvme_disable_prepare_reset(dev, NVME_DISABLE_SHUTDOWN_SYNC);
+	nvme_disable_prepare_reset(dev, NVME_DISABLE_SHUTDOWN_ASYNC);
+}
+
+static void nvme_shutdown_wait(struct pci_dev *pdev)
+{
+	struct nvme_dev *dev = pci_get_drvdata(pdev);
+
+	mutex_lock(&dev->shutdown_lock);
+	nvme_wait_for_shutdown_cmpl(&dev->ctrl);
+
+	/*
+	 * The driver will not be starting up queues again if shutting down so
+	 * must flush all entered requests to their failed completion to avoid
+	 * deadlocking blk-mq hot-cpu notifier.
+	 */
+	nvme_unquiesce_io_queues(&dev->ctrl);
+	if (dev->ctrl.admin_q && !blk_queue_dying(dev->ctrl.admin_q))
+		nvme_unquiesce_admin_queue(&dev->ctrl);
+
+	mutex_unlock(&dev->shutdown_lock);
 }
 
 /*
@@ -3492,6 +3511,7 @@ static struct pci_driver nvme_driver = {
 	.probe		= nvme_probe,
 	.remove		= nvme_remove,
 	.shutdown	= nvme_shutdown,
+	.shutdown_wait  = nvme_shutdown_wait,
 	.driver		= {
 		.probe_type	= PROBE_PREFER_ASYNCHRONOUS,
 #ifdef CONFIG_PM_SLEEP
Signature · 1 line
2.39.3
maintainer
#16 lore raw

Re: [PATCH 4/4] nvme: Add two-pass shutdown support

Quoted 64 lines · Jeremy Allison

This works with the two-pass shutdown mechanism setup for the PCI drivers and participates to provide the shutdown_wait method at the pci_driver structure level.

Adds the new NVME_DISABLE_SHUTDOWN_ASYNC to enum shutdown_type. Changes the nvme shutdown() method to set the NVME_CC_SHN_NORMAL bit and then return to the caller when requested by NVME_DISABLE_SHUTDOWN_ASYNC.

nvme_shutdown_wait() is added to call an internal nvme_wait_for_shutdown_cmpl() function to synchronously wait for the device to wait for the NVME_CSTS_SHST_CMPLT bit.

This change speeds up the shutdown in a system which hosts many controllers.

---
  drivers/nvme/host/core.c | 29 +++++++++++++++++++++++++++--
  drivers/nvme/host/nvme.h |  4 +++-
  drivers/nvme/host/pci.c  | 24 ++++++++++++++++++++++--
  3 files changed, 52 insertions(+), 5 deletions(-)
drivers/nvme/host/core.c +16 -2
index bc7040da8e74..2ebcd40106b7 100644
@@ -2216,7 +2216,7 @@ int nvme_disable_ctrl(struct nvme_ctrl *ctrl, enum shutdown_type shutdown_type)
  	int ret;
 
  	ctrl->ctrl_config &= ~NVME_CC_SHN_MASK;
-	if (shutdown_type == NVME_DISABLE_SHUTDOWN_SYNC)
+	if (shutdown_type != NVME_DISABLE_RESET)
  		ctrl->ctrl_config |= NVME_CC_SHN_NORMAL;
  	else
  		ctrl->ctrl_config &= ~NVME_CC_ENABLE;
@@ -2225,10 +2225,24 @@ int nvme_disable_ctrl(struct nvme_ctrl *ctrl, enum shutdown_type shutdown_type)
  	if (ret)
  		return ret;
 
-	if (shutdown_type == NVME_DISABLE_SHUTDOWN_SYNC) {
+	switch (shutdown_type) {
+	case NVME_DISABLE_SHUTDOWN_ASYNC:
+		/*
+		 * nvme_wait_for_shutdown_cmpl() will read the reply for this.
+		*/
+		return ret;
+	case NVME_DISABLE_SHUTDOWN_SYNC:
+		/*
+		 * Spin on the read of the control register.
+		 */
  		return nvme_wait_ready(ctrl, NVME_CSTS_SHST_MASK,
  				       NVME_CSTS_SHST_CMPLT,
  				       ctrl->shutdown_timeout, "shutdown");
+	case NVME_DISABLE_RESET:
+		/*
+		 * Doing a reset here. Handle below.
+		 */
+		break;
  	}
  	if (ctrl->quirks & NVME_QUIRK_DELAY_BEFORE_CHK_RDY)
  		msleep(NVME_QUIRK_DELAY_AMOUNT);

drivers/nvme/host/core.c int nvme_disable_ctrl(struct nvme_ctrl *ctrl, enum shutdown_type shutdown_type) · line 2257

Quoted 7 lines
drivers/nvme/host/core.c +4 -0
@@ -2237,6 +2251,17 @@ int nvme_disable_ctrl(struct nvme_ctrl *ctrl, enum shutdown_type shutdown_type)
  }
  EXPORT_SYMBOL_GPL(nvme_disable_ctrl);
 
+int nvme_wait_for_shutdown_cmpl(struct nvme_ctrl *ctrl)
+{
+	ctrl->ctrl_config &= ~NVME_CC_SHN_MASK;
+	ctrl->ctrl_config |= NVME_CC_SHN_NORMAL;

Why is ctrl_config being set again?

drivers/nvme/host/core.c int nvme_disable_ctrl(struct nvme_ctrl *ctrl, enum shutdown_type shutdown_type) · line 2263

Quoted 6 lines
drivers/nvme/host/core.c +6 -0
+
+	return nvme_wait_ready(ctrl, NVME_CSTS_SHST_MASK,
+			       NVME_CSTS_SHST_CMPLT,
+			       ctrl->shutdown_timeout, "shutdown");
+}
+EXPORT_SYMBOL_GPL(nvme_wait_for_shutdown_cmpl);

Why export the symbol?

Quoted 43 lines
drivers/nvme/host/core.c +1 -0
+
  int nvme_enable_ctrl(struct nvme_ctrl *ctrl)
  {
  	unsigned dev_page_min;
drivers/nvme/host/nvme.h +3 -1
index d880f1ee08d4..adbff23532de 100644
@@ -189,7 +189,8 @@ enum {
 
  enum shutdown_type {
  	NVME_DISABLE_RESET = 0,
-	NVME_DISABLE_SHUTDOWN_SYNC = 1
+	NVME_DISABLE_SHUTDOWN_SYNC = 1,
+	NVME_DISABLE_SHUTDOWN_ASYNC = 2
  };
 
  static inline struct nvme_request *nvme_req(struct request *req)
@@ -756,6 +757,7 @@ void nvme_cancel_admin_tagset(struct nvme_ctrl *ctrl);
  bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl,
  		enum nvme_ctrl_state new_state);
  int nvme_disable_ctrl(struct nvme_ctrl *ctrl, enum shutdown_type shutdown_type);
+int nvme_wait_for_shutdown_cmpl(struct nvme_ctrl *ctrl);
  int nvme_enable_ctrl(struct nvme_ctrl *ctrl);
  int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,
  		const struct nvme_ctrl_ops *ops, unsigned long quirks);
drivers/nvme/host/pci.c +1 -1
index 77b015affb0b..9cb4436710dd 100644
@@ -2586,7 +2586,7 @@ static void nvme_dev_disable(struct nvme_dev *dev, enum shutdown_type shutdown_t
  		 * Give the controller a chance to complete all entered requests
  		 * if doing a safe shutdown.
  		 */
-		if (!dead && (shutdown_type == NVME_DISABLE_SHUTDOWN_SYNC))
+		if (!dead && (shutdown_type != NVME_DISABLE_RESET))
  			nvme_wait_freeze_timeout(&dev->ctrl, NVME_IO_TIMEOUT);
  	}
 
@@ -3100,7 +3100,26 @@ static void nvme_shutdown(struct pci_dev *pdev)
  {
  	struct nvme_dev *dev = pci_get_drvdata(pdev);
 

drivers/nvme/host/pci.c static void nvme_shutdown(struct pci_dev *pdev) · line 3111

Quoted 10 lines
drivers/nvme/host/pci.c +9 -1
-	nvme_disable_prepare_reset(dev, NVME_DISABLE_SHUTDOWN_SYNC);
+	nvme_disable_prepare_reset(dev, NVME_DISABLE_SHUTDOWN_ASYNC);
+}
+
+static void nvme_shutdown_wait(struct pci_dev *pdev)
+{
+	struct nvme_dev *dev = pci_get_drvdata(pdev);
+
+	mutex_lock(&dev->shutdown_lock);
+	nvme_wait_for_shutdown_cmpl(&dev->ctrl);

If this is the only call-site? why not just open-code it here?

Quoted 22 lines
drivers/nvme/host/pci.c +12 -0
+
+	/*
+	 * The driver will not be starting up queues again if shutting down so
+	 * must flush all entered requests to their failed completion to avoid
+	 * deadlocking blk-mq hot-cpu notifier.
+	 */
+	nvme_unquiesce_io_queues(&dev->ctrl);
+	if (dev->ctrl.admin_q && !blk_queue_dying(dev->ctrl.admin_q))
+		nvme_unquiesce_admin_queue(&dev->ctrl);
+
+	mutex_unlock(&dev->shutdown_lock);
  }
 
  /*
@@ -3492,6 +3511,7 @@ static struct pci_driver nvme_driver = {
  	.probe		= nvme_probe,
  	.remove		= nvme_remove,
  	.shutdown	= nvme_shutdown,
+	.shutdown_wait  = nvme_shutdown_wait,
  	.driver		= {
  		.probe_type	= PROBE_PREFER_ASYNCHRONOUS,
  #ifdef CONFIG_PM_SLEEP
#17 lore raw

Re: [PATCH 4/4] nvme: Add two-pass shutdown support

Quoted 8 lines · Sagi Grimberg

drivers/nvme/host/core.c int nvme_disable_ctrl(struct nvme_ctrl *ctrl, enum shutdown_type shutdown_type) · line 2257

Quoted 5 lines · Jeremy Allison

EXPORT_SYMBOL_GPL(nvme_disable_ctrl);

drivers/nvme/host/core.c +4 -0
+int nvme_wait_for_shutdown_cmpl(struct nvme_ctrl *ctrl)
+{
+	ctrl->ctrl_config &= ~NVME_CC_SHN_MASK;
+	ctrl->ctrl_config |= NVME_CC_SHN_NORMAL;

Why is ctrl_config being set again?

Good catch. There's no need for that. I'll fix
in the next iteration, thanks !

Quoted 3 lines
Quoted 1 line

+EXPORT_SYMBOL_GPL(nvme_wait_for_shutdown_cmpl);

Why export the symbol?

nvme_wait_for_shutdown_cmpl() calls nvme_wait_ready(), which is a static function defined in drivers/nvme/host/core.c.

The only way to inline the functionality of nvme_wait_for_shutdown_cmpl() into nvme_shutdown_wait() is to export nvme_wait_ready() instead.

If you're OK with that I can remove the intermediate function nvme_wait_for_shutdown_cmpl() (and indeed as you've pointed out there's no need to set ctrl->ctrl_config again).

Quoted 8 lines

drivers/nvme/host/pci.c static void nvme_shutdown(struct pci_dev *pdev) · line 3111

Quoted 6 lines
drivers/nvme/host/pci.c +6 -0
+static void nvme_shutdown_wait(struct pci_dev *pdev)
+{
+	struct nvme_dev *dev = pci_get_drvdata(pdev);
+
+	mutex_lock(&dev->shutdown_lock);
+	nvme_wait_for_shutdown_cmpl(&dev->ctrl);

If this is the only call-site? why not just open-code it here?

See above comment.

Thanks for the advice. I'll fix these up in the next iteration (which probably won't be until after January 2nd due to the Christmas break).

maintainer
#18 lore raw

Re: [PATCH 4/4] nvme: Add two-pass shutdown support

Quoted 20 lines · Jeremy Allison
Quoted 8 lines · Sagi Grimberg

drivers/nvme/host/core.c int nvme_disable_ctrl(struct nvme_ctrl *ctrl, enum shutdown_type shutdown_type) · line 2257

Quoted 5 lines · Jeremy Allison

 EXPORT_SYMBOL_GPL(nvme_disable_ctrl);

drivers/nvme/host/core.c +4 -0
+int nvme_wait_for_shutdown_cmpl(struct nvme_ctrl *ctrl)
+{
+    ctrl->ctrl_config &= ~NVME_CC_SHN_MASK;
+    ctrl->ctrl_config |= NVME_CC_SHN_NORMAL;

Why is ctrl_config being set again?

Good catch. There's no need for that. I'll fix
in the next iteration, thanks !

Quoted 3 lines
Quoted 1 line

+EXPORT_SYMBOL_GPL(nvme_wait_for_shutdown_cmpl);

Why export the symbol?

nvme_wait_for_shutdown_cmpl() calls nvme_wait_ready(), which is a static function defined in drivers/nvme/host/core.c.

Quoted 7 lines

The only way to inline the functionality of nvme_wait_for_shutdown_cmpl() into nvme_shutdown_wait() is to export nvme_wait_ready() instead.

If you're OK with that I can remove the intermediate function nvme_wait_for_shutdown_cmpl() (and indeed as you've pointed out there's no need to set ctrl->ctrl_config again).

I think it is small enough to make it static inline in nvme.h

#19 lore raw

Re: [PATCH 4/4] nvme: Add two-pass shutdown support

Quoted 26 lines · Sagi Grimberg
Quoted 23 lines · Jeremy Allison
Quoted 8 lines · Sagi Grimberg

drivers/nvme/host/core.c int nvme_disable_ctrl(struct nvme_ctrl *ctrl, enum shutdown_type shutdown_type) · line 2257

Quoted 5 lines · Jeremy Allison

 EXPORT_SYMBOL_GPL(nvme_disable_ctrl);

drivers/nvme/host/core.c +4 -0
+int nvme_wait_for_shutdown_cmpl(struct nvme_ctrl *ctrl)
+{
+    ctrl->ctrl_config &= ~NVME_CC_SHN_MASK;
+    ctrl->ctrl_config |= NVME_CC_SHN_NORMAL;

Why is ctrl_config being set again?

Good catch. There's no need for that. I'll fix
in the next iteration, thanks !

Quoted 3 lines
Quoted 1 line

+EXPORT_SYMBOL_GPL(nvme_wait_for_shutdown_cmpl);

Why export the symbol?

nvme_wait_for_shutdown_cmpl() calls nvme_wait_ready(), which is a static function defined in drivers/nvme/host/core.c.

The only way to inline the functionality of nvme_wait_for_shutdown_cmpl() into nvme_shutdown_wait() is to export nvme_wait_ready() instead.

Quoted 6 lines
Quoted 4 lines

If you're OK with that I can remove the intermediate function nvme_wait_for_shutdown_cmpl() (and indeed as you've pointed out there's no need to set ctrl->ctrl_config again).

I think it is small enough to make it static inline in nvme.h

Sorry, just looking for some clarification here. Are you talking about inlining nvme_wait_ready() ? There are indeed larger functions already inlined in nvme.h.

maintainer
#20 lore raw

Re: [PATCH 4/4] nvme: Add two-pass shutdown support

Quoted 28 lines
Quoted 28 lines
Quoted 27 lines
Quoted 9 lines · Jeremy Allison

drivers/nvme/host/core.c int nvme_disable_ctrl(struct nvme_ctrl *ctrl, enum shutdown_type shutdown_type) · line 2257

Quoted 5 lines

 EXPORT_SYMBOL_GPL(nvme_disable_ctrl);

drivers/nvme/host/core.c +4 -0
+int nvme_wait_for_shutdown_cmpl(struct nvme_ctrl *ctrl)
+{
+    ctrl->ctrl_config &= ~NVME_CC_SHN_MASK;
+    ctrl->ctrl_config |= NVME_CC_SHN_NORMAL;

Why is ctrl_config being set again?

Good catch. There's no need for that. I'll fix
in the next iteration, thanks !

Quoted 3 lines
Quoted 1 line

+EXPORT_SYMBOL_GPL(nvme_wait_for_shutdown_cmpl);

Why export the symbol?

nvme_wait_for_shutdown_cmpl() calls nvme_wait_ready(), which is a static function defined in drivers/nvme/host/core.c.

The only way to inline the functionality of nvme_wait_for_shutdown_cmpl() into nvme_shutdown_wait() is to export nvme_wait_ready() instead.

If you're OK with that I can remove the intermediate function nvme_wait_for_shutdown_cmpl() (and indeed as you've pointed out there's no need to set ctrl->ctrl_config again).

Quoted 5 lines
Quoted 1 line

I think it is small enough to make it static inline in nvme.h

Sorry, just looking for some clarification here. Are you talking about inlining nvme_wait_ready() ? There are indeed larger functions already inlined in nvme.h.

No, these wrappers are getting confusing.

Exporting nvme_wait_ready and calling it from a static nvme_shutdown_wait in pci.c is fine I think.

#21 lore raw

Re: [PATCH 4/4] nvme: Add two-pass shutdown support

Quoted 5 lines · Sagi Grimberg

No, these wrappers are getting confusing.

Exporting nvme_wait_ready and calling it from a static nvme_shutdown_wait in pci.c is fine I think.

Got it. I'll re-submit v4 with these changes once
I've tested it. Thanks for the help and advice.