I need to perform DMA for 8 bytes for which i've failed.
I've followed the following sequence.
pMem = MmAllocateContiguousMemory(8, HighAddress)
if((pMem == NULL) || FdoData == NULL)
{
TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP,
"pcial_dma_transfer() FAILED pMem || FdoData = NULL\n");
return !STATUS_SUCCESS;
}
pMdl = IoAllocateMdl(pMem , 8, FALSE, TRUE, NULL);
if (pMdl == NULL)
{
TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP,
"IoAllocateMdl FAILED\n");
return !STATUS_SUCCESS;
}
DmaDirection = (rw == DMARW_CNL_TO_HOST) ?
WdfDmaDirectionReadFromDevice:
WdfDmaDirectionWriteToDevice;
status = WdfDmaTransactionCreate( FdoData->WdfDmaEnabler,
WDF_NO_OBJECT_ATTRIBUTES,
&dmaTransaction );
if(status == STATUS_SUCCESS)
TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP,
"WdfDmaTransactionCreate SUCCESS\n");
else
TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP,
"WdfDmaTransactionCreate ERROR\n");
status = WdfDmaTransactionInitialize(
dmaTransaction,
ProgramDmaFunction,
DmaDirection,
pMdl,
pMem,
length);
if(status == STATUS_SUCCESS)
TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP,
"WdfDmaTransactionInitialize SUCCESS\n");
else
{
TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP,
"WdfDmaTransactionInitialize ERROR status=0x%x\n",status);
return status;
}
status = WdfDmaTransactionExecute( dmaTransaction, NULL);
if(status == STATUS_SUCCESS)
{
TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP,
"WdfDmaTransactionExecute SUCCESS\n");
}
else
TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP,
"WdfDmaTransactionExecute ERROR\n");
Where in the ProgramDmaFunction(), i've initiated h/w DMA operations by
fetching the physical address from the input
scatter gather list element, poll for DMA completion interrupt bit &
complete the DMA with wdfdmacompletedfinal & released
the dmatransaction.
After this sequence, when i checked the value of pMem, it remains unchanged
as zero which is not my expected value.
I have the following questions related with it.
1. Can we perform DMA for 8 bytes using dmatransaction ?( I have no other
option of PIO since my h/w design is in such a way, that supports only DMA)
2. What is wrong in the above mentioned sequence ?
3. Is it mandatory to call WdfDmaTransactionDmaCompleted in DPC handler ? [
Right now, i've some problem with the interrupt, so only polling mode is used)
4. I won't initiate DMA on the context of a wdfrequest, so i can't use
WdfDmaTransactionInitializeUsingRequest(), will it be an issue ? [ This is
because all the sample drivers provided by microsoft has used
WdfDmaTransactionInitializeUsingRequest() and DMA has been initiated from
EvtIoQueue dispatched by any WdfRequest.
Thanks in advance,
Murugesan.S
You should check in your Hardware Engineer group if DMA engine could
support such small transaction.
It is very inefficient to use DMA for this amount of data. You should
use simple Read/Write PCI operations for such transfer.
Igor Sharovar
I am pretty sure that my h/w DMA engine supports such small transaction. I
have a reference driver in linux which does the same operation. As I
mentioned earlier, the h/w has not mapped these buffers into PCI registers.
So I cannot do PCI read/write, performing DMA is the only way as per my h/w
design. I am wondering whether KMDF DMA methodology supports such small
transaction. Also why they haven't provided any sample which performs DMA
using the memory allocated in the same layer ?
Is any thing incorrect in my sequence of DMA operation other than the number
of bytes ?
Murugesan
"eagersh" wrote:
> .
>
If you hardware does not support Read/Write PCI transactions how could
you control DMA operation? You need at least access to DMA registers
of the device. And you could do it only through PCI Read/Write.
Do I miss something?
Igor Sharovar
Murugesan
agersh" wrote:
> .
>
If your DMA registers are not mapped to PCI address space how could
initiate DMA transaction?
It is not matter if you have small or big buffer to transfer. Windows
framework only provides MDL or physical memory which you could use for
DMA transfer but initiate DMA transaction must be done by your driver.
You driver must prepare dma operation and starts it. You could look a
sample in WDK - PLX9x5x which shows how a driver does DMA operations.
Igor Sharovar
1. Can we perform DMA for 8 bytes using dmatransaction ?
YES.[From your previous answer]
2. What is wrong in the above mentioned sequence ?
I have provided a pseudo code in my first post. Please get back to my
first post.
3. Is it mandatory to call WdfDmaTransactionDmaCompleted in DPC handler ?
[ Right now, i've some problem with the interrupt, so only polling mode is
used)
4. I haven't initiated DMA on the context of a wdfrequest, so i can't use
WdfDmaTransactionInitializeUsingRequest(), will it be an issue ? [ This is
because all the sample drivers provided by microsoft has used
WdfDmaTransactionInitializeUsingRequest() and DMA has been initiated from
EvtIoQueue dispatched by any WdfRequest.
Murugesan
"eagersh" wrote:
> .
>
> 2. What is wrong in the above mentioned sequence ?
> I have provided a pseudo code in my first post. Please get back to my
> first post.
Is your ProgramDmaFunction called?
If it is, you should show this function too.
I have one comments. Usually if you allocate memory and MDL you need
to call MmBuildMdlForNonPagedPool. I don't know if this could be
related if you allocate a buffer by using MmAllocateContiguousMemory.
For 8 bytes buffer you don't need to use MmAllocateContiguousMemory
anyway.
> 3. Is it mandatory to call WdfDmaTransactionDmaCompleted in DPC handler ?
> [ Right now, i've some problem with the interrupt, so only polling mode is
> used)
No. This function is not linked to interrupt. It is only tells WDF
that DMA transaction is complete and ProgramDmaFunction should not be
called again.
> 4. I haven't initiated DMA on the context of a wdfrequest, so i can't use
> WdfDmaTransactionInitializeUsingRequest(), will it be an issue ? [ This is
> because all the sample drivers provided by microsoft has used
> WdfDmaTransactionInitializeUsingRequest() and DMA has been initiated from
> EvtIoQueue dispatched by any WdfRequest.
No, it should not be an issue.
Igor Sharovar
"Murugesan" <Muru...@discussions.microsoft.com> wrote in message
news:37A20A0C-F067-4B9E...@microsoft.com...
Thanks,
Murugesan.S
"Abhishek R [MSFT]" wrote:
> .
>