mmap'd physical memory not updating user virtual
I am writing a user space MAC driver in Linux 2.6.23 hosted on a Arm11 mpcore. A contiguous block of physical memory is allocated and mmap'd to userspace.
/dev/mem with O_SYNC flag is used to mmap so that the user virtual memory is uncached (with no much benefit).
Kernel
------
kptr = kmalloc(sz, GFP_DMA|GFP_KERNEL);
pptr = __pa(kptr);
User
----
fd = open("/dev/mem", O_RDWR|O_SYNC);
uptr = mmap(0, sz, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_LOCKED,fd, pptr);
The map'd user virtual memory is carved into network buffers and used for DMA.The MAC is successfully able to DMA ethernet frames to the physical memory. From the Rx interrupt handler bh (kernel logical memory) the frames received could be viewed and the cache functions also work fine. However, the mmap'd memory in user space does not reflect the changes.
Why is the physical memory mapped to user virtual does not reflect the chages ?
Or any suggestions on what could be going wrong here ?
thanks,
Deb Rupam Banerjee
P.S: Please note that all buffer alignment's are taken care of.
Trending Topics
| You Need A Budget | Feb 10, 2012 |
| The Linux powered LAN Gaming House | Feb 08, 2012 |
| Creating a vDSO: the Colonel's Other Chicken | Feb 06, 2012 |
| Your CMS Is Not Your Web Site | Feb 01, 2012 |
| Casper, the Friendly (and Persistent) Ghost | Jan 31, 2012 |
| Razor-qt 0.4 - Qt based Desktop Environment | Jan 30, 2012 |
- Fun with ethtool
- Parallel Programming with NVIDIA CUDA
- Readers' Choice Awards 2011
- 100% disappointed with the decision to go all digital.
- Linux-Based X Terminals with XDMCP
- Validate an E-Mail Address with PHP, the Right Way
- You Need A Budget
- The Linux powered LAN Gaming House
- Why Python?
- Python for Android
- Employment Posters
3 hours 49 min ago - Sure the best distro is
5 hours 9 min ago - BeOS was the best
7 hours 53 min ago - I use Wireshark on a daily
12 hours 23 min ago - buena información
17 hours 30 min ago - One important "bucket" that I didn't note (désolé si qqun deja d
18 hours 30 min ago - Gnome3 is such a POS. No one
1 day 3 hours ago - Gnome 3 is the biggest POS
1 day 4 hours ago - I didn't knew this thing by
1 day 10 hours ago - Author's reply
1 day 13 hours ago





Hi Deb, How did you solve
Hi Deb,
How did you solve this issue? I am also facing similar problem with ARM9. I have reserved 4M Bytes of memory at boot time, for using with the DMA and using the following code:
#define DMAMEM_START 0x73C00000
dma_fd = open("/dev/mem", O_RDWR | O_SYNC);
dma_mem = mmap(0, MSP2_DEV_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, dma_fd, DMAMEM_START);
DMA_write(DMAMEM_START, INST_Add, 16);
err = msync(dma_mem, (size_t) 64, MS_SYNC | MS_INVALIDATE);
DMA_read(INST_Add, DMAMEM_START+32, 16);
Using DMA_READ, I can see the data at DMAMEM_START, but sometime it is correct sometime incorrect.
I appreciate your step by step help!
Thanks,
Aa
DEVMEM
Mitch,
Thanks for your comments. I was able to solve the problem as follows:
I was using the cache (flush/inv) routines used on the kernel logical address and was able to see the DMA'd data. The same idea I used for the user virtual mapping and the DMA'd data was visible in the user space mapping.
thanks,
Deb
DEVMEM
Presumably mmap() is returning a valid pointer, correct? And you're not seeing any other errors occur, correct? You just never see the data change in the mapped area.
Does your kernel have CONFIG_STRICT_DEVMEM enabled?
Mitch Frazier is an Associate Editor for Linux Journal.