Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp8898709rwl; Tue, 10 Jan 2023 21:43:42 -0800 (PST) X-Google-Smtp-Source: AMrXdXv5WnNob+RA84Sq2vyGjsbD47ySCCBBA9TNO3JiF45+VHBjPGhunYrR7eV5GDCE4CDwuOhV X-Received: by 2002:a17:907:a809:b0:7c1:5467:39af with SMTP id vo9-20020a170907a80900b007c1546739afmr66424400ejc.37.1673415822492; Tue, 10 Jan 2023 21:43:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673415822; cv=none; d=google.com; s=arc-20160816; b=gRsch9/OdV60WBzaqXWx/4NhJ6DWawHCNGrlCYna0eRDutYqhSVk2jyqlVr0xM3NaK OADJ4E7ecYqWyeqrCPUCGAV0S3PGNipaxGlSSWwgHlo98MyHCJEj2lgQhN+2hg9IDyfA 9XTbbixZlL8yK91X98ZNkSeeP0ZqDmaibdwrhV9xchhJaaG2yfnClpDihckfjVIcXI/b q9WfrXjjgmQk8xCduIl5Qo1WVfwM4o/7sAWZCXNo8jipLPZYecmYD1dzPvJI7k1BupnJ uLY8HafQmjuSQF+eML+iZcWLsqNPXTCA/80QIp5E7WEVqCNdBZVkKuuEn/MN119/4FZE N9Rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=gJxxb2ZWVhEuXmw/t+4O9GPtVyDXiFR31EUQyydnZwU=; b=uAtZqsB7pybQr5Jtkwqx9yJpSgBMObAJWyySE6a/Tj7F+W4s4ceqa6O2OXBL+kCoy5 NtTO849FLpw5bNh71TJrFO8hfe5ktICQC2g9s9/otOyBfpT9IPBzauUufD/5ImayNJ/q nHiQNlTSDdM/6sbXpkXs3LAQjzBth4iFENSWwlElwZ5OzovjX5AcxvJgkRkyDy4qE4pZ JIvtZNpRLHEVr7d31QCT4bm9Pcb40UeX1rAczaV1l5z7Tp0T+bRvDowPxwPLXnl9D4/1 8noD0deBBqHLGzrdR14FpfSP7sZq8TXLoXad7L++zxAvQGJPDUsqjgdZ49SkxoRg4xH+ AqAQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sc40-20020a1709078a2800b007c0bc66e526si15907168ejc.622.2023.01.10.21.43.29; Tue, 10 Jan 2023 21:43:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235990AbjAKFZL (ORCPT + 53 others); Wed, 11 Jan 2023 00:25:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231869AbjAKFYU (ORCPT ); Wed, 11 Jan 2023 00:24:20 -0500 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A67FE032 for ; Tue, 10 Jan 2023 21:18:41 -0800 (PST) Received: by verein.lst.de (Postfix, from userid 2407) id 6AB6568BEB; Wed, 11 Jan 2023 06:18:36 +0100 (CET) Date: Wed, 11 Jan 2023 06:18:36 +0100 From: Christoph Hellwig To: Hector Martin Cc: Christoph Hellwig , Keith Busch , Jens Axboe , Sagi Grimberg , 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 Subject: Re: [PATCH 1/2] nvme-apple: Do not try to shut down the controller twice Message-ID: <20230111051836.GA16576@lst.de> References: <20230111043614.27087-1-marcan@marcan.st> <20230111043614.27087-2-marcan@marcan.st> <20230111045402.GB15520@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17 (2007-11-01) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 11, 2023 at 02:10:42PM +0900, Hector Martin wrote: > OK, so the first question is who is responsible for resetting the > controller after a shutdown? The spec requires a reset in order to bring > it back up from that state. Indeed the PCIe code does an explicit > disable right now (though, judging by the comment, it probably wasn't > done with the intent of resetting after a shutdown, it just happens to > work for that too :)) We need to do the reset before banging the registers to make sure the controller is in a sane state before starting to set it up. > Right now, apple_nvme_reset_work() tries to check for the condition of > an enabled controller (under the assumption that it's coming from a live > controller, not considering shutdown/sleep) and issue an > apple_nvme_disable(). However, this doesn't work when resuming because > at that point the firmware coprocessor is shut down, so the device isn't > usable (can't even get a disable command to complete properly). Perhaps > a better conditional here would be to check for > apple_rtkit_is_running(), since apple_nvme_disable() can't work otherwise. So on a resume the controller should have previously been shutdown properly, and this shouldn't be an issue. Does the apple implementation leave some weird state after a shut down? In that case the resume callback might want to do an explicit controller disable before doing the reset. > Alternatively, we could just revert to the prior behavior of always > issuing a disable after a shutdown. We need to disable at some point to > come back anyway, so it might as well be done early (before we shut down > firmware, so it works). So the disable before shutdown doesn't really make sense from the NVMe POV - the shutdown is to cleanly bring the device into a state where it can quickly recover. While a disable is an abprupt shutdown, which can have effects on recover time, and might also use way more P/E cycles than nessecary. So if you always want to do a disable, it should be after shutdown, and in doubt in the resume / setup path instead of the remove / suspend one.