Re: HalAllocateCommonBuffer & MmMapIoSpace problem



Why do you need to get the DMA buffer that is allocated in driver.

In general, you should allocate another buffer in your application and pass
this buffer pointer to your driver via XXX_Read. In the XXX_Read, copy the
DMA data to the application buffer.

Regards,
Paul, Chao @ Techware

"max" wrote:

Here are some logs, where DMA_MEM is a wrapper to Hal[Allocate|
Free]CommonBuffer used by the driver to get some memory for dma and
FOT_DRIVER is a wrapper that the application uses to access the
driver.

These logs are collected when the application frees the memory before
closing the driver:
-----------------------------------------------------------------------------------------------
....
204613 PID:7249272e TID:920cb8aa 0x9215d400: DMA_MEM::DMA_MEM
HalAllocateCommonBuffer 00A90000 (fis A4E9E000)
....
205071 PID:520cb8ce TID:b214de06 0x9214edb0: FOT_DRIVER VirtualCopy
000A0000 (fis A4E9E000)
....
208261 PID:520cb8ce TID:920cb8aa 0x9215d400: FOT_DRIVER VirtualFree
000A0000 (fis A4E9E000)
....
208303 PID:7249272e TID:920cb8aa 0x9215d400: DMA_MEM::~DMA_MEM
HalFreeCommonBuffer 00A90000 (fis A4E9E000)

The call stack is:
0x1007f800 NK!PhysPageToZero(unsigned long 0xa4e9e000) physmem.c line
907 + 100 bytes
0x1007f83c NK!DecommitPages(MemBlock * [512]* 0x9248f000, int
0x000000a9, int 0x00000000, int 0x00000096, unsigned long 0x00000000,
int 0x80000000, unsigned long * 0x00000000) virtmem.c line 516 + 8
bytes
0x1007f8a4 NK!SC_VirtualFree(void * 0x00a90000, unsigned long
0x00000000, unsigned long 0x00008000) virtmem.c line 1386 + 44 bytes
0x1007f944 NK!SC_FreePhysMem(void * 0x00a90000) virtmem.c line 2718 +
20 bytes
0x1007f958 COREDLL!xxx_FreePhysMem(void * 0x00a90000) tkfuncs.cpp
line 525 + 92 bytes
0x1007f978 CEDDK!HalFreeCommonBuffer(_DMA_ADAPTER_OBJECT_ *
0x00614210, unsigned long 0x00096000, _LARGE_INTEGER {...}, void *
0x00a90000, unsigned char 0x00) ddk_dma.c line 167
0x1007f990 DRVFOT!`anonymous namespace'::DMA_MEM::~DMA_MEM() dma.cpp
line 286


When the application close the driver and then frees the memory the
log is:
-----------------------------------------------------------------------------------------------

....
121658 PID:d249270a TID:f20f9cea 0x9215d400: DMA_MEM::DMA_MEM
HalAllocateCommonBuffer 00A90000 (fis A4E9E000)
....
122164 PID:b216d4fa TID:12142ef6 0x92142000: FOT_DRIVER VirtualCopy
000A0000 (fis A4E9E000)
....
124185 PID:d249270a TID:f20f9cea 0x9215d400: DMA_MEM::~DMA_MEM
HalFreeCommonBuffer 00A90000 (fis A4E9E000)
....
124346 PID:b216d4fa TID:f20f9cea 0x9215d400: FOT_DRIVER VirtualFree
000A0000 (fis A4E9E000)

The call stack is:
0x1007fa20 NK!PhysPageToZero(unsigned long 0xa4e9e000) physmem.c line
907 + 100 bytes
0x1007fa5c NK!DecommitPages(MemBlock * [512]* 0x920e9000, int
0x0000000a, int 0x00000000, int 0x00000096, unsigned long 0x00000000,
int 0x00000000, unsigned long * 0x00000000) virtmem.c line 516 + 8
bytes
0x1007fac4 NK!SC_VirtualFree(void * 0x000a0000, unsigned long
0x00000000, unsigned long 0x00008000) virtmem.c line 1386 + 44 bytes
0x1007fb64 NK!EXT_VirtualFree(void * 0x000a0000, unsigned long
0x00000000, unsigned long 0x00008000) kwin32.c line 119 + 16 bytes
0x1007fb84 COREDLL!xxx_VirtualFree(void * 0x000a0000, unsigned long
0x00000000, unsigned long 0x00008000) tkfuncs.cpp line 432 + 100 bytes


Some hint?

.



Relevant Pages

  • [git patches] libata fixes
    ... And a new, oft-reposted, finally ready cfl driver. ... tristate "Toshiba's Cell Reference Set IDE support" ... * In the last case the DMA engine can generate an interrupt when the ... * @buffer: Data buffer ...
    (Linux-Kernel)
  • Re: Shared Memory: Kernel/User Addresses
    ... I have this implemented this mechanism in my driver. ... DMA through and IOCTL call to the driver. ... pointer to the user buffer, and normally I do dma directly to and from ... When the driver gets the call, it gets an MDL for the user buffer. ...
    (microsoft.public.development.device.drivers)
  • Re: DMA with PCIe and very large DMA transfers
    ... PCIe devices? ... I'm putting together a driver for a specialist high-speed ... The particular use-case for this is a ring buffer with ... The device writes to the DMA memory when there ...
    (Linux-Kernel)
  • [PATCH 1/1] hv: Added new hv_utils driver with shutdown as first functionality - NO OUTLOOK
    ... Addition of new driver for Hyper-V called hv_utils. ... * VmbusChannelSendPacket- Send the specified buffer on the given channel ... struct vmbus_channel *channel; ...
    (Linux-Kernel)
  • Re: Real World Significant Sources of (what we usually call) Latency
    ... CPU is twice as fast, you can reduce your buffer size to half." ... the buffer adjustment for the driver or DAW program would go down to zero. ... nothing that can distract it from processing audio. ...
    (rec.audio.pro)