RFC on writel and writel_relaxed

Arnd Bergmann arnd at arndb.de
Tue Mar 27 00:43:37 AEDT 2018


On Wed, Mar 21, 2018 at 2:58 PM, Sinan Kaya <okaya at codeaurora.org> wrote:
> On 3/21/2018 8:53 AM, Sinan Kaya wrote:
>> BTW, I have no idea what compiler barrier does on PPC and if
>>
>> wrltel() == compiler barrier() + wrltel_relaxed()
>>
>> can be said.
>
> this should have been
>
> writel_relaxed() == compiler barrier() + __raw_writel()

I don't think anyone clarified this so far, but there are additional differences
between the two, writel_relaxed() assumes we are talking to a 32-bit
little-endian
MMIO register, while __raw_writel() is primarily used for writing into
memory-type
regions with no particular byte order. This means:

- writel_relaxed() must perform a byte swap when running on big-endian kernels
- when used with __packed MMIO pointers, __raw_writel() may turn into a series
  of byte writes, while writel_relaxed() must result in a single 32-bit access.
- A set if consecutive writel_relaxed() on the same device is issued in program
  order, while __raw_writel() is not ordered. This typically requires
only a compiler
  barrier, but may also need a CPU barrier (in addition to the
barriers we use to
  serialize with spinlocks and DMA in writel() but not writel_relaxed()).

        Arnd


More information about the Linuxppc-dev mailing list