Hi,

I need to be able to map an IO memory buffer to userspace from a RTDM
driver.

rtdm_mmap_to_user() seems to do what I need, but it doesn't work. Its
code thinks that all virtual addresses between VMALLOC_START and
VMALLOC_END are obtained through vmalloc() and tries to call
xnarch_remap_vm_page() on them, which fails.

Virtual addresses coming from ioremap() need to go through
xnarch_remap_io_page_range(), and their physical address cannot be
obtained with a simple virt_to_phys().

A working patch is attached below, but there might (should ?) be a
better way to do it. Some of the code may also belong to
asm-generic/system.h instead of the RTDM skin.

Note that you may also need to EXPORT_SYMBOL(vmlist and vmlist_lock) in
mm/vmalloc.c if you want to build the RTDM skin as a module.

Comments ?

Stelian.

Index: ksrc/skins/rtdm/drvlib.c
===================================================================
--- ksrc/skins/rtdm/drvlib.c    (révision 1624)
+++ ksrc/skins/rtdm/drvlib.c    (copie de travail)
@@ -1377,6 +1377,7 @@
 {
     struct rtdm_mmap_data *mmap_data = filp->private_data;
     unsigned long vaddr, maddr, size;
+    struct vm_struct *vm;
 
     vma->vm_ops = mmap_data->vm_ops;
     vma->vm_private_data = mmap_data->vm_private_data;
@@ -1385,7 +1386,21 @@
     maddr = vma->vm_start;
     size  = vma->vm_end - vma->vm_start;
 
+    write_lock(&vmlist_lock);
+    for (vm = vmlist; vm != NULL; vm = vm->next) {
+       if (vm->addr == (void *)vaddr)
+           break;
+    }
+    write_unlock(&vmlist_lock);
+
+    /* ioremap'ed memory */
+    if (vm && vm->flags & VM_IOREMAP)
+        return xnarch_remap_io_page_range(vma, maddr,
+                                         vm->phys_addr,
+                                          size, PAGE_SHARED);
+    else
 #ifdef CONFIG_MMU
+    /* vmalloc'ed memory */
     if ((vaddr >= VMALLOC_START) && (vaddr < VMALLOC_END)) {
         unsigned long mapped_size = 0;
 

-- 
Stelian Pop <[EMAIL PROTECTED]>


_______________________________________________
Xenomai-core mailing list
Xenomai-core@gna.org
https://mail.gna.org/listinfo/xenomai-core

Reply via email to