From mboxrd@z Thu Jan 1 00:00:00 1970 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 225BEC678D5 for ; Wed, 11 Jan 2023 05:19:36 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8BEBNb2aWIRBbwJz9yrtKcHp22ZfDyrjooxcFHg2ddU=; b=UMlvd4Wrb9jfyY ZlXDzEs65cP+7sA/6w47JYXDwky4CiWtX5j0XdkCdE3GANcw1BdcuBaVa3yYJ+NjWXNhaH741MoB1 Mn4zO2y0lPQ0+Db3ZgaMQ8WMg/HBZgH5WQiXrfY7MHq+wknwZLsZ5tdLrP+PwuW5AWOTbgZ4KlymZ 0xzhLudMb7O5jvmCjMPPW5+QiEe0LWShXgDpzmWFLijwkh4cS5hnA1dY0OeciP9YWOj8h2v1AwQDt vezrhrMUAdvN4l7rF97LVZvbVoA1dvk8SDeVhyWH/W1nInItK8pilxxhIGnu9isVZS1wtcmM5x5ww G4wnXKdDZVliB7zZcEPw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFTVb-009frw-A4; Wed, 11 Jan 2023 05:18:43 +0000 Received: from verein.lst.de ([213.95.11.211]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFTVY-009frI-Il; Wed, 11 Jan 2023 05:18:41 +0000 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-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17 (2007-11-01) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230110_211840_789356_9D71DE23 X-CRM114-Status: GOOD ( 26.91 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel