mirror of
https://github.com/reactos/reactos.git
synced 2026-06-10 01:42:56 +08:00
[HALX86:DMA] HACK: Avoid excessive stack usage
CORE-17256
This commit is contained in:
committed by
Carl J. Bialorucki
parent
bd33d627b7
commit
5418987cb8
@@ -77,7 +77,8 @@
|
|||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#define MAX_SG_ELEMENTS 0x10
|
// FIXME: This value needs to be calculated at runtime
|
||||||
|
#define MAX_SG_ELEMENTS 0x20
|
||||||
|
|
||||||
#ifndef _MINIHAL_
|
#ifndef _MINIHAL_
|
||||||
static KEVENT HalpDmaLock;
|
static KEVENT HalpDmaLock;
|
||||||
@@ -993,13 +994,24 @@ HalpScatterGatherAdapterControl(IN PDEVICE_OBJECT DeviceObject,
|
|||||||
PSCATTER_GATHER_CONTEXT AdapterControlContext = Context;
|
PSCATTER_GATHER_CONTEXT AdapterControlContext = Context;
|
||||||
PADAPTER_OBJECT AdapterObject = AdapterControlContext->AdapterObject;
|
PADAPTER_OBJECT AdapterObject = AdapterControlContext->AdapterObject;
|
||||||
PSCATTER_GATHER_LIST ScatterGatherList;
|
PSCATTER_GATHER_LIST ScatterGatherList;
|
||||||
SCATTER_GATHER_ELEMENT TempElements[MAX_SG_ELEMENTS];
|
PSCATTER_GATHER_ELEMENT TempElements;
|
||||||
ULONG ElementCount = 0, RemainingLength = AdapterControlContext->Length;
|
ULONG ElementCount = 0, RemainingLength = AdapterControlContext->Length;
|
||||||
PUCHAR CurrentVa = AdapterControlContext->CurrentVa;
|
PUCHAR CurrentVa = AdapterControlContext->CurrentVa;
|
||||||
|
|
||||||
/* Store the map register base for later in HalPutScatterGatherList */
|
/* Store the map register base for later in HalPutScatterGatherList */
|
||||||
AdapterControlContext->MapRegisterBase = MapRegisterBase;
|
AdapterControlContext->MapRegisterBase = MapRegisterBase;
|
||||||
|
|
||||||
|
// FIXME: HACK Allocate TempElements from pool to minimize stack usage.
|
||||||
|
// A more efficient algorithm should be found to avoid allocations during S/G I/O operations.
|
||||||
|
TempElements = ExAllocatePoolUninitialized(NonPagedPool,
|
||||||
|
sizeof(*TempElements) * MAX_SG_ELEMENTS,
|
||||||
|
TAG_DMA);
|
||||||
|
if (!TempElements)
|
||||||
|
{
|
||||||
|
DPRINT1("Scatter/gather list construction failed!\n");
|
||||||
|
return DeallocateObject;
|
||||||
|
}
|
||||||
|
|
||||||
while (RemainingLength > 0 && ElementCount < MAX_SG_ELEMENTS)
|
while (RemainingLength > 0 && ElementCount < MAX_SG_ELEMENTS)
|
||||||
{
|
{
|
||||||
TempElements[ElementCount].Length = RemainingLength;
|
TempElements[ElementCount].Length = RemainingLength;
|
||||||
@@ -1025,6 +1037,7 @@ HalpScatterGatherAdapterControl(IN PDEVICE_OBJECT DeviceObject,
|
|||||||
if (RemainingLength > 0)
|
if (RemainingLength > 0)
|
||||||
{
|
{
|
||||||
DPRINT1("Scatter/gather list construction failed!\n");
|
DPRINT1("Scatter/gather list construction failed!\n");
|
||||||
|
ExFreePoolWithTag(TempElements, TAG_DMA);
|
||||||
return DeallocateObject;
|
return DeallocateObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1039,6 +1052,8 @@ HalpScatterGatherAdapterControl(IN PDEVICE_OBJECT DeviceObject,
|
|||||||
TempElements,
|
TempElements,
|
||||||
sizeof(SCATTER_GATHER_ELEMENT) * ElementCount);
|
sizeof(SCATTER_GATHER_ELEMENT) * ElementCount);
|
||||||
|
|
||||||
|
ExFreePoolWithTag(TempElements, TAG_DMA);
|
||||||
|
|
||||||
DPRINT("Initiating S/G DMA with %d element(s)\n", ElementCount);
|
DPRINT("Initiating S/G DMA with %d element(s)\n", ElementCount);
|
||||||
|
|
||||||
AdapterControlContext->AdapterListControlRoutine(DeviceObject,
|
AdapterControlContext->AdapterListControlRoutine(DeviceObject,
|
||||||
|
|||||||
Reference in New Issue
Block a user