[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
This commit is contained in:
Atharva Kulkarni 2023-04-21 16:14:31 +05:30 committed by GitHub
parent 6eb8fe4f82
commit 6eee9f9daf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -653,7 +653,6 @@ SpiProcessCompletedRequest(
PSCSI_PORT_LUN_EXTENSION LunExtension; PSCSI_PORT_LUN_EXTENSION LunExtension;
LONG Result; LONG Result;
PIRP Irp; PIRP Irp;
//ULONG SequenceNumber;
Srb = SrbInfo->Srb; Srb = SrbInfo->Srb;
Irp = Srb->OriginalRequest; Irp = Srb->OriginalRequest;
@ -681,10 +680,25 @@ SpiProcessCompletedRequest(
} }
/* Flush adapter if needed */ /* Flush adapter if needed */
if (SrbInfo->BaseOfMapRegister) if (SrbInfo->BaseOfMapRegister && SrbInfo->ScatterGather)
{ {
/* TODO: Implement */ ULONG transferLen = 0;
ASSERT(FALSE); 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 */ /* Clear the request */
@ -718,8 +732,16 @@ SpiProcessCompletedRequest(
/* Scatter/gather */ /* Scatter/gather */
if (Srb->SrbFlags & SRB_FLAGS_SGLIST_FROM_POOL) if (Srb->SrbFlags & SRB_FLAGS_SGLIST_FROM_POOL)
{ {
/* TODO: Implement */ ExFreePoolWithTag(SrbInfo->ScatterGather, TAG_SCSIPORT);
ASSERT(FALSE); SrbInfo->ScatterGather = NULL;
}
/* Free Map Registers */
if (SrbInfo->NumberOfMapRegisters)
{
IoFreeMapRegisters(DeviceExtension->AdapterObject,
SrbInfo->BaseOfMapRegister,
SrbInfo->NumberOfMapRegisters);
} }
/* Acquire spinlock (we're freeing SrbExtension) */ /* Acquire spinlock (we're freeing SrbExtension) */