Scatter-gather DMA vs. Map Registers

Hi all,

I think it’s the right place to post such a question.
If I’m wrong, please excuse-me…

Is it possible to avoid using a hardware scatter-gather DMA engine by replacing it with the use of Map Registers ?
In fact, I want to perform DMA transfers between a PCI-Express memory (that is physically contiguous) and a Windows user buffer (that is physically scattered).
Can the driver allocate map registers for this user buffer, so that the DMA engine has only one source address, one destination address and one size to manage ?

Thank you.
Best regards,
Vincent

This is definitely the right place for your question, but I’m not sure I understand what you’re asking.

In summary:
Map Registers are an architectural abstraction supported by Windows. It is up to the HAL and the Bus Drivers how they implement this architectural abstraction… on x86 systems (at least conventional ones) there ARE no hardware map registers, but the HAL and the PCI Bus Driver work together to provide a “System Scatter/Gather” facility that makes it APPEAR that there are hardware map registers. In this case, a driver will get only a single Base Address and Length even when there’s a physically fragmented user data buffer… because Windows will in fact intermediately buffer your data transfer in a physically contiguous data buffer automagically.

How the HAL/Bus Drivers support your driver is all controlled by the support you claim to have when you get your DMA Adapter. If you describe your device as supporting hardware Scatter/Gather, then you’ll get a Physical Address and Length for each physically contiguous chunk of the user data buffer.

If you don’t WANT this, just indicate that your hardware does NOT support Scatter/Gather… then Windows will provide you System Scatter/Gather support.

Simple, right?

Peter
OSR

Peter,

Thank you, your answer is clearer than my question !

“there ARE no hardware map registers”
It means that if I claim that my hardware doesn’t support hardware scatter-gather DMA, then :

  1. Windows will allocate a physically contiguous kernel buffer
  2. My driver will DMA the data inside this buffer using a direct/block DMA
  3. Upon DMA termination, Windows will memcpy the data from the physically contiguous kernel buffer to the physically scattered user buffer
  4. Windows will free the physically contiguous system buffer

So, if my hardware supports scatter-gather DMA, then I should use it to save CPU time by avoiding useless memcpy.
The reason for my question was : as I’m lazy and prone to errors, I wanted to program only direct/block DMA instead of scatter-gather DMA :wink:
Those map registers would be a great idea to implement in hardware !

Thanks a lot.
Best regards,
Vincent

> 1. Windows will allocate a physically contiguous kernel buffer

  1. My driver will DMA the data inside this buffer using a direct/block DMA
  2. Upon DMA termination, Windows will memcpy the data from the physically contiguous kernel
    buffer to the physically scattered user buffer

Yes, exactly so. Just set ScatterGather to FALSE in DEVICE_DESCRIPTION.

So, if my hardware supports scatter-gather DMA, then I should use it to save CPU time by avoiding
useless memcpy.

Yes.

Those map registers would be a great idea to implement in hardware !

Some modern chipsets have IOMMUs in them.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

xxxxx@cea.fr wrote:

So, if my hardware supports scatter-gather DMA, then I should use it to save CPU time by avoiding useless memcpy.

Definitely, and consider yourself lucky. :wink:

The reason for my question was : as I’m lazy and prone to errors, I wanted to program only direct/block DMA instead of scatter-gather DMA :wink:
Those map registers would be a great idea to implement in hardware !

That’s more or less what the AGP GART does.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.