WdfCommonBufferCreate problem

Hi,

I have WDF driver with non-Scatter/Gather DMA and it works well with common buffer (recommended by MS) and MmAllocateContiguousMemory (non-recommended by MS).

But on one pc I have MmAllocateContiguousMemory() returning NULL and blue screen with WdfCommonBufferCreate().

“Good” computers :
Dual-Core AMD Opteron 2214HE
Ram 1Gb
“Bad” computer :
AMD Opteron 240 EE
Ram 1Gb

All computers have :

  • WinXP Pro-SP2
  • WDF :
    wdfldr.sys (x86 - debug) - 1.1.0.0 (winmain(wmbla).060420-0120)
    wdf01000.sys (x86 - debug) 1.1.0.0 (winmain(wmbla).060420-0120)

WinDbg dump stack:

nt+0x21925
nt+0x2d5cb
hal+0x41f6
Wdf01000!FxDmaEnabler::FreeCommonBuffer+0x20
Wdf01000!FxCommonBuffer::FreeCommonBuffer+0x14
Wdf01000!FxCommonBuffer::Dispose+0x5
Wdf01000!FxObject::DisposeChildrenWorker+0x139
Wdf01000!FxObject::DeleteWorkerAndUnlock+0xe5
Wdf01000!FxObject::DeleteObject+0x254
Wdf01000!imp_WdfCommonBufferCreate+0x50c
xvim!VideoDMA::AllocateBuf+0x5e

Thanks,
Igor

Igor-

This looks (from my initial analysis, anyway) like a bona fide bug in the framework (we do not check to see if the buffer was successfully allocated when we destroy the common buffer object). Thanks for posting this. I will be following this up posthaste.

This doesn’t solve the original problem, however- offhand, it appears you simply cannot use a buffer the size you are requesting?

If I’m incorrect in my analysis, Doron or I will post back.

This bug was fixed in KMDF Version 1.5. So you can address it by upgrading to that version.

Bob,

Thanks a lot.
I’ll do it right now

Igor

Just to make sure I haven’t inadvertently overpromised- the blue screen when the allocation fails is fixed. Whatever was causing the original allocation to fail still remains.

Yeah… It seems you are right.
I can not allocate on this system even 2K common buffer

Have you set an alignment requirement (with WdfDeviceSetAlignmentRequirement) on the buffer? It’s hard to see otherwise why a 2K buffer would be unavailable, at least under any normal conditions.

A !wdflogdump with the verifier settings on might prove useful for a problem like this.

I have the same problem with MmAllocateContiguousMemory()
It returns NULL on this system.
On other computers everything works

> I have WDF driver with non-Scatter/Gather DMA and it works well with common

buffer (recommended by MS) and MmAllocateContiguousMemory (non-
recommended by MS).

MmAllocateContiguousMemory is only provided for use inside the DMA adapter
object implementations.

->AllocateCommonBuffer is internally a wrapper around
MmAllocateContiguousMemory, which takes into account some extra important
things like bounce buffers on 4GB boundary cross and such.

So, use ->AllocateCommonBuffer.


Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

I’m calling WdfDeviceSetAlignmentRequirement() with FILE_BYTE_ALIGNMENT.

When I’m trying allocate more than 0x1800 I have STATUS_INSUFFICIENT_RESOURCES error.

Maxim, I’m using WdfCommonBufferCreate().
I just tried MmAllocateContiguousMemory() for make sure it’s memory allocation problem - not with wrong WDFDMAENABLER object.

And again - it happen on one computer from 5 only.

Thanks,
Igor