From patchwork Wed Jan 11 04:36:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hector Martin X-Patchwork-Id: 13096007 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B927FC46467 for ; Wed, 11 Jan 2023 04:39:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=F8RaAfZYWcMB4YOLic60rXylVXsKW3VEEOu/QcY7cTo=; b=yC+WBwzjj2YOKL xRwypH6ufhzLSHf1n0S1DXxeGLhzTIUOfIUP+PnAuCemgI0E5fkDVSqaN25xEXVcaH2xtb08iSIaR Uor40N/KmftUmqyEIzTbLI7sFezNciyoeeVskV55UpDi7eUZEJcvxKYGJKZ9QdEU/ZekAQLxljq04 qfz7nWJdzYoHFkqrqSpkTlfz6SzQTSOMngUIN/MD49lhRViLPKk4YAzTytvcQ9OAT8vqOoFHGFju7 kjZYt10NJ7GXuwI+Kp9/7vXtj6zBZJobZ/vmERfmG+wqye2brC78E9Omm4fPRbfVinrUimjHN62us wTrqMhSB5a0UoZSklV+g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFSsr-009Ya2-Dp; Wed, 11 Jan 2023 04:38:41 +0000 Received: from marcansoft.com ([212.63.210.85] helo=mail.marcansoft.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFSse-009YXl-Ja; Wed, 11 Jan 2023 04:38:29 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: sendonly@marcansoft.com) by mail.marcansoft.com (Postfix) with ESMTPSA id A9EC6422CC; Wed, 11 Jan 2023 04:38:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=marcan.st; s=default; t=1673411907; bh=Q3CUKLEywf+vR4+nGROpaJQqVS2PQmhEl5Il4+LejRo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=QY5tqf60SZHxFaNdFYSzNvp4IdFLjD4OU8BawnpwU74nj7igN5fSFDF1+fcojF39A sOVlpJT9RhW6yM4BHm02nodGm1dFnVtmoqCnFikp1F9d/8cT3SuUqKczh83l09wMoo Zz+ydkC/lTC43zhbi3SjksPhqde146WnH3Ge1L59zI7Cg8TeHT4GQTiqLfm70xYxh7 LVdvZPRhSF4FctliGqXRgKXSjYPgtSRKMkB+ouZ2NiQ/4azKsNZx88fxEu31eKkYae js5/uMv+MwTL1AyrKdtdx76z3wHbPDiWP65rW7ZcORH+fhFmpmvHqNkiBHju5CgmAS FS6P8dLLiUcuA== From: Hector Martin To: Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg Cc: Eric Curtin , Janne Grunau , Sven Peter , Alyssa Rosenzweig , asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Hector Martin Subject: [PATCH 1/2] nvme-apple: Do not try to shut down the controller twice Date: Wed, 11 Jan 2023 13:36:13 +0900 Message-Id: <20230111043614.27087-2-marcan@marcan.st> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230111043614.27087-1-marcan@marcan.st> References: <20230111043614.27087-1-marcan@marcan.st> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230110_203828_806436_7200914E X-CRM114-Status: GOOD ( 14.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The blamed commit stopped explicitly disabling the controller when we do a controlled shutdown, but apple_nvme_reset_work was only checking for the disable bit before deciding to issue another disable. Check for the shutdown state too, to avoid breakage. This issue does not affect nvme-pci, since it only issues controller shutdowns when the system is actually shutting down anyway. Fixes: c76b8308e4c9 ("nvme-apple: fix controller shutdown in apple_nvme_disable") Signed-off-by: Hector Martin --- drivers/nvme/host/apple.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/apple.c b/drivers/nvme/host/apple.c index e13a992b6096..1961376447dc 100644 --- a/drivers/nvme/host/apple.c +++ b/drivers/nvme/host/apple.c @@ -1023,7 +1023,8 @@ static void apple_nvme_reset_work(struct work_struct *work) goto out; } - if (anv->ctrl.ctrl_config & NVME_CC_ENABLE) + if (anv->ctrl.ctrl_config & NVME_CC_ENABLE && + !(anv->ctrl.ctrl_config & NVME_CC_SHN_MASK)) apple_nvme_disable(anv, false); /* RTKit must be shut down cleanly for the (soft)-reset to work */ From patchwork Wed Jan 11 04:36:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hector Martin X-Patchwork-Id: 13096008 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1BCA7C5479D for ; Wed, 11 Jan 2023 04:39:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Q+cP88kjs1/cNjQypLivlP6cxvU+63bagbwf7hErf9E=; b=ohaavYqQAk2a4H fsfqQLYECJxaooMdit4JLG+xrMjyQcY/nG6MOXJIXOszDTxu1mP6phQ+H5zfveo6O00cQmvePv3y7 syu0Z1NxGKqNaHoVcpta4HuKZcdGhuYNWDVTHPrBXF5Epz7iabyV0HvQkxddS85Y9v4EJyXtLd6N0 yD9SJDANTt4lz4JEAEyDFru3zjsH+eQ0sIVF9H5X/KBHV10cS1EvJKIcpNfHsvRRtxIUc/jihRe6P WSo0KwLA8TqrgrRwD4eBUTb0GikvgEcDHjy+hIkcum/00LuqhiS9mILlzlHnMDewxkezOX/4sHvPV 6K1Ie7shDB+wwxcb4e6g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFSt3-009YdM-Jo; Wed, 11 Jan 2023 04:38:53 +0000 Received: from marcansoft.com ([212.63.210.85] helo=mail.marcansoft.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFSsi-009YYX-NN; Wed, 11 Jan 2023 04:38:34 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: sendonly@marcansoft.com) by mail.marcansoft.com (Postfix) with ESMTPSA id 9EA3E4245E; Wed, 11 Jan 2023 04:38:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=marcan.st; s=default; t=1673411911; bh=3mwbRHlRhjEn6d7ialc4jgg5I5MLJj7InHbf8EL6vA0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=gtOdbdn7hRKNeJrKJRvmsoB4h2WV3TdpgzrVGVcpQ+O/RUW4pAwhiS3d5c65/H4lv pJhXSXKrNTs7s8odh9yDMffyHuPvieDbG3RC7gWLalFhXhltp/ytsHX1dcIN74JUES tPz+pwugBCo+WOiapqL9nubi4zzwg1YjNgeqC0Uy7U4oVr9O0cH9ApVemrOaEE+SCW +UjamWWPMvp/gXVXdzpdunJkBp7+G2p/42WU82fSJUFtZej9YELwvVRIXWvMx8JlS/ 2YzLZGzn2w7Py8Wv3Bsjf4QEBty+FrMl0s1LX8po9TVKPCwyiAPUG2eAjpeeXyJnrB 1e+lPNgb1sjBA== From: Hector Martin To: Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg Cc: Eric Curtin , Janne Grunau , Sven Peter , Alyssa Rosenzweig , asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Hector Martin Subject: [PATCH 2/2] nvme: Handle shut down controllers during initialization Date: Wed, 11 Jan 2023 13:36:14 +0900 Message-Id: <20230111043614.27087-3-marcan@marcan.st> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230111043614.27087-1-marcan@marcan.st> References: <20230111043614.27087-1-marcan@marcan.st> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230110_203832_924055_9224F66F X-CRM114-Status: GOOD ( 14.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org According to the spec, controllers need an explicit reset to become active again after a controller shutdown. Check for this state in nvme_enable_ctrl and issue an explicit disable if required, which will trigger the required reset. Fixes: c76b8308e4c9 ("nvme-apple: fix controller shutdown in apple_nvme_disable") Signed-off-by: Hector Martin --- drivers/nvme/host/core.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 7be562a4e1aa..84e5db192ff9 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2410,6 +2410,19 @@ int nvme_enable_ctrl(struct nvme_ctrl *ctrl) if (ret) return ret; + /* + * If the controller is enabled but shut down, we need to disable it to + * reset it and have it come up. If the controller has completed a + * shutdown and is disabled, then we need to clear the shutdown request + * and enable it in the same write to CC. + * See NVMe Base Spec 2.0c Figure 47. + */ + if (ctrl->ctrl_config & NVME_CC_SHN_MASK && ctrl->ctrl_config & NVME_CC_ENABLE) { + ret = nvme_disable_ctrl(ctrl, false); + if (ret) + return ret; + } + ctrl->ctrl_config &= ~NVME_CC_SHN_MASK; ctrl->ctrl_config |= NVME_CC_ENABLE; ret = ctrl->ops->reg_write32(ctrl, NVME_REG_CC, ctrl->ctrl_config); if (ret)