Driver mmap support and behavior | |
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] | |
Hi !
After reading the LDD3 book I made a driver that needs to make some
datas accessible to userland via mmap. These datas are exported by
an FPGA on physical memory 0x10000000-0x10010000.
The code of the driver's mmap function is:
------8<---------------------------------------------------------------
static int device_mmap(struct file *filp, struct vm_area_struct *vma)
{
unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
unsigned long phys_addr = FPGA_IOMEM_BASE1 + offset;
unsigned long phys_size = BASE1_BYTES_SIZE - offset;
unsigned long virt_size = vma->vm_end - vma->vm_start;
if (virt_size > phys_size)
{
PERROR("virtual size > physical size !\n");
return -EINVAL; /* spans too high */
}
vma->vm_flags |= VM_IO | VM_RESERVED;
if (io_remap_page_range(vma,
vma->vm_start,
phys_addr,
virt_size,
vma->vm_page_prot) != 0)
{
PERROR("couldn't remap FPGA IO memory to you address
space.\n");
return -EAGAIN;
}
vma->vm_file = filp;
vma->vm_ops = &device_vm_ops;
device_vm_open(vma);
return 0;
}
------8<---------------------------------------------------------------
I took the code from the book and lightly adapted it to my needs...
The problem I run into is that I must call msync() from user space
so that the datas are really written back to the FPGA, even with the
VM_IO | VM_RESERVED flags.
mmap() is called with the MAP_SHARED (and PROT_READ | PROT_WRITE).
Is there anything I could do so that data is written in sync without
the need to call msync() ? What did I miss ?
Thanks to all.
Thomas.
--
Thomas Nemeth - Ingénieur d'Études en Informatique Industrielle
Industrial Computing Software Designer
BETAtech - 15, rue Apollo, Z.A. de Montredon, 31240, L'Union.
05 34 30 40 00 / 05 34 30 40 09
-------------------------------------------------------------------
List admin: http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm
FAQ: http://www.arm.linux.org.uk/mailinglists/faq.php
Etiquette: http://www.arm.linux.org.uk/mailinglists/etiquette.php
[Site Home] [IETF Annouce] [Security] [Bugtraq] [Linux] [Linux ARM Kernel] [Linux MIPS] [ECOS] [Tools] [DDR & Rambus] [Monitors]