linux 内核中的 b/w __raw_readl/__raw_writel 和 readl/writel 有什么区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9818657/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 05:19:52  来源:igfitidea点击:

What's the difference b/w __raw_readl/__raw_writel and readl/writel in linux kernel?

linuxlinux-kernelkerneldriver

提问by Yifan Zhang

What's the difference b/w __raw_readl/__raw_writeland readl/writelin linux kernel? It is said readl/writelis safer than __raw_readl/__raw_writel, then why do we still use __raw_readl/__raw_writel?

b/w__raw_readl/__raw_writelreadl/writellinux 内核有什么区别?都说readl/writel比安全__raw_readl/__raw_writel,那为什么还要用__raw_readl/__raw_writel呢?

Under what circumstances should we use this: __raw_readl/__raw_writelor readl/writel?

在什么情况下我们应该使用 this:__raw_readl/__raw_writelreadl/writel?

采纳答案by blueshift

It seemsto be the case that

似乎到的情况是,

  • raw denotes native byte ordering, non-raw means little-endian
  • the __ prefix alternatives don't include memory barriers
  • raw 表示本机字节顺序,非原始表示小端
  • __ 前缀替代方案不包括内存屏障

See this LKML discussionand also the comments in linux/arch/arm/include/asm/io.h

请参阅此 LKML 讨论以及linux/arch/arm/include/asm/io.h 中的注释