nvme: fix command ID wraparound handling
PATCH 1/1 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.
--- drivers/nvme/nvme.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/nvme/nvme.c +4 -1
@@ -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)
Signature · 1 line
2.43.0
Quoted 18 lines · Prashant Kamble
nvme_get_cmd_id()returns 0 after cmdid reachesUSHRT_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 <[email protected]>--- drivers/nvme/nvme.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/nvme/nvme.c +0
-0@@ -112,7 +112,10 @@ static __le16 nvme_get_cmd_id(void) {
drivers/nvme/nvme.c static __le16 nvme_get_cmd_id(void) · line 121
Quoted 10 lines
drivers/nvme/nvme.c +4
-1static 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)
Thanks,
Neil
Hi,
Quoted 8 lines · Prashant Kamble
nvme_get_cmd_id()returns 0 after cmdid reachesUSHRT_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.
[...]
Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-ufs (u-boot-nvme-fixes)
[1/1] nvme: fix command ID wraparound handling
https://source.denx.de/u-boot/custodians/u-boot-ufs/-/commit/d6eb327828a384c3bf325de05633a77f66688f53
Signature · 1 line
Neil