From: Jan Kiszka <jan.kiszka@domain.hid>
To: Kolja Waschk <xenoka09@domain.hid>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] rtdm_mmap_to_user without MMU
Date: Thu, 16 Jul 2009 23:41:30 +0200 [thread overview]
Message-ID: <4A5F9E8A.3010906@domain.hid> (raw)
In-Reply-To: <Pine.LNX.4.62.0907151610090.24888@domain.hid>
[-- Attachment #1: Type: text/plain, Size: 2620 bytes --]
Kolja Waschk wrote:
> Hi,
>
> I finally seem to have a complete solution for my case. It's probably
> still missing one or the other detail, but it starts to work. I only
> added a few lines to ksrc/skins/rtdm/drvlib.c in rtdm_do_mmap:
>
> 1. Because linux/mm/nommu.c/validate_mmap_request() checks the
> capabilities of the backing dev, and /dev/zero lacks BDI_CAP_MAP_DIRECT
> capability, the /dev/mem has to be used instead of /dev/zero.
>
>> filp = filp_open("/dev/mem", O_RDWR, 0);
>
> 2. A get_unmapped_area() f_op has to be provided on nommu systems. It is
> also checked by validate_mmap_request(). I just copy in the pointer from
> old_fops: the /dev/mem f_op->get_unmapped_area simply passes pgoffs.
>
>> rtdm_mmap_fops.get_unmapped_area = old_fops->get_unmapped_area;
>
> 3. Since /dev/mem is used, the offset passed to do_mmap() has to
> point to the actual buffer (probably the physical address, for now I
> just used mmap_data->src_vaddr).
>
>> user_ptr = (void *)do_mmap(filp, (unsigned long)*pptr, len, prot,
>> MAP_SHARED, mmap_data->src_vaddr);
>
Nice analysis! I tried to fold your findings into a patch (actually,
they will become two in the end), see below. Please check if it works
for you.
In the meantime I need to verify if switching to /dev/mem comes without
side-effects for CONFIG_MMU. Anyone with a rtdm_mmap/iomap_to_user test
case at hand is welcome to check this, too!
Jan
---------->
diff --git a/ksrc/skins/rtdm/drvlib.c b/ksrc/skins/rtdm/drvlib.c
index 9f1cda8..3f37e75 100644
--- a/ksrc/skins/rtdm/drvlib.c
+++ b/ksrc/skins/rtdm/drvlib.c
@@ -1844,8 +1844,24 @@ static int rtdm_mmap_buffer(struct file *filp, struct vm_area_struct *vma)
return ret;
}
+#ifndef CONFIG_MMU
+static unsigned long rtdm_get_unmapped_area(struct file *file,
+ unsigned long addr,
+ unsigned long len,
+ unsigned long pgoff,
+ unsigned long flags)
+{
+ struct rtdm_mmap_data *mmap_data = filp->private_data;
+
+ return mmap_data->src_vaddr;
+}
+#endif /* !CONFIG_MMU */
+
static struct file_operations rtdm_mmap_fops = {
.mmap = rtdm_mmap_buffer,
+#ifndef CONFIG_MMU
+ .get_unmapped_area = rtdm_get_unmapped_area,
+#endif /* !CONFIG_MMU */
};
static int rtdm_do_mmap(rtdm_user_info_t *user_info,
@@ -1859,7 +1875,7 @@ static int rtdm_do_mmap(rtdm_user_info_t *user_info,
XENO_ASSERT(RTDM, xnpod_root_p(), return -EPERM;);
- filp = filp_open("/dev/zero", O_RDWR, 0);
+ filp = filp_open("/dev/mem", O_RDWR, 0);
if (IS_ERR(filp))
return PTR_ERR(filp);
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 257 bytes --]
next prev parent reply other threads:[~2009-07-16 21:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-14 19:14 [Xenomai-help] rtdm_mmap_to_user without MMU Waschk,Kolja
2009-07-15 7:44 ` Jan Kiszka
2009-07-15 10:24 ` Kolja Waschk
2009-07-15 14:35 ` Kolja Waschk
2009-07-16 21:41 ` Jan Kiszka [this message]
2009-07-17 9:59 ` Kolja Waschk
2009-07-17 11:50 ` Kolja Waschk
2009-07-18 8:00 ` Jan Kiszka
2009-08-04 7:21 ` Kolja Waschk
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=4A5F9E8A.3010906@domain.hid \
--to=jan.kiszka@domain.hid \
--cc=xenoka09@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.