memory mapped devices - Embedded

This is a discussion on memory mapped devices - Embedded ; 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 ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: memory mapped devices

  1. 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,

  2. Re: memory mapped devices

    On Nov 7, 7:02*am, Keep Asking 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?
    >
    > Thanks,


    use "ioremap_nocache()".
    Cheers
    Janaka

  3. 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

  4. Re: memory mapped devices

    Janaka wrote in news:6ca6ebcd-f4a7-456c-b3ae-
    3bfd5da88587@n1g2000prb.googlegroups.com:

    > On Nov 7, 7:02*am, Keep Asking 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

+ Reply to Thread