Received: by 10.223.176.5 with SMTP id f5csp396750wra; Thu, 1 Feb 2018 23:03:55 -0800 (PST) X-Google-Smtp-Source: AH8x2271Yhph9SSDMr3jXF5kahWVpSsLK3AZMdPm21HP+amKaITh1VwyF5F+tFWGQ1i+SUW9VtBf X-Received: by 2002:a17:902:2f03:: with SMTP id s3-v6mr33173648plb.112.1517555035728; Thu, 01 Feb 2018 23:03:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517555035; cv=none; d=google.com; s=arc-20160816; b=Lcp0poAUx7iMCqDbs4L3/UWsT7VMELzDc3/wuXaFHP2sVb12u+VjpR5/U1Uiikz8Cq 0wMXFIGVJ4zBqslHrm27RM+bxtA352Qm9ULEveaBS0NWrK+/N3l49jsX/IpLxQu04paq ljxXxcJjjQ/OzBd+YeXyskYBPc9qQKFDOpg9PH+HcND1a17CfHVciFz00ycehqipet0D a8NZdXxz1Lh+7JWHy0iNyDud2dnT+mXjBpwMmO/Q8fkHedMcpGzIK8az0S7+YVKRc2np T1rujZTf+dbUWZJsRXQn5aH45/kY/C+dICS3GIBBFFS17/UOVMCsJFO8wS85bpYCPjrO BVOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=7xwrhO4iBS4sgRuV+OIJi3IazgVsa8mx/hdYC27C9d8=; b=hHOihopRFDRjsO2LDRWlN8rqjJg+ce0RlWqp9bRB3eiIeZKuMZ5SX6X+kh8rn41GzE GbLBZmkRkMTDfhly+5oYTJamkTQ6y28NSpshBbW2K/kwPzDwbdrw9yl/jdR7c+muziiv h2gN3zfp2it29F4qot34bCZTwc3ikx7cMxOuhI9394SDUxKqfsit6EwYXEeROfFKpjYZ rk5QOnky23se1rawk18mcuHU5fonjmpuj52VCIr6+NUCPWhQ6VHmM3VJMXzT7bobreaY C9vhjEFbz+NSgIFb3Z6MRn109j7m/iC+iLAuQ1H4E13q8prH7ee4QS3ZYnW4i1C72qRt JZBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=Awhcgztx; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e68si1226612pfa.298.2018.02.01.23.03.41; Thu, 01 Feb 2018 23:03:55 -0800 (PST) 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=@oracle.com header.s=corp-2017-10-26 header.b=Awhcgztx; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751853AbeBBHBr (ORCPT + 99 others); Fri, 2 Feb 2018 02:01:47 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:47172 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751135AbeBBHBb (ORCPT ); Fri, 2 Feb 2018 02:01:31 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w126vrOc080563; Fri, 2 Feb 2018 07:01:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2017-10-26; bh=7xwrhO4iBS4sgRuV+OIJi3IazgVsa8mx/hdYC27C9d8=; b=AwhcgztxSSVy/kRHqoFvXs8+IzMibotmCsLb2u3VT5Y4xXKASMITQ2sIP0xya5uTk9kA Bg0+TQmaehe0LhOngE/cpTrJk/hWuTzUPTfxlsMeE13qjLPuzbb8vhflcEgouGxDnX6w 8FccryD9Mh1VrzSNZ9+nManv7VHCg986fHeA237W/C49RJzMTIRnEA6kwiKH+yfcXCoT S4ELWq3vfbHToy5bQAb9oiNkNr76gRaW0hm/wd0ceqHtLJ54MIyxBDy+1aOO3RrmSSS8 GwAUbTy5QHd1MfPAo5VUvjAe6BYoJE8oe4JI0GyR5D5h3EmhmaAid6KokyMGllTR23QN SQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2fvg7frf49-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 02 Feb 2018 07:01:07 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w12717t1004654 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 2 Feb 2018 07:01:07 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w12717HM001110; Fri, 2 Feb 2018 07:01:07 GMT Received: from will-ThinkCentre-M910s.cn.oracle.com (/10.182.70.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 01 Feb 2018 23:01:07 -0800 From: Jianchao Wang To: keith.busch@intel.com, axboe@fb.com, hch@lst.de, sagi@grimberg.me Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/6] nvme-pci: fix the freeze and quiesce for shutdown and reset case Date: Fri, 2 Feb 2018 15:00:45 +0800 Message-Id: <1517554849-7802-3-git-send-email-jianchao.w.wang@oracle.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517554849-7802-1-git-send-email-jianchao.w.wang@oracle.com> References: <1517554849-7802-1-git-send-email-jianchao.w.wang@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8792 signatures=668660 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1802020080 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, request queue will be frozen and quiesced for both reset and shutdown case. This will trigger ioq requests in RECONNECTING state which should be avoided to prepare for following patch. Just freeze request queue for shutdown case and drain all the resudual entered requests after controller has been shutdown. Signed-off-by: Jianchao Wang --- drivers/nvme/host/pci.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 00cffed..a7fa397 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -2172,21 +2172,23 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown) 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) - nvme_start_freeze(&dev->ctrl); dead = !!((csts & NVME_CSTS_CFS) || !(csts & NVME_CSTS_RDY) || pdev->error_state != pci_channel_io_normal); } - /* - * Give the controller a chance to complete all entered requests if - * doing a safe shutdown. - */ - if (!dead) { - if (shutdown) + /* Just freeze the queue for shutdown case */ + if (shutdown) { + if (dev->ctrl.state == NVME_CTRL_LIVE || + dev->ctrl.state == NVME_CTRL_RESETTING) + nvme_start_freeze(&dev->ctrl); + /* + * Give the controller a chance to complete all + * entered requests if doing a safe shutdown. + */ + if (!dead) nvme_wait_freeze_timeout(&dev->ctrl, NVME_IO_TIMEOUT); } + nvme_stop_queues(&dev->ctrl); if (!dead) { @@ -2210,12 +2212,15 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown) blk_mq_tagset_busy_iter(&dev->admin_tagset, nvme_cancel_request, &dev->ctrl); /* - * The driver will not be starting up queues again if shutting down so - * must flush all entered requests to their failed completion to avoid - * deadlocking blk-mq hot-cpu notifier. + * For shutdown case, controller will not be setup again soon. If any + * residual requests here, the controller must have go wrong. Drain and + * fail all the residual entered IO requests. */ - if (shutdown) + if (shutdown) { nvme_start_queues(&dev->ctrl); + nvme_wait_freeze(&dev->ctrl); + nvme_stop_queues(&dev->ctrl); + } mutex_unlock(&dev->shutdown_lock); } @@ -2349,12 +2354,11 @@ static void nvme_reset_work(struct work_struct *work) nvme_remove_namespaces(&dev->ctrl); new_state = NVME_CTRL_ADMIN_ONLY; } else { - nvme_start_queues(&dev->ctrl); - nvme_wait_freeze(&dev->ctrl); /* hit this only when allocate tagset fails */ if (nvme_dev_add(dev)) new_state = NVME_CTRL_ADMIN_ONLY; - nvme_unfreeze(&dev->ctrl); + if (was_suspend) + nvme_unfreeze(&dev->ctrl); } /* -- 2.7.4