[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <3688d54c-85f3-6eba-7f13-1cef0a0b5d85@codeaurora.org>
Date: Fri, 13 Apr 2018 12:36:33 -0400
From: Sinan Kaya <okaya@...eaurora.org>
To: David Laight <David.Laight@...LAB.COM>,
'James Hogan' <jhogan@...nel.org>
Cc: "linux-mips@...ux-mips.org" <linux-mips@...ux-mips.org>,
"arnd@...db.de" <arnd@...db.de>,
"timur@...eaurora.org" <timur@...eaurora.org>,
"sulrich@...eaurora.org" <sulrich@...eaurora.org>,
"linux-arm-msm@...r.kernel.org" <linux-arm-msm@...r.kernel.org>,
"linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>,
Ralf Baechle <ralf@...ux-mips.org>,
Paul Burton <paul.burton@...s.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v3 2/2] MIPS: io: add a barrier after register read in
readX()
On 4/13/2018 11:41 AM, David Laight wrote:
> From: James Hogan
>> Sent: 12 April 2018 22:52
>> On Tue, Apr 03, 2018 at 08:55:04AM -0400, Sinan Kaya wrote:
>>> While a barrier is present in writeX() function before the register write,
>>> a similar barrier is missing in the readX() function after the register
>>> read. This could allow memory accesses following readX() to observe
>>> stale data.
>>>
>>> Signed-off-by: Sinan Kaya <okaya@...eaurora.org>
>>> Reported-by: Arnd Bergmann <arnd@...db.de>
>>
>> Both patches look like obvious improvements to me, so I'm happy to apply
>> to my fixes branch.
>
> Don't you also need at least barrier() between the register write in writeX()
> and the register read in readX()?
> On ppc you probably need eieio.
> Or are drivers expected to insert that one?
> If they need to insert that one then why not all the others??
>
Good question. The volatile in here should prevent compiler from reordering the
register read or write instructions.
static inline type pfx##read##bwlq(const volatile void __iomem *mem)
This is the solution all other architectures rely on especially via
__raw_readX() and __raw_writeX() API.
Now, things can get reordered when it leaves the CPU. This is guaranteed by
embedding wmb() and rmb() into the writeX() and readX() functions in other
architectures.
This ordering guarantee has been agreed to be the responsibility of the
architecture not drivers.
--
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Powered by blists - more mailing lists