linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: hch@lst.de (Christoph Hellwig)
Subject: [PATCH 7/7] nvme: remove failed controllers directly from probe/reset context
Date: Fri,  2 Oct 2015 19:58:19 +0200	[thread overview]
Message-ID: <1443808699-4738-8-git-send-email-hch@lst.de> (raw)
In-Reply-To: <1443808699-4738-1-git-send-email-hch@lst.de>

Now that all probing and resets happen from workqueue context we can remove
the controller directly without any risk of deadlocking.

Signed-off-by: Christoph Hellwig <hch at lst.de>
---
 drivers/block/nvme-core.c | 37 +++++++++++--------------------------
 1 file changed, 11 insertions(+), 26 deletions(-)

diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c
index 48688d6..39c40bb 100644
--- a/drivers/block/nvme-core.c
+++ b/drivers/block/nvme-core.c
@@ -87,7 +87,6 @@ static struct class *nvme_class;
 static int __nvme_reset(struct nvme_dev *dev);
 static int nvme_reset(struct nvme_dev *dev);
 static int nvme_process_cq(struct nvme_queue *nvmeq);
-static void nvme_dead_ctrl(struct nvme_dev *dev);
 
 struct async_cmd_info {
 	struct kthread_work work;
@@ -2960,6 +2959,15 @@ static void nvme_set_irq_hints(struct nvme_dev *dev)
 	}
 }
 
+static void nvme_remove_dead_ctrl(struct nvme_dev *dev)
+{
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
+
+	dev_warn(dev->dev, "Device failed to start.\n");
+
+	if (pci_get_drvdata(pdev))
+		pci_stop_and_remove_bus_device_locked(pdev);
+}
 
 static void nvme_probe_work(struct work_struct *work)
 {
@@ -3033,30 +3041,7 @@ static void nvme_probe_work(struct work_struct *work)
 	nvme_dev_unmap(dev);
  out:
 	if (!work_busy(&dev->reset_work))
-		nvme_dead_ctrl(dev);
-}
-
-static int nvme_remove_dead_ctrl(void *arg)
-{
-	struct nvme_dev *dev = (struct nvme_dev *)arg;
-	struct pci_dev *pdev = to_pci_dev(dev->dev);
-
-	if (pci_get_drvdata(pdev))
-		pci_stop_and_remove_bus_device_locked(pdev);
-	kref_put(&dev->kref, nvme_free_dev);
-	return 0;
-}
-
-static void nvme_dead_ctrl(struct nvme_dev *dev)
-{
-	dev_warn(dev->dev, "Device failed to resume\n");
-	kref_get(&dev->kref);
-	if (IS_ERR(kthread_run(nvme_remove_dead_ctrl, dev, "nvme%d",
-						dev->instance))) {
-		dev_err(dev->dev,
-			"Failed to start controller remove task\n");
-		kref_put(&dev->kref, nvme_free_dev);
-	}
+		nvme_remove_dead_ctrl(dev);
 }
 
 static void nvme_reset_work(struct work_struct *ws)
@@ -3073,7 +3058,7 @@ static void nvme_reset_work(struct work_struct *ws)
 	/* Fail this device if reset occured during probe to avoid
 	 * infinite initialization loops. */
 	if (in_probe) {
-		nvme_dead_ctrl(dev);
+		nvme_remove_dead_ctrl(dev);
 		return;
 	}
 	/* Schedule device resume asynchronously so the reset work is available
-- 
1.9.1

  parent reply	other threads:[~2015-10-02 17:58 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-02 17:58 nvme reset and probe updates Christoph Hellwig
2015-10-02 17:58 ` [PATCH 1/7] nvme: delete dev from dev_list in nvme_reset Christoph Hellwig
2015-10-02 21:13   ` Keith Busch
2015-10-03 10:01     ` Christoph Hellwig
2015-10-02 17:58 ` [PATCH 2/7] nvme: merge nvme_dev_reset into nvme_reset_failed_dev Christoph Hellwig
2015-10-02 21:15   ` Keith Busch
2015-10-02 17:58 ` [PATCH 3/7] nvme: factor reset code into a common helper Christoph Hellwig
2015-10-02 21:19   ` Keith Busch
2015-10-02 17:58 ` [PATCH 4/7] nvme: merge nvme_dev_start, nvme_dev_resume and nvme_async_probe Christoph Hellwig
2015-10-02 21:27   ` Keith Busch
2015-10-03 10:02     ` Christoph Hellwig
2015-10-02 17:58 ` [PATCH 5/7] nvme: remove duplicate call to nvme_set_irq_hints Christoph Hellwig
2015-10-02 17:58 ` [PATCH 6/7] nvme: properly handle partially initialized queues in nvme_create_io_queues Christoph Hellwig
2015-10-02 21:36   ` Keith Busch
2015-10-03 10:03     ` Christoph Hellwig
2015-10-02 17:58 ` Christoph Hellwig [this message]
2015-10-02 21:54   ` [PATCH 7/7] nvme: remove failed controllers directly from probe/reset context Keith Busch
2015-10-03 10:03     ` Christoph Hellwig

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=1443808699-4738-8-git-send-email-hch@lst.de \
    --to=hch@lst.de \
    /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).