Skip to contentSkip to conversation

nvme: disable CC.CRIME (NVME_CC_CRIME)

PATCH Superseded [email protected] 2 participants 3 messages Oct 7, 2024 NVMe

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover nvme: disable CC.CRIME (NVME_CC_CRIME)

From: Greg Joyce <[email protected]>

NVMe 2.0 introduced a configuration setting CC.CRIME that allows the controller to set CSTS.RDY before the media is fully enabled. In this case commands listed in Figure 103 may return the status NVME_SC_ADMIN_COMMAND_MEDIA_NOT_READY. The NVMe driver is not coded to handle these failures so initialization errors occur.

Since the current driver does not:
1) retry media not ready errors
2) utilize any parallel initialization that CRIME may provide

setting NVME_CC_CRIME provides no value.

The NVMe 2.0 spec says this about CC.CRIME:
"If the CAP.CRMS field is set to 11b, then both controller
ready modes are supported, and the host may select the controller ready mode by modifying the value of the CC.CRIME bit."

This the CC.CRIME feature is optional and this patch removes it.

Greg Joyce (1):
nvme: disable CC.CRIME (NVME_CC_CRIME)

 drivers/nvme/host/core.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
Signature · 1 line
[email protected]
#1 lore raw

PATCH 1/1 nvme: disable CC.CRIME (NVME_CC_CRIME)

From: Greg Joyce <[email protected]>

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.

---
 drivers/nvme/host/core.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/nvme/host/core.c +7 -2
index ba6508455e18..6b313524143a 100644
@@ -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
+	 * structured 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;
Signature · 1 line
[email protected]
maintainer
#2 lore raw

drivers/nvme/host/core.c int nvme_enable_ctrl(struct nvme_ctrl *ctrl) · line 2467

Quoted 13 lines · On Mon, Oct 07, 2024 at 09:59:58AM -0500, [email protected] wrote:
drivers/nvme/host/core.c +7 -2
@@ -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
+	 * structured to handle retries, disable CC.CRIME.
+	 */
+	ctrl->ctrl_config &= ~NVME_CC_CRIME;

A little further down in this function, there's a check from CC_CRIME to know which ready timeout value to use. You can remove that check with this change.