Driver Problems? Questions? Issues?
Put OSR's experience to work for you! Contact us for assistance with:
  • Creating the right design for your requirements
  • Reviewing your existing driver code
  • Analyzing driver reliability/performance issues
  • Custom training mixed with consulting and focused directly on your specific areas of interest/concern.
Check us out. OSR, the Windows driver experts.

OSR Seminars


Go Back   OSR Online Lists > ntdev
Welcome, Guest
You must login to post to this list
  Message 1 of 19  
04 Mar 18 13:35
Muthu Kumar
xxxxxx@gmail.com
Join Date: 17 Dec 2015
Posts To This List: 11
WdfDmaTransactionInitializeUsingRequest & WDFREQUEST

How a WdfRequest should be formatted for WdfDmaTransactionInitializeUsingRequest? I'm using WdfRequestCreate, WdfMemoryCreatePreallocated (with content of a buffer I want to DMA) and WdfIoTargetFormatRequestForWrite. WdfDmaTransactionInitializeUsingRequest fails with c0000010 (invalid device request).
  Message 2 of 19  
04 Mar 18 15:45
Muthu Kumar
xxxxxx@gmail.com
Join Date: 17 Dec 2015
Posts To This List: 11
WdfDmaTransactionInitializeUsingRequest & WDFREQUEST

verifier log shows " Couldn't retrieve mdl from WDFREQUEST..." Am I missing any steps above?
  Message 3 of 19  
04 Mar 18 16:04
Don Burn
xxxxxx@windrvr.com
Join Date: 23 Feb 2011
Posts To This List: 1406
WdfDmaTransactionInitializeUsingRequest & WDFREQUEST

In your first post you referred to WdfRequestCreate, are you trying to do this on a Create? There is no MDL on a create call, you really have to be doing this operation on one of the calls referred to in the documentation https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/wdfdma transaction/nf-wdfdmatransaction-wdfdmatransactioninitializeusingrequest Don Burn Windows Driver Consulting Website: http://www.windrvr.com -----Original Message----- From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com Sent: Sunday, March 04, 2018 3:45 PM To: Windows System Software Devs Interest List <xxxxx@lists.osr.com> Subject: RE:[ntdev] WdfDmaTransactionInitializeUsingRequest & WDFREQUEST verifier log shows " Couldn't retrieve mdl from WDFREQUEST..." Am I missing any steps above? --- NTDEV is sponsored by OSR Visit the list online at: <http://www.osronline.com/showlists.cfm?list=ntdev> MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers! Details at <http://www.osr.com/seminars> To unsubscribe, visit the List Server section of OSR Online at <http://www.osronline.com/page.cfm?name=ListServer>
  Message 4 of 19  
04 Mar 18 16:33
Doron Holan
xxxxxx@microsoft.com
Join Date: 08 Sep 2005
Posts To This List: 10209
WdfDmaTransactionInitializeUsingRequest & WDFREQUEST

If you are going to use a request in this context it is needs to have a valid current stack location. This means a request presented to you by a queue. A self created request that is formatted has valid NEXT stack location. Since you have the mdl, just call WdfDmaTransactionInitialize d Bent from my phone ________________________________ From: xxxxx@lists.osr.com <xxxxx@lists.osr.com> on behalf of xxxxx@gmail.com <xxxxx@lists.osr.com> Sent: Sunday, March 4, 2018 12:45:09 PM To: Windows System Software Devs Interest List Subject: RE:[ntdev] WdfDmaTransactionInitializeUsingRequest & WDFREQUEST verifier log shows " Couldn't retrieve mdl from WDFREQUEST..." Am I missing any steps above? --- NTDEV is sponsored by OSR Visit the list online at: <https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.osronline.co m%2Fshowlists.cfm%3Flist%3Dntdev&data=04%7C01%7CDoron.Holan%40microsoft.com%7C9d3 34475f2cb4061277708d58210e2c6%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636557 931402687766%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6 Ik1haWwifQ%3D%3D%7C-2&sdata=SfaBgunKvpRn5UN2C0WVzR8bUL7OFeZHxrRZPxcNa%2Fg%3D&rese rved=0> MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers! Details at <https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.osr.com%2Fse minars&data=04%7C01%7CDoron.Holan%40microsoft.com%7C9d334475f2cb4061277708d58210e 2c6%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636557931402697771%7CUnknown%7CT WFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwifQ%3D%3D%7C-2&sdat a=t69lBJqZnszXW%2Fc4xEkrDwGSR6d2IpBPxk5%2FlIboiQ4%3D&reserved=0> To unsubscribe, visit the List Server section of OSR Online at <https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.osronline.co m%2Fpage.cfm%3Fname%3DListServer&data=04%7C01%7CDoron.Holan%40microsoft.com%7C9d3 34475f2cb4061277708d58210e2c6%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636557 931402697771%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6 Ik1haWwifQ%3D%3D%7C-2&sdata=RUhP1leMMnFYg4Munhp2A%2F5F66O9JjlAb9WEZJcvyrU%3D&rese rved=0> --
  Message 5 of 19  
04 Mar 18 21:13
Muthu Kumar
xxxxxx@gmail.com
Join Date: 17 Dec 2015
Posts To This List: 11
WdfDmaTransactionInitializeUsingRequest & WDFREQUEST

Hi Doron, the situation is I've to send a large buffer to the device. This buffer has a content read from a file. So, I've to create a request from scratch. Should I rather create a MDL and use WdfDmaTransactionInitialize?
  Message 6 of 19  
05 Mar 18 14:02
Peter Viscarola
xxxxxx@osr.com
Join Date:
Posts To This List: 6193
List Moderator
WdfDmaTransactionInitializeUsingRequest & WDFREQUEST

>the situation is I've to send a large buffer to the device So... you don't REALLY need a WdfRequest? You just need a buffer and a DMA Transaction? In that case, don't build the Request. Just allocate the buffer and/or the MDL that describes the buffer, and WdfDmaTransactionInitialize.... No Request required. Peter OSR @OSRDrivers
  Message 7 of 19  
07 Mar 18 13:15
Muthu Kumar
xxxxxx@gmail.com
Join Date: 17 Dec 2015
Posts To This List: 11
WdfDmaTransactionInitializeUsingRequest & WDFREQUEST

Thanks Peter. Basic question. Do I need WdfCommonBuffer if MDL is used?
  Message 8 of 19  
07 Mar 18 13:39
Tim Roberts
xxxxxx@probo.com
Join Date: 28 Jan 2005
Posts To This List: 11963
WdfDmaTransactionInitializeUsingRequest & WDFREQUEST

xxxxx@gmail.com wrote: > Thanks Peter. Basic question. Do I need WdfCommonBuffer if MDL is used? It's not an either/or.  You always need an MDL with WdfDmaTransactionInitialize.  The question is, where did the buffer come from?  What does the MDL point to? If you have been handed a buffer, or you already allocated a buffer, then you can create an MDL for it and pass it to WDTI, assuming you can do scatter/gather. If you can't do scatter/gather, then you'll need a common buffer. -- Tim Roberts, xxxxx@probo.com Providenza & Boekelheide, Inc.
  Message 9 of 19  
07 Mar 18 14:10
Muthu Kumar
xxxxxx@gmail.com
Join Date: 17 Dec 2015
Posts To This List: 11
WdfDmaTransactionInitializeUsingRequest & WDFREQUEST

Tim, The buffer is allocated using ExAllocatePoolWithTag and filled with content read from a file. mdl is created using IoAllocateMdl call with the above buffer mdl is then passed to WDTI A commonbuffer for write was allocated earlier in EvtDeviceAdd I can't do scatter/gather. Now, my confusion, how is commonbuffer is used or connected with WdfDmaTransaction object? In EvtProgramDma, WdfDmaTransactionGetBytesTransferred returns 0 and the commonbuffer is empty.
  Message 10 of 19  
07 Mar 18 14:29
Tim Roberts
xxxxxx@probo.com
Join Date: 28 Jan 2005
Posts To This List: 11963
WdfDmaTransactionInitializeUsingRequest & WDFREQUEST

xxxxx@gmail.com wrote: > The buffer is allocated using ExAllocatePoolWithTag and filled with content read from a file. > > mdl is created using IoAllocateMdl call with the above buffer > > mdl is then passed to WDTI > > A commonbuffer for write was allocated earlier in EvtDeviceAdd > > I can't do scatter/gather. Then you should fire your hardware engineers.   No PCIe design in the 21st Century should ever be built without scatter/gather. > Now, my confusion, how is commonbuffer is used or connected with WdfDmaTransaction object? In EvtProgramDma, WdfDmaTransactionGetBytesTransferred returns 0 and the commonbuffer is empty. There's no connection between them.  The common buffer is just another way of allocating memory.  It only gets used if you use it, and right now you aren't using it. Here's what happens now.  You have your ExAllocatePoolWithTag (which, I hope, is non-paged pool?) buffer, which is not physically contiguous.  When you pass that to WdfDmaTransactionInitialize, it's going to call your callback multiple times, once for each page in the transfer.  Your callback will set up and trigger the DMAs, one page at a time.  As you get the DMA completion interrupts, you call WdfDmaTransactionDmaCompleted, and KMDF will call your callback again for the next page.  The common buffer is not involved. As long as you have the common buffer, why don't you just read the file into the common buffer?  Then you can do the entire thing as one transfer.  With a common buffer, there is really no need to use a WdfDmaTransaction at all. -- Tim Roberts, xxxxx@probo.com Providenza & Boekelheide, Inc.
  Message 11 of 19  
07 Mar 18 14:38
Muthu Kumar
xxxxxx@gmail.com
Join Date: 17 Dec 2015
Posts To This List: 11
WdfDmaTransactionInitializeUsingRequest & WDFREQUEST

>> Then you should fire your hardware engineers I wish I could :) >>As long as you have the common buffer, why don't you just read the file >>into the common buffer?? Then you can do the entire thing as one >>transfer.? With a common buffer, there is really no need to use a ><WdfDmaTransaction at all. Understood. To be clear, in this case, I don't need WDTI and WDTE calls Thanks Tim for the clarification
  Message 12 of 19  
07 Mar 18 14:40
Peter Viscarola
xxxxxx@osr.com
Join Date:
Posts To This List: 6193
List Moderator
WdfDmaTransactionInitializeUsingRequest & WDFREQUEST

<quote> If you can't do scatter/gather, then you'll need a common buffer </quote> Well... no, that's not true. Even if your hardware doesn't support scatter/gather, you can do packet-based DMA. I'm now thoroughly lost with what the OP needs to do. OP... instead of asking us one-line questions, can you please explain the overall goal you want to accomplish? Maybe then we can steer you in the right direction. Sorry for being confused. But I am. And I want to help... Peter OSR @OSRDrivers
  Message 13 of 19  
07 Mar 18 16:07
Muthu Kumar
xxxxxx@gmail.com
Join Date: 17 Dec 2015
Posts To This List: 11
WdfDmaTransactionInitializeUsingRequest & WDFREQUEST

Hi Peter, Trying to DMA 8K buffer of data read from a file. Needed clarification around on my attempt to use WdfDmaTransactionInitializeUsingRequest by creating WDFREQUEST from scratch. Needed further clarifications on using mdl & common buffer & WdfDmaTransaction and related APIs. Per Tim, I guess I can just read the content into a common buffer and DMA it without doing the WDF framework way at least for this scenario.
  Message 14 of 19  
07 Mar 18 16:19
Peter Viscarola
xxxxxx@osr.com
Join Date:
Posts To This List: 6193
List Moderator
WdfDmaTransactionInitializeUsingRequest & WDFREQUEST

<quote> Trying to DMA 8K buffer of data read from a file </quote> Thank you for that. Who's doing the reading? Does an application send you the data to be DMA'ed? That's the normal workflow for a driver. App reads the file, app calls WriteFile on a handle that's been opened to the device, the driver for that device does the DMA operation. Peter OSR @OSRDrivers
  Message 15 of 19  
07 Mar 18 16:24
Muthu Kumar
xxxxxx@gmail.com
Join Date: 17 Dec 2015
Posts To This List: 11
WdfDmaTransactionInitializeUsingRequest & WDFREQUEST

In this case, the driver has to do read (fw config data) and DMA in D0Entry context.
  Message 16 of 19  
07 Mar 18 16:37
Peter Viscarola
xxxxxx@osr.com
Join Date:
Posts To This List: 6193
List Moderator
WdfDmaTransactionInitializeUsingRequest & WDFREQUEST

<quote> In this case, the driver has to do read (fw config data) and DMA in D0Entry context. </quote> No. Sorry. That's not the right design. We don't do DMA operations from within the EvtDeviceD0Entry Event Processing Callback. It just won't work the way you expect. Do you need interrupts to process your DMA (and know it's done)? If so, you'll need to start a worker thread from within your EvtDeviceD0EntryPostInterruptsEnabled Event Processing Callback. But, there's a bigger question. Longer term, how does your device handle I/O Requests? How does it deal with read and write requests? How does it setup its general DMA processing? Peter OSR @OSRDrivers
  Message 17 of 19  
07 Mar 18 16:49
Muthu Kumar
xxxxxx@gmail.com
Join Date: 17 Dec 2015
Posts To This List: 11
WdfDmaTransactionInitializeUsingRequest & WDFREQUEST

Hi Peter, Yes, it is being done in EvtDeviceD0EntryPostInterruptsEnabled. Sorry, I replied quickly. The reads/writes will be handled very similar to how its done in the wdk sample (PLX9x5x)
  Message 18 of 19  
08 Mar 18 15:16
Tim Roberts
xxxxxx@probo.com
Join Date: 28 Jan 2005
Posts To This List: 11963
WdfDmaTransactionInitializeUsingRequest & WDFREQUEST

xxxxx@gmail.com wrote: > Trying to DMA 8K buffer of data read from a file > In this case, the driver has to do read (fw config data) and DMA in D0Entry context. If you're only doing two pages, then this is trivially easy.   Get yourself an 8k common buffer.  Read the file data directly into the buffer.  Set up your DMA hardware and trigger the DMA.  All the interrupt has to do is set a flag saying "DMA engine is now free". Does your hardware have a register-based interface to transfer this data?  For a one-time transfer that small, you might as well just do register pounding.  DMA isn't buying you anything. -- Tim Roberts, xxxxx@probo.com Providenza & Boekelheide, Inc.
  Message 19 of 19  
09 Mar 18 12:46
Peter Viscarola
xxxxxx@osr.com
Join Date:
Posts To This List: 6193
List Moderator
WdfDmaTransactionInitializeUsingRequest & WDFREQUEST

<quote> For a one-time transfer that small, you might as well just do register pounding. </quote> This. Absolutely. In fact, do you *really* want to do this each time your hardware enters D0 state? Because, that's what you're effectively doing by targeting EvtDeviceD0EntryPostInterruptsEnabled. If you don't need the interrupts OR the DMA, you can do the one time only register pounding directly in EvtDevicePrepareHardware. *I* know it says not to fool with your hardware in this routine, but that guidance is somewhat out of style. You know that you're in D0 on entry to EvtDevicePrepareHardware, and this happens to be a darn convenient place to do your one-time hardware initialization. Alternatively, if you really need to do this with DMA and interrupts, I was going to suggest firing-off a worker thread, and just having it work the setup I/O into your "ordinary" DMA I/O path. I, personally, would try to avoid using a unique DMA scheme for the configuration phase of your driver's work. If your ordinary I/O path does packet-based DMA, and (again) if I absolutely needed to DMA the config data, I would try to do packet-based DMA in my config path. I would try to avoid allocating a Common Buffer and writing a bunch of DMA code strictly to handle the initialization. I don't like debugging separate code paths when I can help it. And having two unique ways you handle DMA makes maintenance more confusing, as well. Peter OSR @OSRDrivers
Posting Rules  
You may not post new threads
You may not post replies
You may not post attachments
You must login to OSR Online AND be a member of the ntdev list to be able to post.

All times are GMT -5. The time now is 04:08.


Copyright ©2015, OSR Open Systems Resources, Inc.
Based on vBulletin Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Modified under license