]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
nvme: fix command ID wraparound handling
authorPrashant Kamble <prashant.kamble223@gmail.com>
Mon, 18 May 2026 06:08:44 +0000 (11:38 +0530)
committerNeil Armstrong <neil.armstrong@linaro.org>
Wed, 20 May 2026 07:44:37 +0000 (09:44 +0200)
nvme_get_cmd_id() returns 0 after cmdid reaches USHRT_MAX,
but fails to reset cmdid itself. As a result, all subsequent
calls keep returning 0 indefinitely.

Reset cmdid when wraparound occurs so command IDs continue
incrementing correctly.

Signed-off-by: Prashant Kamble <prashant.kamble223@gmail.com>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Link: https://patch.msgid.link/20260518060915.45607-1-prashant.kamble223@gmail.com
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
drivers/nvme/nvme.c

index 2b14437f69c2a42a6acd82125f259957c8111dad..4f9473367d3ccb63fed78bea19d91898534d73ec 100644 (file)
@@ -112,7 +112,10 @@ static __le16 nvme_get_cmd_id(void)
 {
        static unsigned short cmdid;
 
-       return cpu_to_le16((cmdid < USHRT_MAX) ? cmdid++ : 0);
+       if (cmdid >= USHRT_MAX)
+               cmdid = 0;
+
+       return cpu_to_le16(cmdid++);
 }
 
 static u16 nvme_read_completion_status(struct nvme_queue *nvmeq, u16 index)