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