Results 1 to 3 of 3
I have build an character driver in which i am allocating two PAGESIZE buffer using dma_alloc_coherent
Now i am passing the PHYSICAL address of these BUFFER
[src_ptr & dest_ptr] to ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 01-29-2013 #1Just Joined!
- Join Date
- Sep 2011
- Posts
- 6
Can we perform TWO MMAP operation on same /dev file
I have build an character driver in which i am allocating two PAGESIZE buffer using dma_alloc_coherent
Now i am passing the PHYSICAL address of these BUFFER
[src_ptr & dest_ptr] to user space using IOCTL as source_offset and dest_offset .
In user space this offeset is used as an offset for mmap call.
So on same /dev file say /dev/250 i am making TWO MMAP call
usr_src_ptr= mmap(0,page_size, PROT_READ|PROT_WRITE,MAP_SHARED, dev_FD,src_offset );
if (usr_src_ptr == MAP_FAILED){
printf("USR[UPP]:SOURCE MMAP FAiled \n\n");
close(dev_FD);
exit(-1);
}else{
printf("USR[UPP]:SOURCE MMAP is %X..\n",usr_src_ptr);
}
usr_dest_ptr= mmap(0,page_size, PROT_READ|PROT_WRITE,MAP_SHARED,dev_FD,dest_offset );
if (usr_dest_ptr == MAP_FAILED){
printf("USR[UPP]DEST MMAP FAiled \n\n");
close(dev_FD);
exit(-1);
}else{
printf("USR[UPP]DEST MMAP is %X..\n",usr_dest_ptr);
}
1. I am writing 0x77 in user_src_ptr in user space & printing
user_src_ptr in user space and dest_src_ptr in KERNEL space .
I get correct data for both user and kernel space
2. I am writng 0x55 in dest_ptr in kernel space & printing dest_ptr
in kernel space and usr_dest_ptr in user space.
NOW FOR THIS CASE I GET CORRECT DATA I.E 0X55 IN KERNEL BUFFER
dest_ptR , BUT THE USER SPACE BUFFER OF DESTINATION ALWAYS
RETURNS 0X77 . i.e THE DATA WHICH I HAVE WRITTEN IN usr_src_ptr.
Can any one please let me know if we can do TWO MMAP operation on same file at different OFFSET ?????
Thank You Ashish MishraLast edited by dgashu; 01-29-2013 at 10:58 AM.
- 01-30-2013 #2Just Joined!
- Join Date
- Mar 2012
- Posts
- 14
What is src_ptr and dest_ptr?
What is source_offset and dest_offset?
How you are using IOCTL?
if src_ptr is equals to source_offset then as of my knowledge the following mmap() operation is wrong
mmap(0,page_size, PROT_READ|PROT_WRITE,MAP_SHARED, dev_FD,src_offset );
Post your question clearly where others can understand. You'll definitely receive response from this forum.
- 01-31-2013 #3Just Joined!
- Join Date
- Jun 2008
- Location
- North East U.S.
- Posts
- 30
I'm not sure why my reply on this thread two days ago never showed up, but...
You can definitely have multiple mmap() calls against the same file. The offset passed as the last parameter is the offset within the file that you want to map into memory. This only works for virtual memory and I'm not sure if your mixing of kernel memory and user space could be trouble there. It sounds as if you are passing a pointer for that last parameter. I'd also be concerned that not all devices in /dev may support the direct access required by mmap(). I may be misunderstanding what you are doing though as it isn't very clear.


Reply With Quote
