Skip to contentSkip to conversation

nvme-fabrics: handle zero MAXCMD without closing the connection

PATCH Superseded Maurizio Lombardi 3 participants 3 messages Nov 29, 2024 – Dec 3, 2024 NVMe

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvme-fabrics: handle zero MAXCMD without closing the connection

The NVMe specification states that MAXCMD is mandatory
for NVMe-over-Fabrics implementations. However, some NVMe/TCP and NVMe/FC arrays from major vendors have buggy firmware that reports MAXCMD as zero in the Identify Controller data structure.

Currently, the implementation closes the connection in such cases, completely preventing the host from connecting to the target.

Fix the issue by printing a clear error message about the firmware bug and allowing the connection to proceed. It assumes that the target supports a MAXCMD value of SQSIZE + 1. If any issues arise, the user can manually adjust SQSIZE to mitigate them.

Fixes 4999568184e5 ("nvme-fabrics: check max outstanding commands")
---
 drivers/nvme/host/core.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/nvme/host/core.c +3 -2
index 1a8d32a4a5c3..91ee2c3aa95e 100644
@@ -3257,8 +3257,9 @@ static int nvme_check_ctrl_fabric_info(struct nvme_ctrl *ctrl, struct nvme_id_ct
 	}
 
 	if (!ctrl->maxcmd) {
-		dev_err(ctrl->device, "Maximum outstanding commands is 0\n");
-		return -EINVAL;
+		dev_err(ctrl->device,
+			"Firmware bug: maximum outstanding commands is 0\n");
+		ctrl->maxcmd = ctrl->sqsize + 1;
 	}
 
 	return 0;
Signature · 1 line
2.43.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 32 lines · Maurizio Lombardi

The NVMe specification states that MAXCMD is mandatory for NVMe-over-Fabrics implementations. However, some NVMe/TCP and NVMe/FC arrays from major vendors have buggy firmware that reports MAXCMD as zero in the Identify Controller data structure.

Currently, the implementation closes the connection in such cases, completely preventing the host from connecting to the target.

Fix the issue by printing a clear error message about the firmware bug
and allowing the connection to proceed. It assumes that the target supports a MAXCMD value of SQSIZE + 1. If any issues arise, the user can manually adjust SQSIZE to mitigate them.

Fixes 4999568184e5 ("nvme-fabrics: check max outstanding commands")

---
 drivers/nvme/host/core.c | 5 +++--

 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/nvme/host/core.c +0 -0
index 1a8d32a4a5c3..91ee2c3aa95e 100644
@@ -3257,8 +3257,9 @@ static int nvme_check_ctrl_fabric_info(struct

nvme_ctrl *ctrl, struct nvme_id_ct
        }

        if (!ctrl->maxcmd) {
-               dev_err(ctrl->device, "Maximum outstanding commands is 0\n");

Quoted 8 lines

-               return -EINVAL;
+               dev_err(ctrl->device,
+                       "Firmware bug: maximum outstanding commands is 0\n");
+               ctrl->maxcmd = ctrl->sqsize + 1;
        }

        return 0;

A similar fix was tested by a customer seeing this issue and they can now connect to their array again.
Looks good.

#2 lore raw
In reply to Maurizio Lombardi
Quoted 4 lines · Maurizio Lombardi

The NVMe specification states that MAXCMD is mandatory
for NVMe-over-Fabrics implementations. However, some NVMe/TCP and NVMe/FC arrays from major vendors have buggy firmware that reports MAXCMD as zero in the Identify Controller data structure.

Sigh.

drivers/nvme/host/core.c static int nvme_check_ctrl_fabric_info(struct nvme_ctrl *ctrl, struct nvme_id_ct · line 3262

Quoted 6 lines
drivers/nvme/host/core.c +3 -2
 	if (!ctrl->maxcmd) {
-		dev_err(ctrl->device, "Maximum outstanding commands is 0\n");
-		return -EINVAL;
+		dev_err(ctrl->device,
+			"Firmware bug: maximum outstanding commands is 0\n");
+		ctrl->maxcmd = ctrl->sqsize + 1;

Maybe warn instead of err as made it not an error now? Otherwise looks fine.