From nobody Sun Sep 14 22:31:44 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A5F1C54E76 for ; Tue, 17 Jan 2023 19:35:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234165AbjAQTdj (ORCPT ); Tue, 17 Jan 2023 14:33:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232702AbjAQT03 (ORCPT ); Tue, 17 Jan 2023 14:26:29 -0500 Received: from soltyk.jannau.net (soltyk.jannau.net [144.76.91.90]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F082047429 for ; Tue, 17 Jan 2023 10:34:18 -0800 (PST) Received: from robin.home.jannau.net (p579ad32f.dip0.t-ipconnect.de [87.154.211.47]) by soltyk.jannau.net (Postfix) with ESMTPSA id 7FEC926F670; Tue, 17 Jan 2023 19:25:02 +0100 (CET) From: Janne Grunau Date: Tue, 17 Jan 2023 19:25:00 +0100 Subject: [PATCH v2 1/2] nvme-apple: Reset controller during shutdown MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230114-apple-nvme-suspend-fixes-v6.2-v2-1-9157bf633dba@jannau.net> References: <20230114-apple-nvme-suspend-fixes-v6.2-v2-0-9157bf633dba@jannau.net> In-Reply-To: <20230114-apple-nvme-suspend-fixes-v6.2-v2-0-9157bf633dba@jannau.net> To: Hector Martin , Sven Peter , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg Cc: Alyssa Rosenzweig , Eric Curtin , asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Janne Grunau X-Mailer: b4 0.11.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1570; i=j@jannau.net; h=from:subject:message-id; bh=qtyorAlxkkMT/6LLYB1Bf2sjPkpsduWNqrw5l5ng7OU=; b=owGbwMvMwCG2UNrmdq9+ahrjabUkhuRjz//une7jdPHspxsXz4QpX9JqNW8ofLKt7PmpS3uFL4W2 pp5J6ChlYRDjYJAVU2RJ0n7ZwbC6RjGm9kEYzBxWJpAhDFycAjCRp1MZ/kd5BHDxrL5lGKkQLbzupt leg5POL7XC/xQ81XglfsEjewojw7qzBjVf5V6eXtwT5vDAJuO4wuKne1/GtrmEbnK+e63+PgcA X-Developer-Key: i=j@jannau.net; a=openpgp; fpr=8B336A6BE4E5695E89B8532B81E806F586338419 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is a functional revert of c76b8308e4c9 ("nvme-apple: fix controller shutdown in apple_nvme_disable"). The commit broke suspend/resume since apple_nvme_reset_work() tries to disable the controller on resume. This does not work for the apple NVMe controller since register access only works while the co-processor firmware is running. Disabling the NVMe controller in the shutdown path is also required for shutting the co-processor down. The original code was appropriate for this hardware. Add a comment to prevent a similar breaking changes in the future. Fixes: c76b8308e4c9 ("nvme-apple: fix controller shutdown in apple_nvme_dis= able") Reported-by: Janne Grunau Link: https://lore.kernel.org/all/20230110174745.GA3576@jannau.net/ Signed-off-by: Janne Grunau --- drivers/nvme/host/apple.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/apple.c b/drivers/nvme/host/apple.c index bf1c60edb7f9..2a1f11b30615 100644 --- a/drivers/nvme/host/apple.c +++ b/drivers/nvme/host/apple.c @@ -829,7 +829,13 @@ static void apple_nvme_disable(struct apple_nvme *anv,= bool shutdown) apple_nvme_remove_cq(anv); } =20 - nvme_disable_ctrl(&anv->ctrl, shutdown); + /* + * Always reset the NVMe controller on shutdown. The reset is + * required to shutdown the co-processor cleanly. + */ + if (shutdown) + nvme_disable_ctrl(&anv->ctrl, shutdown); + nvme_disable_ctrl(&anv->ctrl, false); } =20 WRITE_ONCE(anv->ioq.enabled, false); --=20 2.38.2 From nobody Sun Sep 14 22:31:44 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79BF6C3DA78 for ; Tue, 17 Jan 2023 19:35:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234635AbjAQTeS (ORCPT ); Tue, 17 Jan 2023 14:34:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232686AbjAQT03 (ORCPT ); Tue, 17 Jan 2023 14:26:29 -0500 X-Greylist: delayed 555 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 17 Jan 2023 10:34:19 PST Received: from soltyk.jannau.net (soltyk.jannau.net [144.76.91.90]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E99F2113E2 for ; Tue, 17 Jan 2023 10:34:18 -0800 (PST) Received: from robin.home.jannau.net (p579ad32f.dip0.t-ipconnect.de [87.154.211.47]) by soltyk.jannau.net (Postfix) with ESMTPSA id F0B5B26F671; Tue, 17 Jan 2023 19:25:02 +0100 (CET) From: Janne Grunau Date: Tue, 17 Jan 2023 19:25:01 +0100 Subject: [PATCH v2 2/2] nvme-apple: Only reset the controller when RTKit is running MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230114-apple-nvme-suspend-fixes-v6.2-v2-2-9157bf633dba@jannau.net> References: <20230114-apple-nvme-suspend-fixes-v6.2-v2-0-9157bf633dba@jannau.net> In-Reply-To: <20230114-apple-nvme-suspend-fixes-v6.2-v2-0-9157bf633dba@jannau.net> To: Hector Martin , Sven Peter , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg Cc: Alyssa Rosenzweig , Eric Curtin , asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Janne Grunau X-Mailer: b4 0.11.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1064; i=j@jannau.net; h=from:subject:message-id; bh=u2Uiv1bFso8EeQe26njgU/kTCYTgJ/N9RudVytjdmsU=; b=owGbwMvMwCG2UNrmdq9+ahrjabUkhuRjz//K7P3Rc/S+5fOiFZ0c4hcrs/1V1n16zHbtrIGKb0w1 r/zJjlIWBjEOBlkxRZYk7ZcdDKtrFGNqH4TBzGFlAhnCwMUpABMpcmBkeMTZ9OH5v9lqSRceHORvM4 4Q9zFbz9UsNGFlye/3Jg998hj++7Hea4k33LTUPu655PbvoTG930vEfwQnzVLgzrJcpPmXCQA= X-Developer-Key: i=j@jannau.net; a=openpgp; fpr=8B336A6BE4E5695E89B8532B81E806F586338419 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org NVMe controller register access hangs indefinitely when the co-processor is not running. A missed reset is preferable over a hanging thread since it could be recoverable. Signed-off-by: Janne Grunau --- drivers/nvme/host/apple.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/nvme/host/apple.c b/drivers/nvme/host/apple.c index 2a1f11b30615..3258fd7efaf9 100644 --- a/drivers/nvme/host/apple.c +++ b/drivers/nvme/host/apple.c @@ -991,11 +991,11 @@ static void apple_nvme_reset_work(struct work_struct = *work) goto out; } =20 - if (anv->ctrl.ctrl_config & NVME_CC_ENABLE) - apple_nvme_disable(anv, false); - /* RTKit must be shut down cleanly for the (soft)-reset to work */ if (apple_rtkit_is_running(anv->rtk)) { + /* reset the controller if it is enabled */ + if (anv->ctrl.ctrl_config & NVME_CC_ENABLE) + apple_nvme_disable(anv, false); dev_dbg(anv->dev, "Trying to shut down RTKit before reset."); ret =3D apple_rtkit_shutdown(anv->rtk); if (ret) --=20 2.38.2