[PATCH] nvme-pci: ignore bogus CRTO according to NVME 2.0 spec

Keith Busch kbusch at kernel.org
Mon Sep 11 16:16:09 PDT 2023


On Mon, Sep 11, 2023 at 04:00:42PM -0700, Keith Busch wrote:
> @@ -2257,12 +2258,15 @@ int nvme_enable_ctrl(struct nvme_ctrl *ctrl)
>  
>  		if (ctrl->cap & NVME_CAP_CRMS_CRIMS) {
>  			ctrl->ctrl_config |= NVME_CC_CRIME;
> -			timeout = NVME_CRTO_CRIMT(crto);
> +			/*
> +			 * CRIMT should always be greater or equal to CAP.TO,
> +			 * but some devices are known to get this wrong. Use
> +			 * the larger of the two values.
> +			 */
> +			timeout = max(timeout, NVME_CRTO_CRIMT(crto));
>  		} else {
>  			timeout = NVME_CRTO_CRWMT(crto);
>  		}

Er... please pretend I added the "max()" handling in the 'else' case
instead of the CRIMS case.

-- >8 --
@@ -2259,10 +2260,13 @@ int nvme_enable_ctrl(struct nvme_ctrl *ctrl)
 			ctrl->ctrl_config |= NVME_CC_CRIME;
 			timeout = NVME_CRTO_CRIMT(crto);
 		} else {
-			timeout = NVME_CRTO_CRWMT(crto);
+			/*
+			 * CRWMT should always be greater or equal to CAP.TO,
+			 * but some devices are known to get this wrong. Use
+			 * the larger of the two values.
+			 */
+			timeout = max(timeout, NVME_CRTO_CRWMT(crto));
 		}



More information about the Linux-nvme mailing list