Re: Looking for KMDF alternative to MmAllocateContiguousMemorySpecifyCache




Eliyas Yakub [MSFT] wrote:
Why do you need contiguous memory? Do you need it for DMA purposes?

There is no direct KMDF equivalent of this function. WdfCommonBuffer will
give you contiguous memory but you need to allocate a DMA enabler object
first.


Yes, both you and Max guessed right - DMA. Our good old friend - PLX
PCI9xxx.

Why don't I use AllocateCommonBuffer? Two reasons:
1. Strictly speaking, I don't need contiguous memory.
Since the buffer I'm planning to allocate is not exactly small I want
to apply as little pressure as possible on the system resources.
O.k. Now I realized that this argument isn't very sound because
MmAllocateContiguousMemory() also gives me, well, contiguous memory.
But at least I can allocated several smaller buffer... on the other
hand, the same is possible with AllocateCommonBuffer(). Well,... let's
continue to the argument #2

2. I run my PCI9xxx in the Scatter/Gather Mode with the SG Descriptors
located in the system memory. The oddity is - the device supports
dual-address cycles for DMA data access, but not for descriptors
access.
So the user buffer could live elsewhere in the full address space but
descriptors have to reside in the lower 4GB. So going with common
buffer I really have no idea what profile I should specify in
WDF_DMA_ENABLER_CONFIG_INIT(). Allocating space for descriptor list
with MmAllocateContiguousMemory(,4G-1) and setting
profile=WdfDmaProfileScatterGather64 looks like a nice workaround.
Now thinking about it, may be, I should create TWO DMA enabler objects,
one for descriptor list (with profile =WdfDmaProfilePacket or
WdfDmaProfileScatterGather) and another one for the data with
profile=WdfDmaProfileScatterGather64? Sounds weird.


Yes it's okay to use WDM and KMDF function in a driver however you should
try to find out if there a KMDF equivalent and use that (just like you are
doing now) because we provide KMDF equivalent to a WDM function only if
there is any value add in doing so in terms of better and simple programming
pattern, eliminating common mistakes, improving reliability, diagnosability,
etc.

We have come up with a porting table that will help you in quickly
identifying which concept of WDM maps to KMDF.

http://www.microsoft.com/whdc/driver/wdf/WDF_Port.mspx

-Eliyas

Thanks

.



Relevant Pages

  • Re: Kmalloc
    ... >>> Can any one help in knowing whether Kmalloc will always allocate ... >>> contiguous memory. ... some reason, not "kmalloc", thus changing the sense of the question. ... Kmalloc does deliver contiguous lumps of underlying physical memory even ...
    (comp.os.linux.development.system)
  • Re: contiguous memory allocation problem
    ... For example I noticed that FreeBSD was unable to allocate ... 350kbytes of contiguous memory after that I had run "konqueror", the KDE web ... browser and various other memory consuming applications for a while. ...
    (freebsd-hackers)
  • Re: AllocateCommonBuffer slow on AMD Opteron
    ... physical memory is too fragmented at the time you allocate the buffer. ... suballocate my contiguous memory from that slab. ...
    (microsoft.public.development.device.drivers)
  • Re: Size of contiguous memory
    ... Is it possible to allocate a 512KByte contiguous memory in the WDM ... Can I use MmAllocateContiguousMemory function in WDM driver? ...
    (microsoft.public.development.device.drivers)