All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-core]  [PATCH, RFC] Make ioremap'ed memory available through rtdm_mmap_to_user()
@ 2006-09-15 16:26 Stelian Pop
  2006-09-15 16:40 ` Jan Kiszka
  0 siblings, 1 reply; 9+ messages in thread
From: Stelian Pop @ 2006-09-15 16:26 UTC (permalink / raw)
  To: xenomai

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 <stelian.pop@domain.hid>



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2006-09-22 14:53 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-15 16:26 [Xenomai-core] [PATCH, RFC] Make ioremap'ed memory available through rtdm_mmap_to_user() Stelian Pop
2006-09-15 16:40 ` Jan Kiszka
2006-09-18 21:13   ` Stelian Pop
2006-09-19 15:34     ` Jan Kiszka
2006-09-22  8:35       ` Stelian Pop
2006-09-22  8:58         ` Jan Kiszka
2006-09-22 11:34           ` Stelian Pop
2006-09-22 14:41             ` Jan Kiszka
2006-09-22 14:53               ` Stelian Pop

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.