Re: CE device driver help, virtual memory and physical memory




It should work the way you are describing. It is probably
a mistake somewhere with the Virtualxxx flags. Personally
I'm using MmMapIoSpace/MmUnmapIoSpace instead of
VirtualAlloc/Copy (it should be no difference) for the same
purposes with no issues when releasing the memory.


On Mon, 25 Sep 2006 22:37:05 +0200, Andy Purcell <Andy_Purcell@xxxxxxxxxxx> wrote:

Hello,

At startup, my driver needs to allocate some memory for DMA purposes. I
currently use HalAllocateCommonBuffer() for this. I use this because it
gives me a physical address (needed for DMA).

I would like to make this memory available to the application for R/W. This
is because after the DMA is done, the app needs to see the content of the
memory. I am currently doing this with VirtualAlloc() and VirtualCopy() up
in user space. This all seems to work fine.

However, the problem is that when I close down the app and the driver, if I
try to do a VirtualFree() followed by a HalFreeCommonBuffer(), I hit a
DEBUGCHK() in the CE memory code.

Any thoughts about how best to
1) allocate some physical memory for DMA
2) make it available up in user space for R/W
3) free the memory when the app closes (user space actions and kernel driver
actions)

would be greatly appreciated.

Thanks in advance,

Andy




.



Relevant Pages

  • Re: PCIe device driver question
    ... I was thinking that the MMIO and reserve memory ... pages, allocated several additional memaligned pages in user space, used ... kernel using an ioctlcall, ... The DMA was just NOT happening on ...
    (Linux-Kernel)
  • Re: PCIe device driver question
    ... I was thinking that the MMIO and reserve memory ... pages, allocated several additional memaligned pages in user space, used ... kernel using an ioctlcall, ... The DMA was just NOT happening on ...
    (Linux-Kernel)
  • Re: dma to user space
    ... >> I would like to DMA this data to user space so that it can be saved to ... >> the physical addresses so I can create a scatter gather list for DMA. ... >> All the 2.6 kernel documentation seems to imply that you must allocate ... >> DMA memory in the kernel. ...
    (comp.os.linux.development.system)
  • RE: How to make mmaped kernel buffer non-cacheable
    ... I have mapped some user space memory to the kernel buffer and I wish to ensure that the contents of both are coherent and correctly ordered. ... The dma mapping API provide the neccessary ...
    (Linux-Kernel)
  • Re: dma to user space
    ... >I would like to DMA this data to user space so that it can be saved to ... then lock the memory with mlock. ... >the physical addresses so I can create a scatter gather list for DMA. ... >DMA memory in the kernel. ...
    (comp.os.linux.development.system)