Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Nilay Shroff <nilay@linux.ibm.com>
To: gjoyce@linux.ibm.com, linux-nvme@lists.infradead.org
Cc: kbusch@kernel.org, axboe@fb.com, hch@lst.de, sagi@grimberg.me,
	hare@suse.de, dwagner@suse.de, msuchanek@suse.de,
	jonathan.derrick@linux.dev, okozina@redhat.com
Subject: Re: [PATCH v2 1/1] nvme: disable CC.CRIME (NVME_CC_CRIME)
Date: Tue, 8 Oct 2024 21:15:45 +0530	[thread overview]
Message-ID: <99bf368e-5970-44a4-8407-49747f0e2339@linux.ibm.com> (raw)
In-Reply-To: <20241007193324.5846-2-gjoyce@linux.ibm.com>



On 10/8/24 01:03, gjoyce@linux.ibm.com wrote:
> From: Greg Joyce <gjoyce@linux.ibm.com>
> 
> Disable NVME_CC_CRIME so that CSTS.RDY indicates that the media
> is ready and able to handle commands without returning
> NVME_SC_ADMIN_COMMAND_MEDIA_NOT_READY.
> 
> Signed-off-by: Greg Joyce <gjoyce@linux.ibm.com>
> ---
>  drivers/nvme/host/core.c | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index ba6508455e18..10eca7660ca7 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -2458,8 +2458,13 @@ int nvme_enable_ctrl(struct nvme_ctrl *ctrl)
>  	else
>  		ctrl->ctrl_config = NVME_CC_CSS_NVM;
>  
> -	if (ctrl->cap & NVME_CAP_CRMS_CRWMS && ctrl->cap & NVME_CAP_CRMS_CRIMS)
> -		ctrl->ctrl_config |= NVME_CC_CRIME;
> +	/*
> +	 * Setting CRIME results in CSTS.RDY before the media is ready. This
> +	 * make it possible for media related commands to return the error
> +	 * NVME_SC_ADMIN_COMMAND_MEDIA_NOT_READY. Until the driver is
> +	 * restructurade to handle retries, disable CC.CRIME.
> +	 */
> +	ctrl->ctrl_config &= ~NVME_CC_CRIME;
>  
>  	ctrl->ctrl_config |= (NVME_CTRL_PAGE_SHIFT - 12) << NVME_CC_MPS_SHIFT;
>  	ctrl->ctrl_config |= NVME_CC_AMS_RR | NVME_CC_SHN_NONE;
> @@ -2489,10 +2494,7 @@ int nvme_enable_ctrl(struct nvme_ctrl *ctrl)
>  		 * devices are known to get this wrong. Use the larger of the
>  		 * two values.
>  		 */
> -		if (ctrl->ctrl_config & NVME_CC_CRIME)
> -			ready_timeout = NVME_CRTO_CRIMT(crto);
> -		else
> -			ready_timeout = NVME_CRTO_CRWMT(crto);
> +		ready_timeout = NVME_CRTO_CRWMT(crto);
>  
>  		if (ready_timeout < timeout)
>  			dev_warn_once(ctrl->device, "bad crto:%x cap:%llx\n",

Looks good to me.

Reviewed-by: nilay@linux.ibm.com

Tested the above patch on Kioxia disk supporting TCG Opal SED. My test 
confirmed that the patch works as expected and we don't see 
NVME_SC_ADMIN_COMMAND_MEDIA_NOT_READY error during opal discovery or 
any admin command executed during disk initialization.

Tested-by: nilay@linux.ibm.com


  reply	other threads:[~2024-10-08 15:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-07 19:33 [PATCH v2 0/1] nvme: disable CC.CRIME (NVME_CC_CRIME) gjoyce
2024-10-07 19:33 ` [PATCH v2 1/1] " gjoyce
2024-10-08 15:45   ` Nilay Shroff [this message]
2024-10-08 17:35   ` Keith Busch
2024-10-09  7:51     ` Christoph Hellwig
2024-10-09 19:47   ` Keith Busch
2024-10-09 22:04   ` Keith Busch
2024-10-10 16:11     ` Greg Joyce
2024-10-10 16:16       ` Keith Busch

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=99bf368e-5970-44a4-8407-49747f0e2339@linux.ibm.com \
    --to=nilay@linux.ibm.com \
    --cc=axboe@fb.com \
    --cc=dwagner@suse.de \
    --cc=gjoyce@linux.ibm.com \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=jonathan.derrick@linux.dev \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=msuchanek@suse.de \
    --cc=okozina@redhat.com \
    --cc=sagi@grimberg.me \
    /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