linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Keith Busch <kbusch@kernel.org>
Cc: Sagi Grimberg <sagi@grimberg.me>,
	Chaitanya Kulkarni <kch@nvidia.com>,
	Gerd Bayer <gbayer@linux.ibm.com>,
	asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
	linux-nvme@lists.infradead.org
Subject: [PATCH 12/12] nvme-pci: don't unbind the driver on reset failure
Date: Tue,  8 Nov 2022 16:02:52 +0100	[thread overview]
Message-ID: <20221108150252.2123727-13-hch@lst.de> (raw)
In-Reply-To: <20221108150252.2123727-1-hch@lst.de>

Unbind a device driver when a reset fails is very unusual behavior.
Just disable the controller and leave it in dead state if we fail to
reset it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/nvme/host/pci.c | 40 ++++++++++------------------------------
 1 file changed, 10 insertions(+), 30 deletions(-)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 1c8c70767cb8a..b1b659db682fa 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -130,7 +130,6 @@ struct nvme_dev {
 	u32 db_stride;
 	void __iomem *bar;
 	unsigned long bar_mapped_size;
-	struct work_struct remove_work;
 	struct mutex shutdown_lock;
 	bool subsystem;
 	u64 cmb_size;
@@ -2781,20 +2780,6 @@ static void nvme_pci_free_ctrl(struct nvme_ctrl *ctrl)
 	kfree(dev);
 }
 
-static void nvme_remove_dead_ctrl(struct nvme_dev *dev)
-{
-	/*
-	 * Set state to deleting now to avoid blocking nvme_wait_reset(), which
-	 * may be holding this pci_dev's device lock.
-	 */
-	nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_DELETING);
-	nvme_get_ctrl(&dev->ctrl);
-	nvme_dev_disable(dev, false);
-	nvme_mark_namespaces_dead(&dev->ctrl);
-	if (!queue_work(nvme_wq, &dev->remove_work))
-		nvme_put_ctrl(&dev->ctrl);
-}
-
 static void nvme_reset_work(struct work_struct *work)
 {
 	struct nvme_dev *dev =
@@ -2894,20 +2879,16 @@ static void nvme_reset_work(struct work_struct *work)
  out_unlock:
 	mutex_unlock(&dev->shutdown_lock);
  out:
-	if (result)
-		dev_warn(dev->ctrl.device,
-			 "Removing after probe failure status: %d\n", result);
-	nvme_remove_dead_ctrl(dev);
-}
-
-static void nvme_remove_dead_ctrl_work(struct work_struct *work)
-{
-	struct nvme_dev *dev = container_of(work, struct nvme_dev, remove_work);
-	struct pci_dev *pdev = to_pci_dev(dev->dev);
-
-	if (pci_get_drvdata(pdev))
-		device_release_driver(&pdev->dev);
-	nvme_put_ctrl(&dev->ctrl);
+	/*
+	 * Set state to deleting now to avoid blocking nvme_wait_reset(), which
+	 * may be holding this pci_dev's device lock.
+	 */
+	dev_warn(dev->ctrl.device, "Disabling device after reset failure: %d\n",
+		 result);
+	nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_DELETING);
+	nvme_dev_disable(dev, false);
+	nvme_mark_namespaces_dead(&dev->ctrl);
+	nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_DEAD);
 }
 
 static int nvme_pci_reg_read32(struct nvme_ctrl *ctrl, u32 off, u32 *val)
@@ -3045,7 +3026,6 @@ static struct nvme_dev *nvme_pci_alloc_ctrl(struct pci_dev *pdev,
 	if (!dev)
 		return NULL;
 	INIT_WORK(&dev->ctrl.reset_work, nvme_reset_work);
-	INIT_WORK(&dev->remove_work, nvme_remove_dead_ctrl_work);
 	mutex_init(&dev->shutdown_lock);
 
 	dev->nr_write_queues = write_queues;
-- 
2.30.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2022-11-08 15:09 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-08 15:02 RFC: nvme-pci: split the probe and reset handlers Christoph Hellwig
2022-11-08 15:02 ` [PATCH 01/12] nvme-pci: don't call nvme_init_ctrl_finish from nvme_passthru_end Christoph Hellwig
2022-11-09  2:55   ` Sagi Grimberg
2022-11-09  6:26     ` Christoph Hellwig
2022-11-08 15:02 ` [PATCH 02/12] nvme: move OPAL setup from PCIe to core Christoph Hellwig
2022-11-09  2:55   ` Sagi Grimberg
2022-11-09 20:44   ` Keith Busch
2022-11-09 23:22     ` Chaitanya Kulkarni
2022-11-13 16:15       ` Christoph Hellwig
2022-11-08 15:02 ` [PATCH 03/12] nvme: simplify transport specific device attribute handling Christoph Hellwig
2022-11-09  2:57   ` Sagi Grimberg
2022-11-08 15:02 ` [PATCH 04/12] nvme-pci: put the admin queue in nvme_dev_remove_admin Christoph Hellwig
2022-11-09  2:58   ` Sagi Grimberg
2022-11-09  6:28     ` Christoph Hellwig
2022-11-08 15:02 ` [PATCH 05/12] nvme-pci: move more teardown work to nvme_remove Christoph Hellwig
2022-11-09  3:00   ` Sagi Grimberg
2022-11-08 15:02 ` [PATCH 06/12] nvme-pci: factor the iod mempool creation into a helper Christoph Hellwig
2022-11-09  3:00   ` Sagi Grimberg
2022-11-08 15:02 ` [PATCH 07/12] nvme-pci: factor out a nvme_pci_alloc_ctrl helper Christoph Hellwig
2022-11-09  3:03   ` Sagi Grimberg
2022-11-09  6:28     ` Christoph Hellwig
2022-11-08 15:02 ` [PATCH 08/12] nvme-pci: set constant paramters in nvme_pci_alloc_ctrl Christoph Hellwig
2022-11-09  3:03   ` Sagi Grimberg
2022-11-08 15:02 ` [PATCH 09/12] nvme-pci: call nvme_pci_configure_admin_queue from nvme_pci_enable Christoph Hellwig
2022-11-09  3:04   ` Sagi Grimberg
2022-11-08 15:02 ` [PATCH 10/12] nvme-pci: split nvme_dbbuf_dma_alloc Christoph Hellwig
2022-11-09  3:05   ` Sagi Grimberg
2022-11-08 15:02 ` [PATCH 11/12] nvme-pci: split the initial probe from the rest path Christoph Hellwig
2022-11-09  3:14   ` Sagi Grimberg
2022-11-09  6:31     ` Christoph Hellwig
2022-11-09 17:00       ` Keith Busch
2022-11-09 15:18   ` Gerd Bayer
2022-11-09 15:51   ` Keith Busch
2022-11-09 15:56   ` Keith Busch
2022-11-10  3:17   ` Chao Leng
2022-11-13 16:19     ` Christoph Hellwig
2022-11-08 15:02 ` Christoph Hellwig [this message]
2022-11-09  3:15   ` [PATCH 12/12] nvme-pci: don't unbind the driver on reset failure Sagi Grimberg
2022-11-09 17:10   ` Keith Busch
2022-11-09 17:12 ` RFC: nvme-pci: split the probe and reset handlers Keith Busch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221108150252.2123727-13-hch@lst.de \
    --to=hch@lst.de \
    --cc=asahi@lists.linux.dev \
    --cc=gbayer@linux.ibm.com \
    --cc=kbusch@kernel.org \
    --cc=kch@nvidia.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).