IPortWaveRTStream::AllocatePagesForMdl & MmAllocatePagesForMdlEx

Hello,

Just wondering whether currently the portcls functions is doing anything other than wrapping around MmAllocatePagesForMdlEx? I’m asking as it’s used for DMA purposes and to me it looks like an unofficial “confirmation” that it’s fine to use the Mm version for DMA purposes (discontiguous common buffer, in particular), at least for now (i.e. IOMMUs/etc still not used by Windows).

Also, does anybody know of any particular reason for the lack of a function to allocate a (potentially) discontiguous common DMA buffer (disregarding the packet-based functionality)?

-Alex

xxxxx@gmail.com wrote:

Just wondering whether currently the portcls functions is doing anything other than wrapping around MmAllocatePagesForMdlEx? I’m asking as it’s used for DMA purposes and to me it looks like an unofficial “confirmation” that it’s fine to use the Mm version for DMA purposes (discontiguous common buffer, in particular), at least for now (i.e. IOMMUs/etc still not used by Windows).

“Discontiguous common buffer” is just another name for “ordinary memory”.

Also, does anybody know of any particular reason for the lack of a function to allocate a (potentially) discontiguous common DMA buffer (disregarding the packet-based functionality)?

There is a function. ExAllocatePool. Nothing special is needed.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

>Discontiguous common buffer" is just another name for “ordinary memory”.

“…for DMA purposes…” - just allocating memory is sufficient, but only for now :wink:

There is a function. ExAllocatePool. Nothing special is needed.

…unless you want to avoid making your code naughty (see message 7 here: https://www.osronline.com/showthread.cfm?link=251064) by avoiding “hypothetically” (i.e. in the future) required translations. Hence my question :slight_smile:

xxxxx@gmail.com wrote:

> There is a function. ExAllocatePool. Nothing special is needed.
…unless you want to avoid making your code naughty (see message 7 here: https://www.osronline.com/showthread.cfm?link=251064) by avoiding “hypothetically” (i.e. in the future) required translations. Hence my question

That doesn’t mean a different kind of memory. If you’re worried about
this, you just need to use GetScatterGatherList in the DMA_ADAPTER to
get the page physical addresses.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

> That doesn’t mean a different kind of memory. If you’re worried about this, you just need to use GetScatterGatherList in the DMA_ADAPTER to get the page physical addresses.

GetScatterGatherList is for packet-based transfers - the “problem” is when you need a static common buffer that can be discontiguous (so as to prevent allocation failures as much as possible, for example). I know that I can hoard system resources with GetScatterGatherList (well, theoretically - 64-bit hardware so bounce buffers won’t be utilized) but this is abusing the API. I’m aware that it’s the same kind of memory and that on current hardware and versions of Windows (with disabled IOMMUs) there’s no difference between device-logical and physical addresses - I was just wondering why the DMA API hasn’t included a function that’s analogue to MmAllocatePagesForMdlEx or something similar (exallocatepool/etc), and if the PortCLS WaveRT driver is doing anything more under the hood, or is just being “naughty” (again, see the link in my previous message). I know that it’s not a problem currently, but “hypothetically”… :wink: