Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

mmap shared memory and bus error

1 view
Skip to first unread message

RM

unread,
May 14, 2003, 11:02:16 PM5/14/03
to
I'm using mmap to share memory between my driver and app. I've done
__get_free_pages in my driver to allocate contiguous physical memory. The
app did a couple of ioctls down to retrieve the address and size. The app
then calls mmap to map kernel space to it's own space. Everything is
returning ok.

Now my app tries to read the shared memory and gets a bus error. This is on
a MIPS (4k, I believe) embedded box. Is there something else I still need to
do? Is there alignment restrictions - I need to overlay a C structure on
this? Any suggestions? Thanx in advance.
RM


Michael Schnell

unread,
May 15, 2003, 3:55:39 AM5/15/03
to
> The app
> then calls mmap to map kernel space to it's own space.

> Now my app tries to read the shared memory and gets a bus error.

Can mmap be done from user space ? Seems not very logical to me.
Regarding you already wrote a device driver, why don't you provide the
mapping function for the application, there, too, using some kind of
handle you give the applications to identify pages, hiding the hardware
addresses from user space (where they shouldn't be seen IMHO). This will
improve the portability of your solution, too.

-Michael

Neil Horman

unread,
May 15, 2003, 8:48:31 AM5/15/03
to

Why are you using get_free_pages directly? There are other APIs in the
kernel which you can use to do the same thing without as much hassle (th
e pci_pool* api, and the consistent_alloc function come immediately to
mind). You may want to look into those, before you go figuring out why
using __get_free_pages isn't working properly.

Also, if your only purpose is to share memory between a driver and your
application, you may want to re-consider your contiguous page
requirement. If you don't really need contiguous pages, you can just as
easily use kmalloc in your driver, and memory map the range by calling
mmap using a file descriptor open on /dev/kmem rather than /dev/mem

HTH
Neil


0 new messages