Re: Do I need a WdfDmaTransaction before accessing a Common Buffer?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Tim Roberts schrieb:
Charles Gardiner <invalid@xxxxxxxxxxxxxxx> wrote:
Just for clarification: I see I mixed the terms common-buffer/circular
buffer at least twice below.
Correct is, the data set is written to a _circular_ buffer (in user
space).

How did you lock that buffer into memory, and how did you get the physical
address?

I locked the user-space circular buffer into memory by pending the
request indefinitely. Then, obtained the physical addresses by

-1- setting up a WdfDmaTransaction
(WdfDmaTransactionInitializeUsingRequest)

-2- Executing the Dma Transaction (WdfDmaTransactionExecute)

-3- Taking the S/G list(s) passed to the EvtProgramDma callback and
storing these in a buffer. They are then cyclically passed to my DMA
hardware.

My real issue is the _common-buffer_ (WDFCOMMONBUFFER object) which is
made up of 'n' structures each describing 'n' circular buffers as
desribed above. One of the structure elements (a single ULONG) is
written by the DMA hardware everytime it writes a block to a circular
buffer and contains the last location written (circular buffer offset).
Initially, I obtained the logical addresses to the common-buffer by
calling WdfCommonBufferGetAlignedLogicalAddress, computed the offsets to
the structure elements and just set this address up in the hardware as
target address of the offset recorder. This solution blue-screened on
me. Next, I tried getting the Mdl to the common-buffer using
IoAllocateMdl and based on the result of
WdfCommonBufferGetAlignedVirtualAddress. Strangely, this approach worked
as long as the Mdl was below 4Gbytes. If it ended up to be above
4Gbytes, this solution blue screened on me too. (My hardware can
generate 48 bit addresses)

What I now do is:
-1- set up an additional DMA transaction to the common buffer using
WdfDmaTransactionInitialize

-2- Get the Mdl to the WDFCOMMONBUFFER by calling
WdfCommonBufferGetAlignedVirtualAddress and IoAllocateMdl.
I now never use these values but WdfDmaTransactionInitialize requires an
Mdl in one of it's parameters and this is the most 'related' Mdl, IMHO.

-3- In the EvtProgramDma callback to this (common buffer) DMA
transaction, compute the offset to the required common buffer structure
element based on the result from
WdfCommonBufferGetAlignedLogicalAddress, and pass this to the hardware.
(i.e. just ignore the S/G list passed to EvtProgramDma)

This solution has now been running for several hours so I assume it's
ok. My resumee: KMDF is missing a
'WdfDmaTransactionInitializeUsingCommonBuffer' call or something similar.
.



Relevant Pages

  • Re: Ring buffers
    ... CIRCULAR 1+ +; ... In the original system I coded this in 8051 assembler for speed. ... average over the last n entries in the buffer, ... CREATE CIRCULAR 128 4 CELLS * CELL+ ALLOT ...
    (comp.lang.forth)
  • Re: Wait free writer/lock free reader on POD struct. Guaranteeing integrity ?
    ... There are several implementations of lock-free circular ... In fact I have several independant structures in the array. ... I guess I could have an array of circular buffer. ... chance of contention on my reader. ...
    (comp.programming.threads)
  • Re: circular addressing implementation
    ... had a special instruction to manage addressing circular buffers. ... > buffer every time a new input sample is available. ... > buffer size to a power of two and use a logical AND on the input index instead ...
    (comp.dsp)
  • Re: Circular addressing mode in TI C64x+
    ... local buffer and then carry out the processing? ... efficiently generate circular addresses. ... The DSP detects the ...
    (comp.dsp)
  • Re: Do I need a WdfDmaTransaction before accessing a Common Buffer?
    ... You shouldn't need to be performing DMA transactions to use the CommonBuffer, that is the purpose of using a Common Buffer. ... In step 3 of your current solution, do the addresses from your S/G list and WdfCommonBufferGetAlignedLogicalAddress match up? ...
    (microsoft.public.development.device.drivers)