Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Scatter/gather list with only one element

0 views
Skip to first unread message

alex

unread,
Jun 4, 2008, 10:02:43 AM6/4/08
to
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

Maxim S. Shatskih

unread,
Jun 4, 2008, 11:52:58 AM6/4/08
to
> 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.

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
ma...@storagecraft.com
http://www.storagecraft.com

alex

unread,
Jun 5, 2008, 3:23:51 AM6/5/08
to
Maxim S. Shatskih wrote:
>> 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.
>
> Can you look at the MDL passed to GetScatterGatherList and its tail?
I'm not sure I know what the MDL tail is. How can I inspect it?

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?

> what the the physical page numbers?

How can I find the physical page numbers in the MDL?

Bye
Alex

Maxim S. Shatskih

unread,
Jun 5, 2008, 4:06:55 AM6/5/08
to
> 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?

Surely.

> > what the the physical page numbers?
> How can I find the physical page numbers in the MDL?

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

alex

unread,
Jun 5, 2008, 10:42:25 AM6/5/08
to
Maxim S. Shatskih wrote:

>>> what the the physical page numbers?
>> How can I find the physical page numbers in the MDL?
>
> Several 64bit (for PAE and x64 OS) or 32bit words just after struct _MDL, each
> word describing 1 page.

Ok, did a transfer of 81920 bytes and looking at the first 5 32 bit
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

Maxim S. Shatskih

unread,
Jun 6, 2008, 5:11:48 PM6/6/08
to
> 8916
> 8920
> 8924
> 8928
> 8932
>
> (in decimal representation)
> They are regularly spaced, but they're not consecutive.

And what are the values in scatter-gather list?

Ben Voigt [C++ MVP]

unread,
Jun 9, 2008, 9:38:46 AM6/9/08
to

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.

>
> Bye
> Alex


alex

unread,
Jun 9, 2008, 9:29:38 AM6/9/08
to
Maxim S. Shatskih wrote:
>> 8916
>> 8920
>> 8924
>> 8928
>> 8932
>>
>> (in decimal representation)
>> They are regularly spaced, but they're not consecutive.
>
> And what are the values in scatter-gather list?
I get one element with address 36507660 and length 81920. It's not
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

Maxim S. Shatskih

unread,
Jun 9, 2008, 3:26:08 PM6/9/08
to
> 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.

Yes, and this is really strange.

MDL tail values are the physical addresses divided to PAGE_SIZE.

0 new messages