Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp8973606rwl; Tue, 10 Jan 2023 23:04:17 -0800 (PST) X-Google-Smtp-Source: AMrXdXvt/0snTwIEI7VlJND4nat6rRd/NkjR5tiqmv7iW49bA9gjsd6zOjp4xvykitcc3lG3yYp7 X-Received: by 2002:a17:902:ecc1:b0:192:760f:c35e with SMTP id a1-20020a170902ecc100b00192760fc35emr77024693plh.53.1673420657113; Tue, 10 Jan 2023 23:04:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673420657; cv=none; d=google.com; s=arc-20160816; b=GB8/b0YQ8HKOLifRx7hHwwnvfDD5GwziCKsX8JSyladkRt2QBRYaE3S6TT2lZibXnD 2LO6m91b6kX1AcqPk23HkS9hhZ7UY+U4YcOE/FAMTUp1hyKDpst00IarTNnVoA3R2Nz7 lq8mSv7SZ66xslcNnqTAFAUOziXE0x9eIRH8NMdJA8f9LaxUxsXM+UtN2WbGyofeAsv9 nGGzRnK2n5noZskoTP4rWI4VrdVEcgFohly4gKx2xTFrizP+RTJ7pKyJZEESd0cRKJb6 3YtLgo84we1d6wnH+n6LaUXP5W7XRYNQN1dy9XqZscWd2YP0PZ32JgUSL8zi/bTpYWB2 teTg== 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=WdSJer6GSyMumPEXHTpi+4fJo0tw6X9dji2BQnUjs10=; b=ucvbxRd0JN3ir+XrxbQI7mJcAbirBLOMV5a0uTEFha9Z5fYCcjxICWnHk0Lb40U5b8 OsXFt44hSLLoXhocX/4C2arMqM8y8a2JtgqRBy5wGcl8Lo3T3z9hweePM9kBSf+6RQ5B 5H/5Tog/orobvPw5HIhfEiFnDk+y5/Dnqeu4ETszY6gEoWVPuSjOuNtg1IQhaWOiUYd8 C9QrMYOkXk+gt9/F114bB8lgtcQXsUqUCfRPvmJ5nKpIJ8LUIjYn/SoXIOT86yqCe2tI nxs6yhbBopscFKdT20c+PCL88Sgq4lg1QW0cRCdZjZvwFu3hn1W0DCtQc5a4GSEFL+9I Rb/A== 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 a26-20020a631a1a000000b004776a50bd21si13388624pga.579.2023.01.10.23.04.10; Tue, 10 Jan 2023 23:04:17 -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 S231979AbjAKGla (ORCPT + 55 others); Wed, 11 Jan 2023 01:41:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231694AbjAKGl1 (ORCPT ); Wed, 11 Jan 2023 01:41:27 -0500 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7461B2AD6 for ; Tue, 10 Jan 2023 22:41:26 -0800 (PST) Received: by verein.lst.de (Postfix, from userid 2407) id CB7D868BEB; Wed, 11 Jan 2023 07:41:20 +0100 (CET) Date: Wed, 11 Jan 2023 07:41:20 +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: <20230111064120.GA18581@lst.de> References: <20230111043614.27087-1-marcan@marcan.st> <20230111043614.27087-2-marcan@marcan.st> <20230111045402.GB15520@lst.de> <20230111051836.GA16576@lst.de> <0e7f9ef4-6660-5842-821b-7492f7ecbc61@marcan.st> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0e7f9ef4-6660-5842-821b-7492f7ecbc61@marcan.st> 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:44:42PM +0900, Hector Martin wrote: > The higher-level resume path can't do a disable since the firmware isn't > up at that point, and the subsequent reset (which is shared with other > conditions that cause a reset) is what brings the firmware back up. So > the disable has to either happen in the suspend path, or in the shared > reset path after we know the firmware is running. Ok, that's the weird part where nvme-apply really isn't nvme at all. Because for actual NVMe devices the register access must work all the time. > That's only if you issue a disable *in lieu* of a shutdown (and in fact > if you do that on Apple controllers under some conditions, they crash). > Issuing a disable *after* a shutdown is required by the NVMe spec if you > want to use the controller again (and should basically do nothing at > that point, since the controller is already cleanly shut down, but it is > required to set EN to 0 such that the subsequent 0->1 transition > actually kickstarts the controller again). If you don't do that, the > controller never leaves the shutdown state (how would it know?). Yes. Although I would not call this a disable after shutdown, but a disable (or rather reset) before using it again. > To be clear, the sequence I was attempting to describe (which is what we > were doing before the patch that regressed this) was: > > (on sleep) > - NVMe shutdown > - NVMe disable > - Firmware shutdown > > After the firmware shutdown, we can't do anything with NVMe again until > we start firmware back up, which requires going through the reset flow. > > Right now we're doing: > > (on sleep) > - NVMe shutdown > - Firmware shutdown > (wakeup) > - Oops, NVMe is enabled, let's disable it! (times out due to FW being > down but failure isn't propagated) > - Firmware startup > - NVMe enable (thinks it succeeds but actually the controller is still > in the shutdown state since it was never disabled and this persists > across the firmware cycle!) > - I/O (never completes) Yes, so I guess due to the weird firmware issues doing the disable after shutdown instead of before setting up might be the right thing for nvme-apple, unlike real NVMe. So I guess we need to do that in the driver, and add a big fat comment explaining why.