Skip to contentSkip to conversation

nvme: don't send unsupported NVME_ID_CNS_CS_CTRL

PATCH In review Caleb Sander 2 participants 2 messages Jun 8, 2022 NVMe

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvme: don't send unsupported NVME_ID_CNS_CS_CTRL

Identify CNS values 0x05 to 0x0F are reserved in NVMe base spec 1.4. 0x06 was only added in spec 2.0. Our array implementing spec version 1.3 correctly responds to this Identify with "Invalid Field in Command". The driver ignores an error status code here, but the reserved CNS value violates the spec and causes unnecessary traffic on the NVMe connection.

Require controller version 2.0 to send this command instead of 1.1.

---
 drivers/nvme/host/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/core.c +1 -1
index 24165daee..ebffc3545 100644
@@ -2934,11 +2934,11 @@ static int nvme_init_non_mdts_limits(struct nvme_ctrl *ctrl)
 	    !(ctrl->quirks & NVME_QUIRK_DISABLE_WRITE_ZEROES))
 		ctrl->max_zeroes_sectors = ctrl->max_hw_sectors;
 	else
 		ctrl->max_zeroes_sectors = 0;
 
-	if (nvme_ctrl_limited_cns(ctrl))
+	if (ctrl->vs < NVME_VS(2, 0, 0))
 		return 0;
 
 	id = kzalloc(sizeof(*id), GFP_KERNEL);
 	if (!id)
 		return 0;
Signature · 1 line
2.25.1
#1 lore raw
Quoted 5 lines · Caleb Sander

Identify CNS values 0x05 to 0x0F are reserved in NVMe base spec 1.4. 0x06 was only added in spec 2.0. Our array implementing spec version 1.3 correctly responds to this Identify with "Invalid Field in Command". The driver ignores an error status code here, but the reserved CNS value violates the spec and causes unnecessary traffic on the NVMe connection.

No, it does not "violate" the spec. All NVMe TPs can be implement for older spec versions as well, and regularly do. So yes, your array will return an error here and that is perfectly fine.