From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Ming Lei To: Keith Busch Cc: Jens Axboe , linux-block@vger.kernel.org, Ming Lei , James Smart , Jianchao Wang , Christoph Hellwig , Sagi Grimberg , linux-nvme@lists.infradead.org, Laurence Oberman Subject: [PATCH V5 3/9] nvme: pci: only wait freezing if queue is frozen Date: Fri, 11 May 2018 20:29:27 +0800 Message-Id: <20180511122933.27155-4-ming.lei@redhat.com> In-Reply-To: <20180511122933.27155-1-ming.lei@redhat.com> References: <20180511122933.27155-1-ming.lei@redhat.com> List-ID: In nvme_dev_disable() called during shutting down controler, nvme_wait_freeze_timeout() may be done on the controller not frozen yet, so add the check for avoiding the case. Cc: James Smart Cc: Jianchao Wang Cc: Christoph Hellwig Cc: Sagi Grimberg Cc: linux-nvme@lists.infradead.org Cc: Laurence Oberman Signed-off-by: Ming Lei --- drivers/nvme/host/pci.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index ff09b1c760ea..57bd7bebd1e5 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -2244,14 +2244,17 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown) int i; bool dead = true; struct pci_dev *pdev = to_pci_dev(dev->dev); + bool frozen = false; mutex_lock(&dev->shutdown_lock); if (pci_is_enabled(pdev)) { u32 csts = readl(dev->bar + NVME_REG_CSTS); if (dev->ctrl.state == NVME_CTRL_LIVE || - dev->ctrl.state == NVME_CTRL_RESETTING) + dev->ctrl.state == NVME_CTRL_RESETTING) { nvme_start_freeze(&dev->ctrl); + frozen = true; + } dead = !!((csts & NVME_CSTS_CFS) || !(csts & NVME_CSTS_RDY) || pdev->error_state != pci_channel_io_normal); } @@ -2261,7 +2264,7 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown) * doing a safe shutdown. */ if (!dead) { - if (shutdown) + if (shutdown && frozen) nvme_wait_freeze_timeout(&dev->ctrl, NVME_IO_TIMEOUT); } -- 2.9.5