Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3000376ybi; Mon, 17 Jun 2019 14:23:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqw6M1nLHSRv9UHBTwNo1ailmvP0fJHWPcxQTiYvtWkIY3AuhcRX4TP6y8oWtMgMwysjBP3m X-Received: by 2002:a17:90a:350c:: with SMTP id q12mr1178915pjb.46.1560806624730; Mon, 17 Jun 2019 14:23:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560806624; cv=none; d=google.com; s=arc-20160816; b=I3XmiaYy0jf4Q/2zHZPQyutSWCX0ZPYYV3XpL2qA8z9BAaJT7uQShxyS8LSm4l7GtP bq8I7cFF6o9zq5CDFsiTVh60Qm9fs4eGsQx+LhQCcDK2nIUJYNe7UhhZO7PZwpVsMhxl SkOZ9QQq8FJUFRE7NinPqPehOATc4GDG29k246X371oL4HuekVn9VQRir7+rPLE5ujFH hNzoPIYQfzaJPWEJSJUXmX6ws3KxREd0R2pQcvTruHqODxXJ4EDc5OfxVZk4eG4Bzp9m 9F29W3XldXngDNwy4vyUm3lPEj2alfURtZ9eWyXCZ25grHDtG4UoqY6nhox5la76DRu1 DfEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Fe4AJcHxMpwWuYuPaV1/D6nnRkQrRVpduMR1t791JCE=; b=l56xZgh/C7+3FKAS8X1wSJ2dgqVZtCRKwssmcGsrRRiGJsRuGw3wCjg1yhAPOUkek2 fYuqFFdrcps48Nd0KEv3pDfKxI4x/v9mreYu9a8eWYWNYUmk2AXAgZxWpIINvcP4u5I6 nqHBplKRaCP39L586KU6OpCExPysAFVe6enWyjqVm2bpPW1w6bmtS76QzXOXzQkGiFIU ZyxTaGoxHu+VOhRuifeCW1l9g6bGod5tpPaW8WIAvO1crDD/snlO2HYHs0+MtOQyWAbJ ER4/82My/2AbjI0OvAbEd/OrjNovQZEq1bLJOfaVB2RTsozE0DzI3wl5IuOBLvtRpjG8 jDjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=eS51hMqH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q2si10259735plh.59.2019.06.17.14.23.29; Mon, 17 Jun 2019 14:23:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=eS51hMqH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729327AbfFQVVS (ORCPT + 99 others); Mon, 17 Jun 2019 17:21:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:45804 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728811AbfFQVVR (ORCPT ); Mon, 17 Jun 2019 17:21:17 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0734B208E4; Mon, 17 Jun 2019 21:21:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560806476; bh=ELvTOrk45EK+TWqLdnXanaRtbY3YzIW95jg6O2WUp2g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eS51hMqH5UwkGZr8FHHnTBFrzeQnMV6H4eqMarcGrR4PxNyyeh4icuRrf8ljSxAt3 5v6IZfXdggetWzSAZs9fGzu/azKbHses6ZOB3n5s+5kgsDkD2AUcWx7B6GThcn/rEs MsXu+UHkaEDg+hOVbYRoLovcjPsEMQCOoJ7/PaYo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ming Lei , Christoph Hellwig , Keith Busch , Sasha Levin Subject: [PATCH 5.1 065/115] nvme-pci: Fix controller freeze wait disabling Date: Mon, 17 Jun 2019 23:09:25 +0200 Message-Id: <20190617210803.490251928@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190617210759.929316339@linuxfoundation.org> References: <20190617210759.929316339@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit e43269e6e5c49d7fec599e6bba71963935b0e4ba ] If a controller disabling didn't start a freeze, don't wait for the operation to complete. Reviewed-by: Ming Lei Reviewed-by: Christoph Hellwig Signed-off-by: Keith Busch Signed-off-by: Sasha Levin --- drivers/nvme/host/pci.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 372d3f4a106a..f20da2e3da2c 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -2400,7 +2400,7 @@ static void nvme_pci_disable(struct nvme_dev *dev) static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown) { - bool dead = true; + bool dead = true, freeze = false; struct pci_dev *pdev = to_pci_dev(dev->dev); mutex_lock(&dev->shutdown_lock); @@ -2408,8 +2408,10 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown) 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) { + freeze = true; nvme_start_freeze(&dev->ctrl); + } dead = !!((csts & NVME_CSTS_CFS) || !(csts & NVME_CSTS_RDY) || pdev->error_state != pci_channel_io_normal); } @@ -2418,10 +2420,8 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown) * 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 && freeze) + nvme_wait_freeze_timeout(&dev->ctrl, NVME_IO_TIMEOUT); nvme_stop_queues(&dev->ctrl); -- 2.20.1