https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6eee9f9daf8aa3260e8682...
commit 6eee9f9daf8aa3260e868291c5e32f1b8eee0d70 Author: Atharva Kulkarni atharvak1910@gmail.com AuthorDate: Fri Apr 21 16:14:31 2023 +0530 Commit: GitHub noreply@github.com CommitDate: Fri Apr 21 12:44:31 2023 +0200
[SCSIPORT] Flush and Free Map Registers (#5190)
- Flush Map registers once the DMA completes - Free Map registers once the DMA completes - Add support for SGL allocated from NonPagedPool
Test: Force Allocations of SGL from Non Paged Pool and ensure OS boots and functions properly
Test Logs: SpiAdapterControlFORCING ALLOCATION FROM SGPOOL SpiAdapterControlFORCING ALLOCATION FROM SGPOOL SpiAdapterControlFORCING ALLOCATION FROM SGPOOL SpiAdapterControlFORCING ALLOCATION FROM SGPOOL SpiAdapterControlFORCING ALLOCATION FROM SGPOOL SpiAdapterControlFORCING ALLOCATION FROM SGPOOL DHCPCSVC: Adapter Name: [{7cd69ac0-dabb-410a-b927-cb3961d174da}] (dynamic) SpiAdapterControlFORCING ALLOCATION FROM SGPOOL WARNING: HalCalculateScatterGatherListSize at hal\halx86\generic\dma.c:1168 is UNIMPLEMENTED! SpiAdapterControlFORCING ALLOCATION FROM SGPOOL SpiAdapterControlFORCING ALLOCATION FROM SGPOO --- drivers/storage/port/scsiport/scsi.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-)
diff --git a/drivers/storage/port/scsiport/scsi.c b/drivers/storage/port/scsiport/scsi.c index 056e2bb8328..42efbeca821 100644 --- a/drivers/storage/port/scsiport/scsi.c +++ b/drivers/storage/port/scsiport/scsi.c @@ -653,7 +653,6 @@ SpiProcessCompletedRequest( PSCSI_PORT_LUN_EXTENSION LunExtension; LONG Result; PIRP Irp; - //ULONG SequenceNumber;
Srb = SrbInfo->Srb; Irp = Srb->OriginalRequest; @@ -681,10 +680,25 @@ SpiProcessCompletedRequest( }
/* Flush adapter if needed */ - if (SrbInfo->BaseOfMapRegister) + if (SrbInfo->BaseOfMapRegister && SrbInfo->ScatterGather) { - /* TODO: Implement */ - ASSERT(FALSE); + ULONG transferLen = 0; + BOOLEAN isWrite = !!(Srb->SrbFlags & SRB_FLAGS_DATA_OUT); + ULONG i; + + for (i = 0; + i < SrbInfo->NumberOfMapRegisters && transferLen < Srb->DataTransferLength; + i++) + { + transferLen += SrbInfo->ScatterGather[i].Length; + } + + IoFlushAdapterBuffers(DeviceExtension->AdapterObject, + Irp->MdlAddress, + SrbInfo->BaseOfMapRegister, + Srb->DataBuffer, + transferLen, + isWrite); }
/* Clear the request */ @@ -718,8 +732,16 @@ SpiProcessCompletedRequest( /* Scatter/gather */ if (Srb->SrbFlags & SRB_FLAGS_SGLIST_FROM_POOL) { - /* TODO: Implement */ - ASSERT(FALSE); + ExFreePoolWithTag(SrbInfo->ScatterGather, TAG_SCSIPORT); + SrbInfo->ScatterGather = NULL; + } + + /* Free Map Registers */ + if (SrbInfo->NumberOfMapRegisters) + { + IoFreeMapRegisters(DeviceExtension->AdapterObject, + SrbInfo->BaseOfMapRegister, + SrbInfo->NumberOfMapRegisters); }
/* Acquire spinlock (we're freeing SrbExtension) */