| View previous topic :: View next topic |
| Author |
Message |
Keep Asking Guest
|
Posted: Thu Nov 06, 2008 8:02 pm Post subject: memory mapped devices |
|
|
My question is how linux deals with memory cache .
When we have a memory mapped device, for example, at address
0x????????
The only thing I need to do to get the virtual adress is
ioremap(0x????????), then we can access the device just like normal
memory. If I look the ioremap(0 some case it's just as simple as to
add a offset. Then question is what mechanism makes memory cache
disabled for this range of memory?
Thanks, |
|
| |
|
Back to top |
Janaka Guest
|
Posted: Thu Nov 06, 2008 11:03 pm Post subject: Re: memory mapped devices |
|
|
On Nov 7, 7:02 am, Keep Asking <as...@yahoo.com> wrote:
| Quote: | My question is how linux deals with memory cache .
When we have a memory mapped device, for example, at address
0x????????
The only thing I need to do to get the virtual adress is
ioremap(0x????????), then we can access the device just like normal
memory. If I look the ioremap(0 some case it's just as simple as to
add a offset. Then question is what mechanism makes memory cache
disabled for this range of memory?
Thanks,
|
use "ioremap_nocache()".
Cheers
Janaka |
|
| |
|
Back to top |
Michael Schnell Guest
|
Posted: Fri Nov 07, 2008 3:02 pm Post subject: Re: memory mapped devices |
|
|
AFAIK, this depends on the MMU
If you use an MMU (and also if you use one), you can do this only in a
device driver and here ioremap()can be used to grant uncached access
ioremap() usually is inly called in the initialization phase of the
driver and the address obtained us used later.
If you don't use an MMU there are ways to access these ports in user mode.
-Michael |
|
| |
|
Back to top |
Gil Hamilton Guest
|
Posted: Fri Nov 07, 2008 6:38 pm Post subject: Re: memory mapped devices |
|
|
Janaka <janakas@optiscan.com> wrote in news:6ca6ebcd-f4a7-456c-b3ae-
3bfd5da88587@n1g2000prb.googlegroups.com:
| Quote: | On Nov 7, 7:02 am, Keep Asking <as...@yahoo.com> wrote:
My question is how linux deals with memory cache .
When we have a memory mapped device, for example, at address
0x????????
The only thing I need to do to get the virtual adress is
ioremap(0x????????), then we can access the device just like normal
memory. If I look the ioremap(0 some case it's just as simple as to
add a offset. Then question is what mechanism makes memory cache
disabled for this range of memory?
use "ioremap_nocache()".
|
To expand on this a bit: Typically, device drivers map device memory in
an uncached way so that each load or store goes directly to the device,
bypassing the cpu cache -- ioremap_nocache is typically the way that's
done. Its implementation varies from one architecture to another.
However, there is more to it than that. Device drivers should use readl
() and writel() and related macros to access memory on the device. You
may also want to read about the possible effects of asynchronously
posted writes that some buses such as PCI use. All of this is covered
(though not too thoroughly) in the kernel internals documentation. See
Documentation/DocBook/deviceiobook.XXX in your kernel source tree. I'd
also recommend looking at the book "Linux Device Drivers" which is
available online at http://lwn.net/Kernel/LDD3/
GH |
|
| |
|
Back to top |
|