2
0
mirror of https://git.missingno.dev/kolibrios-nvme-driver/ synced 2024-11-10 02:20:27 +01:00

fix: initialize command mutexes correctly

This commit is contained in:
Abdur-Rahman Mansoor 2024-08-01 12:08:41 -04:00
parent 0cbf662a9f
commit d36f13f7af

View File

@ -750,11 +750,12 @@ proc nvme_init stdcall, pci:dword
invoke KernelAlloc, sizeof.MUTEX
test eax, eax
jz .exit_fail
mov dword [esi + ebx * NVMQCMD.mutex_ptr], eax
mov dword [esi + ebx * NVMQCMD.cid], ebx
mov dword [esi + NVMQCMD.mutex_ptr], eax
mov dword [esi + NVMQCMD.cid], ebx
mov ecx, eax
invoke MutexInit
inc ebx
add esi, sizeof.NVMQCMD
cmp ebx, CQ_ENTRIES
jne .init_cmd_entries
@ -1081,18 +1082,18 @@ proc sqytdbl_write stdcall, pci:dword, y:word, cmd:dword
movzx ebx, [y]
imul ebx, sizeof.NVM_QUEUE_ENTRY
lea edi, [edi + ebx]
;mov eax, dword [edi + NVM_QUEUE_ENTRY.cmd_ptr]
mov eax, dword [edi + NVM_QUEUE_ENTRY.cmd_ptr]
mov edx, dword [edi + NVM_QUEUE_ENTRY.sq_ptr]
mov esi, [cmd]
mov ecx, dword [esi + SQ_ENTRY.cdw0]
shr ecx, 16 ; Get CID
imul ecx, sizeof.SQ_ENTRY
lea edx, [edx + ecx]
;mov ecx, dword [eax + ecx + NVMQCMD.mutex_ptr]
;push ecx
mov ecx, dword [eax + ecx + NVMQCMD.mutex_ptr]
push ecx
stdcall memcpyd, edx, esi, sizeof.SQ_ENTRY / 4
;pop ecx
;invoke MutexLock
pop ecx
invoke MutexLock
mov esi, [pci]
movzx eax, word [edi + NVM_QUEUE_ENTRY.tail]