system unstable when using MMAP and REMAP_PFN_RANGE
I hope to get some clues on my problem.
My system: 2GB RAM, Fedora12, an PCIe card with DMA write engine, PCIe linux driver exported as character device with ioctl and mmap operations, test-application which checks the received data.
- System memory is limited to 1GB by specifying "mem = 1024M" in /boot/grub/grub.conf file. The higher half is used for DMA transfer, DMA engine transfer upto 512MB only. i.e 1GB=>1.5GB then back to 1GB, continuously streaming.
- Up on certain amount of data, PCIe card interrupts driver, driver updates total data available, called "total".
- Application accesses the "total" via ioctl, accesses the transferred data by mmap.
- mmap in character-device-pcie-driver called remap_pfn_range and pass directly the physical address to it:
remap_pfn(vma, vma->vm_start, (physical_address>>PAGE_SHIFT), vma->vm_end-vma->vm_start, vma->vm_page_prot)
- Application checks data by accessing the memory returned by mmap and checks certain locations for known signatures.
- The DMA always dumps data into Main memory regardless of whether the application is running or not.
Everythings works fine, data is valid, interrupt, poll, mmap functions work perfectly. However, the X11 system is very unstable. Symptoms:
- ssh deamon, sshd, received segmentation fault
- some audit programme has segmentation fault
- terminal used to launch the test-application quits
- X11 GUI quits (logged off to the log-on screen) or gets black-out
I've tried and found out that the system is stable when:
- I do not run the test application, i.e only driver and dma running.
- OR test-application does mmap but not accessing the memory at all, i.e. just do mmap and the test-application go into while-forever loop and do nothing.
I really have no clue what's wrong. Why does accessing the memory make system & other applications unstable?
I'm seeking help from community and experts. Any hint would help a lot.
Thanks for reading,