Skip to content

Commit 328ca36

Browse files
committed
Use PAGE_SIZE instead of SG_ELEMENT_MIN.
1 parent a5df17a commit 328ca36

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

hal/halx86/generic/dma.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,6 @@ typedef struct _SCATTER_GATHER_CONTEXT {
981981
} SCATTER_GATHER_CONTEXT, *PSCATTER_GATHER_CONTEXT;
982982

983983
#define MAX_SG_ELEMENTS 0x30
984-
#define SG_ELEMENT_MIN 4096 // Minimum bytes in a S/G element
985984

986985
IO_ALLOCATION_ACTION
987986
NTAPI
@@ -996,9 +995,10 @@ HalpScatterGatherAdapterControl(IN PDEVICE_OBJECT DeviceObject,
996995
PSCATTER_GATHER_ELEMENT TempElements;
997996
ULONG ElementCount = 0, RemainingLength = AdapterControlContext->Length;
998997
PUCHAR CurrentVa = AdapterControlContext->CurrentVa;
999-
// RemainingLength / Minimum BYTES in S/G element
1000-
// + 1 for remainder of division + 1 for a safety cushion
1001-
ULONG Est_SG_Elements = min(RemainingLength / SG_ELEMENT_MIN + 2, MAX_SG_ELEMENTS);
998+
// RemainingLength / PAGE_SIZE + 1 for the remainder of our division
999+
// + 1 for a safety cushion gives a good safe value. Using the
1000+
// min function with MAX_SG_ELEMENTS keeps us from getting too large.
1001+
ULONG Est_SG_Elements = min(RemainingLength / PAGE_SIZE + 2, MAX_SG_ELEMENTS);
10021002

10031003
/* Store the map register base for later in HalPutScatterGatherList */
10041004
AdapterControlContext->MapRegisterBase = MapRegisterBase;

0 commit comments

Comments
 (0)