Re: HalAllocateCommonBuffer & MmMapIoSpace problem



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?
.