Skip to contentSkip to conversation

nvme: Namepace identification descriptor list is optional

PATCH In review Keith Busch 6 participants 15 messages Dec 2, 2019 – Jul 28, 2020

Subsystems (2)
lore
Share & tools
lore

Keith Busch

author maintainer
#0 lore raw

PATCH 1/1 nvme: Namepace identification descriptor list is optional

Despite NVM Express specification 1.3 requires a controller claiming to be 1.3 or higher implement Identify CNS 03h (Namespace Identification Descriptor list), the driver doesn't really need this identification in order to use a namespace. The code had already documented in comments that we're not to consider an error to this command.

Return success if the controller provided any response to an namespace identification descriptors command.

Fixes 538af88ea7d9de24 ("nvme: make nvme_report_ns_ids propagate error back")
Cc Sagi Grimberg <[email protected]>
---
 drivers/nvme/host/core.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/nvme/host/core.c +2 -0
index e6ee34376c5e..2a84e1402244 100644
@@ -1735,6 +1735,8 @@ static int nvme_report_ns_ids(struct nvme_ctrl *ctrl, unsigned int nsid,
 		if (ret)
 			dev_warn(ctrl->device,
 				 "Identify Descriptors failed (%d)\n", ret);
+		if (ret > 0)
+			ret = 0;
 	}
 	return ret;
 }
Signature · 1 line
2.21.0
#1 lore raw
Quoted 11 lines · Keith Busch

Despite NVM Express specification 1.3 requires a controller claiming to be 1.3 or higher implement Identify CNS 03h (Namespace Identification Descriptor list), the driver doesn't really need this identification in order to use a namespace. The code had already documented in comments that we're not to consider an error to this command.

Return success if the controller provided any response to an namespace identification descriptors command.

Fixes 538af88ea7d9de24 ("nvme: make nvme_report_ns_ids propagate error back")

Why would we ignore the error? Do you have a buggy controller messing this up?

author maintainer
#2 lore raw
Quoted 7 lines · Christoph Hellwig
Quoted 6 lines · Keith Busch

Despite NVM Express specification 1.3 requires a controller claiming to be 1.3 or higher implement Identify CNS 03h (Namespace Identification Descriptor list), the driver doesn't really need this identification in order to use a namespace. The code had already documented in comments that we're not to consider an error to this command.

Quoted 8 lines
Quoted 5 lines

Return success if the controller provided any response to an namespace identification descriptors command.

Fixes 538af88ea7d9de24 ("nvme: make nvme_report_ns_ids propagate error back")

Why would we ignore the error? Do you have a buggy controller messing this up?

I don't have such a controller, but many apparently do. The regression was reported here:

http://lists.infradead.org/pipermail/linux-nvme/2019-December/028223.html

And of course it's the SMI controller ...

#3 lore raw
Quoted 17 lines · Keith Busch
Quoted 7 lines · Christoph Hellwig
Quoted 6 lines · Keith Busch

Despite NVM Express specification 1.3 requires a controller claiming to be 1.3 or higher implement Identify CNS 03h (Namespace Identification Descriptor list), the driver doesn't really need this identification in order to use a namespace. The code had already documented in comments that we're not to consider an error to this command.

Quoted 8 lines
Quoted 5 lines

Return success if the controller provided any response to an namespace identification descriptors command.

Fixes 538af88ea7d9de24 ("nvme: make nvme_report_ns_ids propagate error back")

Why would we ignore the error? Do you have a buggy controller messing this up?

Quoted 6 lines

I don't have such a controller, but many apparently do. The regression was reported here:

http://lists.infradead.org/pipermail/linux-nvme/2019-December/028223.html

And of course it's the SMI controller ...

Does 5.4 show the exact error code? Perhaps we should selectively allow just for that case?

Ed

#4 lore raw
Quoted 9 lines · Edmund
Quoted 6 lines

I don't have such a controller, but many apparently do. The regression was reported here:

http://lists.infradead.org/pipermail/linux-nvme/2019-December/028223.html

And of course it's the SMI controller ...

Does 5.4 show the exact error code? Perhaps we should selectively allow just for that case?

They'll find other ways to f***ck up. Looks like at least the controller in the bug report also doesn't have an subnqn and the nguid/eui64 are bogus. I wonder if we actually do users a favour by allowing that..

#5 lore raw
Quoted 6 lines · Christoph Hellwig
Quoted 5 lines · Edmund
Quoted 5 lines

I don't have such a controller, but many apparently do. The regression was reported here:

http://lists.infradead.org/pipermail/linux-nvme/2019-December/028223.html

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

And of course it's the SMI controller ...

Does 5.4 show the exact error code? Perhaps we should selectively allow just for that case?

They'll find other ways to f***ck up. Looks like at least the controller in the bug report also doesn't have an subnqn and the nguid/eui64 are bogus. I wonder if we actually do users a favour by allowing that..

Agreed, tho since it looks like a regression, does it make sense to treat as a quirk?

Ed

author maintainer
#6 lore raw
In reply to Christoph Hellwig
Quoted 6 lines · Christoph Hellwig
Quoted 5 lines · Edmund
Quoted 5 lines

I don't have such a controller, but many apparently do. The regression was reported here:

http://lists.infradead.org/pipermail/linux-nvme/2019-December/028223.html

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

And of course it's the SMI controller ...

Does 5.4 show the exact error code? Perhaps we should selectively allow just for that case?

They'll find other ways to f***ck up. Looks like at least the controller in the bug report also doesn't have an subnqn and the nguid/eui64 are bogus.

Indeed, they will find creative ways to break it.

Customer or OEM requirments are poorly written, like "Must report NVMe version 1.3". Nobody bothers to mention that it must also be compliant to that version, or even realize they never cared for those features in the first place.

Compliance testing like from UNH should have caught this before shipping with such a device, but it's a cheap device, so maybe they skip that step.

Quoted 1 line

I wonder if we actually do users a favour by allowing that..

I think it's too late now. We did successfully use such namespaces before 5.4, even if they're fundamentally broken.

Johannes also commented *not* to consider these errors when this identification was originally implemented, so either he knew vendors screwed this up, or had the forethought to know they would.

maintainer Reviewed-by
#7 lore raw
Quoted 8 lines · Keith Busch

Customer or OEM requirments are poorly written, like "Must report NVMe version 1.3". Nobody bothers to mention that it must also be compliant to that version, or even realize they never cared for those features in the first place.

Compliance testing like from UNH should have caught this before shipping with such a device, but it's a cheap device, so maybe they skip that step.

Quoted 8 lines
Quoted 1 line

I wonder if we actually do users a favour by allowing that..

I think it's too late now. We did successfully use such namespaces before 5.4, even if they're fundamentally broken.

Johannes also commented *not* to consider these errors when this identification was originally implemented, so either he knew vendors screwed this up, or had the forethought to know they would.

Yes. I guess your patch is the best thing for now:

But I think we might need a new kernel tain flag or something like it for devices that are so obviously broken in their identifiers.

author maintainer Applied
#8 lore raw
Quoted 3 lines · Christoph Hellwig

Yes. I guess your patch is the best thing for now:

Thanks, applied for-5.5

Quoted 2 lines

But I think we might need a new kernel tain flag or something like it for devices that are so obviously broken in their identifiers.

That's fine with me. We currently just log a warning when an error is returned here, we can add_taint() too. Which flag do you think? TAINT_FIRMWARE_WORKAROUND, TAINT_CRAP, or something else?

#9 lore raw
In reply to Keith Busch

With commit ea43d97, appearing now in kernel 5.7.8, you made my cheap SSD disfunctional again. For reference, see bug 205679. Maybe you remember the discussion.

I do not know if this was intentional or not. Maybe you should introduce a quirk for that particular controller.

Regards
Ingo Brunberg

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

maintainer
#10 lore raw
Quoted 7 lines

With commit ea43d97, appearing now in kernel 5.7.8, you made my cheap SSD disfunctional again. For reference, see bug 205679. Maybe you remember the discussion.

I do not know if this was intentional or not. Maybe you should introduce a quirk for that particular controller.

Either we quirk this controller, or we are back to test specific errors...

What is the pci id of the device to test a quirk?

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

#11 lore raw
Quoted 10 lines · Sagi Grimberg
Quoted 6 lines

With commit ea43d97, appearing now in kernel 5.7.8, you made my cheap SSD disfunctional again. For reference, see bug 205679. Maybe you remember the discussion.

I do not know if this was intentional or not. Maybe you should introduce a quirk for that particular controller.

Either we quirk this controller, or we are back to test specific errors...

What is the pci id of the device to test a quirk?

The PCI ID is 126f:2263

Related old and new bugs on bugzilla.kernel.org with some actual drives listed are: 205679, 205645, 208583, 208585

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

#12 lore raw
Quoted 6 lines · Ingo Brunberg
Quoted 4 lines · Sagi Grimberg
Quoted 4 lines

With commit ea43d97, appearing now in kernel 5.7.8, you made my cheap SSD disfunctional again. For reference, see bug 205679. Maybe you remember the discussion.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

I do not know if this was intentional or not. Maybe you should introduce a quirk for that particular controller.

Either we quirk this controller, or we are back to test specific errors...

What is the pci id of the device to test a quirk?

The PCI ID is 126f:2263

Please try this patch:

drivers/nvme/host/core.c +3 -13
index 05aa568a60af62..0602e0f3e77de9 100644
@@ -1287,18 +1287,6 @@ static int nvme_identify_ns_descs(struct nvme_ctrl *ctrl, unsigned nsid,
 	if (status) {
 		dev_warn(ctrl->device,
 			"Identify Descriptors failed (%d)\n", status);
-		 /*
-		  * Don't treat non-retryable errors as fatal, as we potentially
-		  * already have a NGUID or EUI-64.  If we failed with DNR set,
-		  * we want to silently ignore the error as we can still
-		  * identify the device, but if the status has DNR set, we want
-		  * to propagate the error back specifically for the disk
-		  * revalidation flow to make sure we don't abandon the
-		  * device just because of a temporal retry-able error (such
-		  * as path of transport errors).
-		  */
-		if (status > 0 && (status & NVME_SC_DNR) && !nvme_multi_css(ctrl))
-			status = 0;
 		goto free_data;
 	}
 
@@ -1888,7 +1876,9 @@ static int nvme_report_ns_ids(struct nvme_ctrl *ctrl, unsigned int nsid,
 		memcpy(ids->eui64, id->eui64, sizeof(id->eui64));
 	if (ctrl->vs >= NVME_VS(1, 2, 0))
 		memcpy(ids->nguid, id->nguid, sizeof(id->nguid));
-	if (ctrl->vs >= NVME_VS(1, 3, 0) || nvme_multi_css(ctrl))
+	if (nvme_multi_css(ctrl) ||
+	    (ctrl->vs >= NVME_VS(1, 3, 0) &&
+	     !(ctrl->quirks & NVME_QUIRK_NO_NS_DESC_LIST)))
 		return nvme_identify_ns_descs(ctrl, nsid, ids);
 	return 0;
 }
drivers/nvme/host/nvme.h +7 -0
index c5c1bac797aa5a..4cadaea9034ae4 100644
@@ -137,6 +137,13 @@ enum nvme_quirks {
 	 * Don't change the value of the temperature threshold feature
 	 */
 	NVME_QUIRK_NO_TEMP_THRESH_CHANGE	= (1 << 14),
+
+	/*
+	 * The controller doesn't handle the Identify Namespace
+	 * Identification Descriptor list subcommand despite claiming
+	 * NVMe 1.3 compliance.
+	 */
+	NVME_QUIRK_NO_NS_DESC_LIST		= (1 << 15),
 };
 
 /*
drivers/nvme/host/pci.c +2 -0
index 61e612d52d61d6..bac3a3f9c79e0d 100644
@@ -3181,6 +3181,8 @@ static const struct pci_device_id nvme_id_table[] = {
 	{ PCI_DEVICE(0x1cc1, 0x8201),   /* ADATA SX8200PNP 512GB */
 		.driver_data = NVME_QUIRK_NO_DEEPEST_PS |
 				NVME_QUIRK_IGNORE_DEV_SUBNQN, },
+	{ PCI_DEVICE(0x126f, 0x2263),
+		.driver_data = NVME_QUIRK_NO_NS_DESC_LIST, },
 	{ PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_EXPRESS, 0xffffff) },
 	{ PCI_DEVICE(PCI_VENDOR_ID_APPLE, 0x2001),
 		.driver_data = NVME_QUIRK_SINGLE_VECTOR },

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

#13 lore raw
Quoted 59 lines · Christoph Hellwig

Please try this patch:

drivers/nvme/host/core.c +3 -13
index 05aa568a60af62..0602e0f3e77de9 100644
@@ -1287,18 +1287,6 @@ static int nvme_identify_ns_descs(struct nvme_ctrl *ctrl, unsigned nsid,
 	if (status) {
 		dev_warn(ctrl->device,
 			"Identify Descriptors failed (%d)\n", status);
-		 /*
-		  * Don't treat non-retryable errors as fatal, as we potentially
-		  * already have a NGUID or EUI-64.  If we failed with DNR set,
-		  * we want to silently ignore the error as we can still
-		  * identify the device, but if the status has DNR set, we want
-		  * to propagate the error back specifically for the disk
-		  * revalidation flow to make sure we don't abandon the
-		  * device just because of a temporal retry-able error (such
-		  * as path of transport errors).
-		  */
-		if (status > 0 && (status & NVME_SC_DNR) && !nvme_multi_css(ctrl))
-			status = 0;
 		goto free_data;
 	}
 
@@ -1888,7 +1876,9 @@ static int nvme_report_ns_ids(struct nvme_ctrl *ctrl, unsigned int nsid,
 		memcpy(ids->eui64, id->eui64, sizeof(id->eui64));
 	if (ctrl->vs >= NVME_VS(1, 2, 0))
 		memcpy(ids->nguid, id->nguid, sizeof(id->nguid));
-	if (ctrl->vs >= NVME_VS(1, 3, 0) || nvme_multi_css(ctrl))
+	if (nvme_multi_css(ctrl) ||
+	    (ctrl->vs >= NVME_VS(1, 3, 0) &&
+	     !(ctrl->quirks & NVME_QUIRK_NO_NS_DESC_LIST)))
 		return nvme_identify_ns_descs(ctrl, nsid, ids);
 	return 0;
 }
drivers/nvme/host/nvme.h +7 -0
index c5c1bac797aa5a..4cadaea9034ae4 100644
@@ -137,6 +137,13 @@ enum nvme_quirks {
 	 * Don't change the value of the temperature threshold feature
 	 */
 	NVME_QUIRK_NO_TEMP_THRESH_CHANGE	= (1 << 14),
+
+	/*
+	 * The controller doesn't handle the Identify Namespace
+	 * Identification Descriptor list subcommand despite claiming
+	 * NVMe 1.3 compliance.
+	 */
+	NVME_QUIRK_NO_NS_DESC_LIST		= (1 << 15),
 };
 
 /*
drivers/nvme/host/pci.c +0 -0
index 61e612d52d61d6..bac3a3f9c79e0d 100644

drivers/nvme/host/pci.c static const struct pci_device_id nvme_id_table[] = { · line 3188

Quoted 8 lines
drivers/nvme/host/pci.c +2 -0
@@ -3181,6 +3181,8 @@ static const struct pci_device_id nvme_id_table[] = {
 	{ PCI_DEVICE(0x1cc1, 0x8201),   /* ADATA SX8200PNP 512GB */
 		.driver_data = NVME_QUIRK_NO_DEEPEST_PS |
 				NVME_QUIRK_IGNORE_DEV_SUBNQN, },
+	{ PCI_DEVICE(0x126f, 0x2263),
+		.driver_data = NVME_QUIRK_NO_NS_DESC_LIST, },
 	{ PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_EXPRESS, 0xffffff) },
 	{ PCI_DEVICE(PCI_VENDOR_ID_APPLE, 0x2001),
 		.driver_data = NVME_QUIRK_SINGLE_VECTOR },

Thanks, the patch works. Maybe it is not too late to make its way into kernel 5.8.

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

maintainer Reviewed-by
#14 lore raw
Quoted 61 lines
Quoted 61 lines
drivers/nvme/host/core.c +3 -13
index 05aa568a60af62..0602e0f3e77de9 100644
@@ -1287,18 +1287,6 @@ static int nvme_identify_ns_descs(struct nvme_ctrl *ctrl, unsigned nsid,
  	if (status) {
  		dev_warn(ctrl->device,
  			"Identify Descriptors failed (%d)\n", status);
-		 /*
-		  * Don't treat non-retryable errors as fatal, as we potentially
-		  * already have a NGUID or EUI-64.  If we failed with DNR set,
-		  * we want to silently ignore the error as we can still
-		  * identify the device, but if the status has DNR set, we want
-		  * to propagate the error back specifically for the disk
-		  * revalidation flow to make sure we don't abandon the
-		  * device just because of a temporal retry-able error (such
-		  * as path of transport errors).
-		  */
-		if (status > 0 && (status & NVME_SC_DNR) && !nvme_multi_css(ctrl))
-			status = 0;
  		goto free_data;
  	}
 
@@ -1888,7 +1876,9 @@ static int nvme_report_ns_ids(struct nvme_ctrl *ctrl, unsigned int nsid,
  		memcpy(ids->eui64, id->eui64, sizeof(id->eui64));
  	if (ctrl->vs >= NVME_VS(1, 2, 0))
  		memcpy(ids->nguid, id->nguid, sizeof(id->nguid));
-	if (ctrl->vs >= NVME_VS(1, 3, 0) || nvme_multi_css(ctrl))
+	if (nvme_multi_css(ctrl) ||
+	    (ctrl->vs >= NVME_VS(1, 3, 0) &&
+	     !(ctrl->quirks & NVME_QUIRK_NO_NS_DESC_LIST)))
  		return nvme_identify_ns_descs(ctrl, nsid, ids);
  	return 0;
  }
drivers/nvme/host/nvme.h +7 -0
index c5c1bac797aa5a..4cadaea9034ae4 100644
@@ -137,6 +137,13 @@ enum nvme_quirks {
  	 * Don't change the value of the temperature threshold feature
  	 */
  	NVME_QUIRK_NO_TEMP_THRESH_CHANGE	= (1 << 14),
+
+	/*
+	 * The controller doesn't handle the Identify Namespace
+	 * Identification Descriptor list subcommand despite claiming
+	 * NVMe 1.3 compliance.
+	 */
+	NVME_QUIRK_NO_NS_DESC_LIST		= (1 << 15),
  };
 
  /*
drivers/nvme/host/pci.c +0 -0
index 61e612d52d61d6..bac3a3f9c79e0d 100644
@@ -3181,6 +3181,8 @@ static const struct pci_device_id nvme_id_table[] = {
  	{ PCI_DEVICE(0x1cc1, 0x8201),   /* ADATA SX8200PNP 512GB */
  		.driver_data = NVME_QUIRK_NO_DEEPEST_PS |
  				NVME_QUIRK_IGNORE_DEV_SUBNQN, },
Quoted 9 lines

drivers/nvme/host/pci.c static const struct pci_device_id nvme_id_table[] = { · line 3188

Quoted 5 lines
drivers/nvme/host/pci.c +2 -0
+	{ PCI_DEVICE(0x126f, 0x2263),
+		.driver_data = NVME_QUIRK_NO_NS_DESC_LIST, },
  	{ PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_EXPRESS, 0xffffff) },
  	{ PCI_DEVICE(PCI_VENDOR_ID_APPLE, 0x2001),
  		.driver_data = NVME_QUIRK_SINGLE_VECTOR },

Thanks, the patch works. Maybe it is not too late to make its way into kernel 5.8.

Patch looks good, you can add my

on the formal patch.

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme