From: Stelian Pop <stelian.pop@domain.hid>
To: xenomai@xenomai.org
Subject: [Xenomai-core] [PATCH, RFC] Make ioremap'ed memory available through rtdm_mmap_to_user()
Date: Fri, 15 Sep 2006 18:26:23 +0200 [thread overview]
Message-ID: <1158337583.13530.20.camel@domain.hid> (raw)
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>
next reply other threads:[~2006-09-15 16:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-15 16:26 Stelian Pop [this message]
2006-09-15 16:40 ` [Xenomai-core] [PATCH, RFC] Make ioremap'ed memory available through rtdm_mmap_to_user() 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1158337583.13530.20.camel@domain.hid \
--to=stelian.pop@domain.hid \
--cc=xenomai@xenomai.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.