Tech Support > Microsoft Windows > Drivers > Scatter/gather list with only one element
Scatter/gather list with only one element
Posted by alex on June 4th, 2008


Hi,
I have a PCI device with which I want to establish a DMA transfer. I
create a DEVICE_DESCRIPTION object with the following code:

DEVICE_DESCRIPTION DeviceDesc;
RtlZeroMemory(&DeviceDesc, sizeof(DEVICE_DESCRIPTION));
DeviceDesc.Version = DEVICE_DESCRIPTION_VERSION2;
DeviceDesc.Master = TRUE;
DeviceDesc.ScatterGather = TRUE;
DeviceDesc.Dma32BitAddresses = TRUE;
DeviceDesc.InterfaceType = PCIBus;
DeviceDesc.MaximumLength = sizeof(ULONG)-1;

Then I allocate a DMA adapter with IoGetDmaAdapter(). When I use
GetScatterGatherList() the list I receive in my AdapterListControl
function has always 1 element, regardless of the length of the transfer.
What could I do to understand what I'm doing wrong?

Ciao
Alessio

Posted by Maxim S. Shatskih on June 4th, 2008


Can you look at the MDL passed to GetScatterGatherList and its tail? what the
the physical page numbers?

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com


Posted by alex on June 5th, 2008


Maxim S. Shatskih wrote:

Looking at the fields of the MDL structure I see meaningful numbers,
such as:
StartVa: 2219864064
ByteOffset: 52
ByteCount: 40000

Is it possible that GetScatterGatherList() coalesces many elements in
one, i.e. if it has 10 contiguous physical pages it fills the structure
with one entry of length 40960?


Bye
Alex

Posted by Maxim S. Shatskih on June 5th, 2008


Surely.

Several 64bit (for PAE and x64 OS) or 32bit words just after struct _MDL, each
word describing 1 page.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com


Posted by alex on June 5th, 2008


Maxim S. Shatskih wrote:

DWORDs after the struct _MDL I see these page frame numbers:

8916
8920
8924
8928
8932

(in decimal representation)
They are regularly spaced, but they're not consecutive. What can I infer
about the physical memory layout?

Bye
Alex

Posted by Maxim S. Shatskih on June 6th, 2008


And what are the values in scatter-gather list?

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com


Posted by alex on June 9th, 2008


Maxim S. Shatskih wrote:
entirely clear to me what kind of relationship should there be between
page frame numbers in the MDL tail and the physical address in the
scatter/gather list. It seems like the numbers in the MDL tail represent
the last of a group of four pages, since physical address 36507660
should be contained in page 8913.

Bye
Alex

Posted by Ben Voigt [C++ MVP] on June 9th, 2008


alex wrote:
You requested a 80k transfer, with 5 blocks that would be 16k each. I seem
to recall that the page size on 32-bit Windows is 4k.



Posted by Maxim S. Shatskih on June 9th, 2008


Yes, and this is really strange.

MDL tail values are the physical addresses divided to PAGE_SIZE.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com



Similar Posts