The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.
Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/
I am enabling DMA remapping for PCI device Windows driver (mostly WDF based).
I am getting BSODs (including not surprisingly DRIVER_VERIFIER_DMA_VIOLATION).
Could you help to confirm (or point problems you see) if the approach which was undertaken (and proven to work without DMA remapping) is still valid when DMA remapping is enabled.
I believe the redesign is needed, so I would appreciate your suggestions in this matter as well.
The current outline is like that:
On the device initialization WdfDeviceSetAlignmentRequirement is set to (PAGE_SIZE – 1)
On the device initialization DMA enabler is created with WdfDmaEnablerCreate and WdfDmaProfileScatterGather64.
On the device initialization driver allocates few common buffers which are used to program the device.
I have doubts on the direction of the transfer which seems to me to be inconsistent:
On the BSOD scenario (buffer length 128B) I can see BuildScatterGatherList returns ScatterGatherBuffer NumberOfElements to be zero. For sure the driver does not properly handle this case which may be BSOD reason. But I don’t know why NumberOfElements==0 can happen.
Beside NumberOfElements==0 BuildScatterGatherList returns successfully. The previous call to CalculateScatterGatherList returned ScatterGatherListSize==232 and NumberOfMapRegisters==1.
Could you help me understand what is the reason NumberOfElements==0 and if the driver can handle that i.e., get the proper address to program device to use DMA in such a case?
What more is interesting this driver seems to work fine (with DMA remapping enabled) for memory buffers > PAGE_SIZE.
For memory buffers <= PAGES_SIZE sometimes the driver also works fine, but only for the first IO request sent. The device is still plugged in and is not being unplugged during the test, but it may go to D3 between the first and second request being sent.
|Upcoming OSR Seminars|
|OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!|
|Writing WDF Drivers||7 Dec 2020||LIVE ONLINE|
|Internals & Software Drivers||25 Jan 2021||LIVE ONLINE|
|Developing Minifilters||8 March 2021||LIVE ONLINE|