From: Christoph Hellwig <hch@lst.de>
To: Hector Martin <marcan@marcan.st>
Cc: Christoph Hellwig <hch@lst.de>, Keith Busch <kbusch@kernel.org>,
Jens Axboe <axboe@fb.com>, Sagi Grimberg <sagi@grimberg.me>,
Eric Curtin <ecurtin@redhat.com>, Janne Grunau <j@jannau.net>,
Sven Peter <sven@svenpeter.dev>,
Alyssa Rosenzweig <alyssa@rosenzweig.io>,
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
Date: Wed, 11 Jan 2023 06:18:36 +0100 [thread overview]
Message-ID: <20230111051836.GA16576@lst.de> (raw)
In-Reply-To: <fc2e03ea-5404-e768-0cab-e95adcde6da7@marcan.st>
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
next prev parent reply other threads:[~2023-01-11 5:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-11 4:36 [PATCH 0/2] nvme-apple: Fix suspend-resume regression Hector Martin
2023-01-11 4:36 ` [PATCH 1/2] nvme-apple: Do not try to shut down the controller twice Hector Martin
2023-01-11 4:54 ` Christoph Hellwig
2023-01-11 5:10 ` Hector Martin
2023-01-11 5:18 ` Christoph Hellwig [this message]
2023-01-11 5:44 ` Hector Martin
2023-01-11 6:41 ` Christoph Hellwig
2023-01-11 4:36 ` [PATCH 2/2] nvme: Handle shut down controllers during initialization Hector Martin
2023-01-11 4:50 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230111051836.GA16576@lst.de \
--to=hch@lst.de \
--cc=alyssa@rosenzweig.io \
--cc=asahi@lists.linux.dev \
--cc=axboe@fb.com \
--cc=ecurtin@redhat.com \
--cc=j@jannau.net \
--cc=kbusch@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=marcan@marcan.st \
--cc=sagi@grimberg.me \
--cc=sven@svenpeter.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).