This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

[ARMv7] question about writel & barrier

Hi Sirs,

I got a question about the way Linux 3.18 defines the "writel()".

In linux-3.18/arch/arm64/include/asm/io.h, it describes:

/*

* I/O memory access primitives. Reads are ordered relative to any

* following Normal memory access. Writes are ordered relative to any prior

* Normal memory access.

*/

And we can see the definition of writel():

#define writel(v,c) ({ __iowmb(); writel_relaxed((v),(c)); })

As you can see from the comment and the definition, when you call "writel()", the ARMv7 CPU would probably just sent as wmb and execute the instruction of "writel_relaxed()".

But...WHY?

Why put the barrier in front of the write_relaxed?

It just make sure that write would not be merged into CPU cluster's interior write buffer with previous data that haven't been write to exterior memory or IO device.

But we can not make sure after calling the "writel()", the write behavior has been done, isn't it? Since there is no instruction to drain the write buffer after writel_relaxed.

// I got this question because when tracing some driver, they use writel() to config the register.

// And I'm not sure it can make write be done with a short delay.

訊息由此人編輯:hcbamboo

Parents
  • @Ash Wilding

    Just a heads up that you're mentioning an "ARMv7" CPU, but then refer to /arch/arm64/, which corresponds to the ARMv8-A AArch64 port of the Linux kernel, not ARMv7-A. You should be looking in /arch/arm/ for ARMv7-A and earlier.

    Hi Sir,

    Sorry I just choose the wrong SDK.

    It should be Linux-3.4, and the path is linux-3.4/arch/arm/include/asm/io.h.

    The definition of writel() remains the same, however.

    (And the CPU we use in that project is dual core of Cortex-A9, anyway.)

    Thanks for your answering.

Reply
  • @Ash Wilding

    Just a heads up that you're mentioning an "ARMv7" CPU, but then refer to /arch/arm64/, which corresponds to the ARMv8-A AArch64 port of the Linux kernel, not ARMv7-A. You should be looking in /arch/arm/ for ARMv7-A and earlier.

    Hi Sir,

    Sorry I just choose the wrong SDK.

    It should be Linux-3.4, and the path is linux-3.4/arch/arm/include/asm/io.h.

    The definition of writel() remains the same, however.

    (And the CPU we use in that project is dual core of Cortex-A9, anyway.)

    Thanks for your answering.

Children