nvme: fix command ID wraparound handling

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>
This commit is contained in:
Prashant Kamble
2026-05-18 11:38:44 +05:30
committed by Neil Armstrong
parent 49f8b8de4e
commit d6eb327828

View 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)