[PATCH 1/1] nvme: retry security commands if media not ready

Greg Joyce gjoyce at linux.ibm.com
Thu Oct 3 06:30:21 PDT 2024


On Thu, 2024-10-03 at 14:43 +0200, Christoph Hellwig wrote:
> On Wed, Oct 02, 2024 at 11:51:56AM -0500, Greg Joyce wrote:
> > If we cache the timeout value(s) in nvme_ctrl then it may be
> > possible
> > to just eliminate nvme_get_timeout() entirely. Is this the approach
> > that you were thinking?
> 
> Yes.
> 
> > I'm a little confused about what you're saying about the timeout.
> > nvme_enable_ctrl() does determine the correct timeout value and
> > passes
> > it to nvme_wait_ready() but NVME_CSTS_RDY is set well before the
> > media
> > is ready (if CC.CRIME is set). Unfortunately there doesn't seem to
> > be
> > any controller status that indicates when the media is ready. I
> > thought
> > about having nvme_wait_ready() wait the whole timeout if CC.CRIME
> > is
> > set, but I think that is contrary to intent of CC.CRIME. And on the
> > SSD
> > that I'm looking at the timeout is 15 seconds which would be a
> > pretty
> > big hit to boot time.
> 
> What I mean is to simply set a timer for the controller ready
> timeout,
> fire it when we set CC.EN and then the time sets a new media ready
> flag in ctrl->flags.  Then only retry when this flag is not set.
> 

Thanks. I think that leads me to ask a larger question. If we always
wait until media ready, does the driver really need to set
NVME_CC_CRIME? Currently it only gets set if both the
NVME_CAP_CRMS_CRWMS and NVME_CAP_CRMS_CRIMS are set. So the
NVME_CC_CRIME config option is only set based on drive capabilities and
not any user configuration.

If NVME_CC_CRIME is not set, then the controller doesn't assert ready
until the media is ready and this issue does not occur.

So the question is, should the fix be to just remove the NVMe driver
code that sets NVME_CC_CRIME?

-Greg



More information about the Linux-nvme mailing list