linux-mips
[Top] [All Lists]

Re: Uncached mmap

To: Mile Davidovic <Mile.Davidovic@micronasnit.com>
Subject: Re: Uncached mmap
From: Ralf Baechle <ralf@linux-mips.org>
Date: Mon, 13 Nov 2006 16:40:54 +0000
Cc: linux-mips@linux-mips.org
In-reply-to: <002101c70738$a4974ad0$5c00a8c0@niit.micronasnit.com>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <20061113123233.GA20337@linux-mips.org> <002101c70738$a4974ad0$5c00a8c0@niit.micronasnit.com>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mutt/1.4.2.2i
On Mon, Nov 13, 2006 at 04:30:26PM +0100, Mile Davidovic wrote:

> ptr = (unsigned char*)mmap(0,lineSize,PROT_READ|PROT_WRITE,MAP_SHARED,fd0,0);
> ...
> for (i = 0; i < 12; i++) 
>    *ptr++ = 0xaa;
> 
> this loop will not write all bytes correctly (every 4 bytes will have 0xaa as
> value), here is dump from Lauterbach debugger:
> ___address__|_0________4________8________C________0123456789ABCDEF
>   D:83660000|>FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF ................
>   D:83660010| 000000AA 000000AA 000000AA 0000AA02 ................

Is 83660000 a proper physical address or a virtual address?  A common
mistake is mapping a KSEG _virtual_ address to a userspace _virtual_
address.  Obviously mapping anything virtual to something else virtual
doesn't work ...

> and if I use bigger loop
> for (i = 0; i < 20; i++) 
>    *ptr++ = 0xaa;
> My linux will be crashed on 13 write. So, this is reason why I thought that
> byte access is not allowed on mmaped uncached memory. 

Let me guess, you filled up some write queue which now is waiting for
an acknowledge which never arrives.

> Is it possible that problem with byte access is related with device mmap
> function?

That is fairly simple code.

  Ralf

<Prev in Thread] Current Thread [Next in Thread>