On Tue, Oct 25, 2022 at 07:40:13AM -0700, Christoph Hellwig wrote: > When we have a non-present controller there is no reason to wait in > marking the namespaces dead, so do it ASAP. Also remove the superflous > call to nvme_start_queues as nvme_dev_disable already did that for us. > > Signed-off-by: Christoph Hellwig <hch@xxxxxx> > --- > drivers/nvme/host/pci.c | 18 ++++++------------ > 1 file changed, 6 insertions(+), 12 deletions(-) > > diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c > index 8ab54857cfd50..bef98f6e1396c 100644 > --- a/drivers/nvme/host/pci.c > +++ b/drivers/nvme/host/pci.c > @@ -3244,25 +3244,19 @@ static void nvme_remove(struct pci_dev *pdev) > nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_DELETING); > pci_set_drvdata(pdev, NULL); > > + /* > + * Mark the namespaces dead as we can't flush the data, and disable the > + * controller ASAP as we can't shut it down properly if it was surprise > + * removed. > + */ > if (!pci_device_is_present(pdev)) { > nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_DEAD); > + nvme_mark_namespaces_dead(&dev->ctrl); > nvme_dev_disable(dev, true); > } Ah, this changes what I mentioned about 4. Flushing the scan_work prior to nvme_mark_namespaces_dead() still looks the right thing to do, but I think you have to do both after nvme_dev_disable().