dma_sync_sg_for_device

Am in the process of porting linux driver to Windows. During that I came across this dma_sync_sg_for_device() Routine.

I have tried to look for its usage and its corresponding implementation in Windows.

But, I didn’t get much information about this routine.

Do anyone knows its usage and correponding Routine in windows to achieve it.

All Windows DMA stuff is:

  • the concept of MDLs
  • DMA adapter object, which you retrieve by IoGetDmaAdapter (or KMDF wrappers) and its methods like ->GetScatterGatherList


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com

wrote in message news:xxxxx@ntdev…
> Am in the process of porting linux driver to Windows. During that I came across this dma_sync_sg_for_device() Routine.
>
>
> I have tried to look for its usage and its corresponding implementation in Windows.
>
> But, I didn’t get much information about this routine.
>
> Do anyone knows its usage and correponding Routine in windows to achieve it.
>

xxxxx@gmail.com wrote:

Am in the process of porting linux driver to Windows. During that I came across this dma_sync_sg_for_device() Routine.

I have tried to look for its usage and its corresponding implementation in Windows.

But, I didn’t get much information about this routine.

Do anyone knows its usage and correponding Routine in windows to achieve it.

Do you understand what the function does and why one needs it? If not,
then it’s going to be quite difficult for you to find out anything.

The issue is that, on some CPU and bus architectures, DMA operations
bypass the processor caches. So, if you had previously read data from
memory, and then did a DMA that wrote into that memory, your next read
might get stale data from the cache instead of reading fresh data from
memory. This page describes how to use KeFlushIoBuffers and
FlushAdapterBuffers to protect against that:

https://msdn.microsoft.com/en-us/library/windows/hardware/ff545924.aspx

Many architectures are cache-coherent, so that these routines do nothing
(and if you look in the Linux source you’ll see dma_sync_sg_for_device
and dma_sync_sg_for_cpu also often do nothing), but you need them.


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

https://www.osr.com/blog/2014/04/04/dma-cache-coherent-arm/

Peter
OSR
@OSRDrivers