-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@seagate.com
Sent: Tuesday, October 10, 2006 11:45 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Question about common buffer DMA
“Bus logical address” means an address that is valid in the address
space
on the bus. In most x86, that’s the same as physical address, but not
always. Systems with lots of PCI bridges can have multiple busses with
the
same “bus logical address” mapped into different memory addresses.
There
are a lot of other cases where the mapping is not 1 - 1.
Just stand on the notion that the OS gives you the addresses to program
your hardware with, use those address exclusively to program your
hardware,
and it also gives you VAs to use from the CPU, use those addresses
exclusively to access the buffer directly from the CPU, and you should
be
pretty safe.
As a rule, common buffer DMA is done when you want to queue commands (or
similar operations) to a device by just updating the command list in memory,
without writing to the device’s registers. Those commands often refer to
other ranges of memory which the device may separately read and write from
via DMA. This strategy can be very efficient.
The only time you’d want to copy data into a common buffer would be when
you’re also doing some transform on the data (like decryption, or some sort
of codec) using the main processor and you have to write it out somewhere
anyhow.
Jake Oshins
Windows Kernel Team
“Wu, Cody” wrote in message news:xxxxx@ntdev… Hi, all
I read a lot about common buffer DMA models recently and there is still one thing I am not sure about. Hopefully someone here can share with me your thoughts on it.
I know common DMA buffers needs to allocate a physically contiguous memory region for the communication between the device and the driver. I am just thinking that, if we are using common buffer devices, the user data would have to be copied from user-space memory to the common buffer first, and then set the relative control structure in the common buffer and program the hardware to initiate the real transfer. If that is the case, wouldn’t it be much more slowly than doing a direct memory copy since now we have to copy user data to common buffer before DMA transfer is started every time? Is this some sort of downside of using common buffer DMA?
By the way, I would be grateful is someone can recommend me some common buffer DMA adapters and I would like to read its datasheet for the implementation details. Thanks in advance for any of your explanations!!!
>case, wouldn’t it be much more slowly than doing a direct memory copy
since now we have to copy user data to common buffer before DMA transfer
is started every time? Is this some sort of downside of using common
buffer DMA?
No. Windows has 2 DMA facilities:
common buffers
passing MDLs to DMA (MapTransfer, Get/BuildScatterGatherList).
Usually, the IRP’s MDL which describes the user buffer is converted to SGL via
one of the aforementioned methods, then this SGL is converted to
hardware-defined form and put to common buffer as the “controller program” for
the peripheral. The peripheral then executes this “controller program”.
“Copy to common buffer” is rarely used, I think for AC97 audio (WavePci) only.
By the way, I would be grateful is someone can recommend me some common
buffer DMA adapters and I would like to read its datasheet for the
implementation details.
Intel IDE controller
UHCI or OHCI USB controllers
OHCI 1394 controller
at least the latter 2 specs (maybe drafts) are free for download.
> 33Mhz for example). AFAIK there is no way to DMA directly to user
allocated buffer
Pass Irp->MdlAddress to GetScatterGatherList (I personally would prefer
MapTransfer, and for a reason) - and then use these SGL start/length pairs to
program your hardware. This is zero-copy IO, and this is how, say,
IDE/SCSI/USB/1394 stacks work.
Thanks for your information. The people here are really nice and
helpful. Now my knowledge of common buffer is much much enriched.
Best regards,
Cody
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Maxim S.
Shatskih
Sent: Thursday, October 12, 2006 10:07 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Question about common buffer DMA
case, wouldn’t it be much more slowly than doing a direct memory copy
since now we have to copy user data to common buffer before DMA
transfer
is started every time? Is this some sort of downside of using common
buffer DMA?
No. Windows has 2 DMA facilities:
common buffers
passing MDLs to DMA (MapTransfer, Get/BuildScatterGatherList).
Usually, the IRP’s MDL which describes the user buffer is converted to
SGL via
one of the aforementioned methods, then this SGL is converted to
hardware-defined form and put to common buffer as the “controller
program” for
the peripheral. The peripheral then executes this “controller program”.
“Copy to common buffer” is rarely used, I think for AC97 audio (WavePci)
only.
By the way, I would be grateful is someone can recommend me some common
buffer DMA adapters and I would like to read its datasheet for the
implementation details.
Intel IDE controller
UHCI or OHCI USB controllers
OHCI 1394 controller
at least the latter 2 specs (maybe drafts) are free for download.
Even better, the adaptec 154x controller (their ISA) controller was an
ISA bus-master which could accept 17 entry SG lists. The 77xx was at
least an EISA controller.
-p
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Maxim S. Shatskih
Sent: Wednesday, October 11, 2006 7:12 PM
To: Windows System Software Devs Interest List
Subject: Re: Re:[ntdev] Question about common buffer DMA
devices. Servers with UltraScsi 320 all use SG (scatter/gather) lists.
Even Adaptec 77xx - not even 78xx - used SGLs. This hardware is dated
1994 I
think.
>>“Copy to common buffer” is rarely used, I think for AC97 audio (WavePci) only.<<
Actually, that would be WaveCyclic.
WavePci builds SGL and sends the entries to the miniport as it asks for them.
WaveRT (new for Vista) is essentially common buffer, but the “copy to / from common buffer” is done in user mode [by the audio service], and not by anything in the kernel.
For XP and up, both are supported. Vista also supports WaveRT. The last time I looked at the sample driver, I believe it included code for both. But hardly ever touched it (don’t generally use samples).
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Maxim S. Shatskih
Sent: Saturday, October 14, 2006 1:55 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Question about common buffer DMA
>“Copy to common buffer” is rarely used, I think for AC97 audio (WavePci)
only.<<
Actually, that would be WaveCyclic.
WavePci builds SGL and sends the entries to the miniport as it asks for them.
Is the AC97-family driver template - WaveCyclic or WavePci?
I checked the samples on my machine- 2K3SP1 DDK uses a WavePci miniport, WDK uses both Pci and RT.
The XP one is definitely WavePci- calls GetMapping / ReleaseMapping (which is where the port driver manages the SGL entries on behalf of the miniport).