From f98d3b95b66a6ab6ac57280afb57183c4b44ee29 Mon Sep 17 00:00:00 2001 From: Abdur-Rahman Mansoor Date: Sat, 10 Aug 2024 13:05:28 -0400 Subject: [PATCH] fix: command wrapping --- drivers/nvme/nvme.asm | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/drivers/nvme/nvme.asm b/drivers/nvme/nvme.asm index 8d9814b..27f4173 100644 --- a/drivers/nvme/nvme.asm +++ b/drivers/nvme/nvme.asm @@ -1128,13 +1128,13 @@ proc sqytdbl_write stdcall, pci:dword, y:word, cmd:dword invoke MutexLock mov esi, [pci] - movzx eax, word [edi + NVM_QUEUE_ENTRY.tail] - cmp ax, (NVM_ASQS - 1) - jb @f + mov ax, word [edi + NVM_QUEUE_ENTRY.tail] + inc ax + cmp ax, NVM_ASQS + jb @f xor ax, ax @@: - inc ax ; 1000h + (2y * (4 << CAP.DSTRD)) movzx ebx, [y] shl ebx, 1 @@ -1194,30 +1194,17 @@ proc consume_cq_entries stdcall, pci:dword, queue:dword shl ecx, SIZEOF_NVM_QUEUE_ENTRY mov esi, dword [esi + pcidev.queue_entries] lea esi, [esi + ecx] - mov edi, dword [esi + NVM_QUEUE_ENTRY.cq_ptr] - movzx eax, word [esi + NVM_QUEUE_ENTRY.tail] movzx ecx, word [esi + NVM_QUEUE_ENTRY.head] - ;stdcall is_queue_full, eax, ecx - ;test eax, eax - ;jnz .end - movzx ecx, word [esi + NVM_QUEUE_ENTRY.head] - cmp ecx, (NVM_ACQS - 1) - jb .loop - xor ecx, ecx - mov word [esi + NVM_QUEUE_ENTRY.head], cx - -.loop: cmp cx, word [esi + NVM_QUEUE_ENTRY.tail] je .end - mov edx, ecx - shl edx, SIZEOF_CQ_ENTRY - mov ax, word [edi + edx + CQ_ENTRY.status] - ;DEBUGF DBG_INFO, "Status: 0x%x\n", ax - inc cx - push ecx + inc ecx + cmp ecx, NVM_ACQS + jb @f + xor ecx, ecx + mov word [esi + NVM_QUEUE_ENTRY.head], cx + +@@: stdcall cqyhdbl_write, [pci], [queue], ecx - pop ecx - jmp .loop .end: pop edi esi