linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: keith.busch@intel.com (Keith Busch)
Subject: [PATCHv2 2/8] nvme-pci: Fix queue freeze criteria on reset
Date: Tue, 22 May 2018 16:03:26 -0600	[thread overview]
Message-ID: <20180522220332.9244-3-keith.busch@intel.com> (raw)
In-Reply-To: <20180522220332.9244-1-keith.busch@intel.com>

The driver had been relying on the pci_dev to maintain the state of
the pci device to know when starting a freeze would be appropriate. The
blktests block/011 however shows us that users may alter the state of
pci_dev out from under drivers and break the criteria we had been using.

Signed-off-by: Keith Busch <keith.busch at intel.com>
---
 drivers/nvme/host/pci.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index deb44c27cdaf..8949ea3609d8 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -2196,24 +2196,22 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown)
 	struct pci_dev *pdev = to_pci_dev(dev->dev);
 
 	mutex_lock(&dev->shutdown_lock);
-	if (pci_is_enabled(pdev)) {
+	if (dev->ctrl.ctrl_config & NVME_CC_ENABLE &&
+	    (dev->ctrl.state == NVME_CTRL_LIVE ||
+	     dev->ctrl.state == NVME_CTRL_RESETTING)) {
 		u32 csts = readl(dev->bar + NVME_REG_CSTS);
 
-		if (dev->ctrl.state == NVME_CTRL_LIVE ||
-		    dev->ctrl.state == NVME_CTRL_RESETTING)
-			nvme_start_freeze(&dev->ctrl);
+		nvme_start_freeze(&dev->ctrl);
 		dead = !!((csts & NVME_CSTS_CFS) || !(csts & NVME_CSTS_RDY) ||
-			pdev->error_state  != pci_channel_io_normal);
+			pci_channel_offline(pdev) || !pci_is_enabled(pdev));
 	}
 
 	/*
 	 * Give the controller a chance to complete all entered requests if
 	 * doing a safe shutdown.
 	 */
-	if (!dead) {
-		if (shutdown)
-			nvme_wait_freeze_timeout(&dev->ctrl, NVME_IO_TIMEOUT);
-	}
+	if (!dead && shutdown)
+		nvme_wait_freeze_timeout(&dev->ctrl, NVME_IO_TIMEOUT);
 
 	nvme_stop_queues(&dev->ctrl);
 
-- 
2.14.3

  parent reply	other threads:[~2018-05-22 22:03 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-22 22:03 [PATCHv2 0/8] nvme timeout fixes v2 Keith Busch
2018-05-22 22:03 ` [PATCHv2 1/8] nvme: Sync request queues on reset Keith Busch
2018-05-22 22:03 ` Keith Busch [this message]
2018-05-22 22:03 ` [PATCHv2 3/8] nvme: Move all IO out of controller reset Keith Busch
2018-05-22 22:03 ` [PATCHv2 4/8] nvme: Allow reset from CONNECTING state Keith Busch
2018-05-22 22:03 ` [PATCHv2 5/8] nvme-pci: Attempt reset retry for IO failures Keith Busch
2018-05-22 22:03 ` [PATCHv2 6/8] nvme-pci: Rate limit the nvme timeout warnings Keith Busch
2018-05-22 22:03 ` [PATCHv2 7/8] nvme-pci: End IO requests in CONNECTING state Keith Busch
2018-05-22 22:03 ` [PATCHv2 8/8] nvme-pci: Unquiesce queues on dead controller Keith Busch
2018-05-23  3:00 ` [PATCHv2 0/8] nvme timeout fixes v2 Ming Lei
2018-05-23 16:16   ` Keith Busch
2018-05-23 22:49     ` Keith Busch
2018-05-24  6:52       ` jianchao.wang
2018-07-11 23:23       ` James Smart
2018-05-24  3:23     ` Ming Lei
2018-05-24 13:57       ` Keith Busch
2018-05-24 15:04         ` Ming Lei
2018-05-24 15:16           ` 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=20180522220332.9244-3-keith.busch@intel.com \
    --to=keith.busch@intel.com \
    /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).