From: Ralf Baechle <ralf@linux-mips.org>
To: Alex Gonzalez <langabe@gmail.com>
Cc: linux-mips <linux-mips@linux-mips.org>
Subject: Re: Bus error after successful mmap of physical address
Date: Wed, 22 Aug 2007 19:08:27 +0100 [thread overview]
Message-ID: <20070822180827.GA3362@linux-mips.org> (raw)
In-Reply-To: <c58a7a270708221031g3fba98d5u8507c2aafd4e16b4@mail.gmail.com>
On Wed, Aug 22, 2007 at 06:31:22PM +0100, Alex Gonzalez wrote:
> I am sure there is a basic reason why this is not working but I just
> can't see it.
>
> I am booting with mem=512MB and trying to access a memory region at
> 0xC0000000 mapped by a fixed TLB entry.
Is 0xC0000000 a physical or virtual address. If it's a virtual address
your mapping will conflict with other mappings generated by the kernel and
you will need additional hacks to protect the address space from being
used by the kernel for other purposes.
> My driver does,
>
> vma->vm_flags = vma->vm_flags | VM_IO | VM_RESERVED ;
> vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot) ;
>
> // open device
> vadr = mmap( NULL , 1024*1024 ,
> PROT_WRITE|PROT_READ,MAP_NORESERVE|MAP_SHARED,device,0xC0000000);
^^^^^^^^^^
This is the reason why I was asking if 0xC0000000 was a physical address.
mmap needs a physical address.
> if(vadr == MAP_FAILED)
> {
> perror("mmap failed.\n");
> exit(-1);
> }
>
>
> That goes OK, but then if I try to read or write from vadr I get a "Bus error".
Assuming device is a /dev/mem descriptor that is looking ok. However - you
will be getting an uncached mapping from mmap so the performance will suck
rocks through a straw.
Anyway, you have 64-bit hardware, use it. On a 64-bit kernel you can just
address all your memory through XKPHYS without the need for any TLB entries.
Ralf
next prev parent reply other threads:[~2007-08-22 18:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-22 17:31 Bus error after successful mmap of physical address Alex Gonzalez
2007-08-22 18:08 ` Ralf Baechle [this message]
2007-08-23 10:22 ` Alex Gonzalez
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=20070822180827.GA3362@linux-mips.org \
--to=ralf@linux-mips.org \
--cc=langabe@gmail.com \
--cc=linux-mips@linux-mips.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.