From: okaya@codeaurora.org (Sinan Kaya)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 2/2] MIPS: io: add a barrier after register read in readX()
Date: Fri, 13 Apr 2018 12:36:33 -0400 [thread overview]
Message-ID: <3688d54c-85f3-6eba-7f13-1cef0a0b5d85@codeaurora.org> (raw)
In-Reply-To: <e38a329dfb9c461ab3e91de7b96db3dc@AcuMS.aculab.com>
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@codeaurora.org>
>>> Reported-by: Arnd Bergmann <arnd@arndb.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.
prev parent reply other threads:[~2018-04-13 16:36 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-03 12:55 [PATCH v3 1/2] MIPS: io: prevent compiler reordering on the default writeX() implementation Sinan Kaya
2018-04-03 12:55 ` [PATCH v3 2/2] MIPS: io: add a barrier after register read in readX() Sinan Kaya
2018-04-06 1:34 ` Sinan Kaya
2018-04-06 18:15 ` Sinan Kaya
2018-04-06 21:26 ` James Hogan
2018-04-07 21:43 ` Sinan Kaya
2018-04-11 17:10 ` Sinan Kaya
2018-04-11 20:26 ` James Hogan
2018-04-11 20:48 ` Sinan Kaya
2018-04-11 17:04 ` Maciej W. Rozycki
2018-04-12 21:51 ` James Hogan
2018-04-12 21:58 ` James Hogan
2018-04-12 22:38 ` Sinan Kaya
2018-04-12 22:20 ` Sinan Kaya
2018-04-13 15:41 ` David Laight
2018-04-13 16:36 ` Sinan Kaya [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3688d54c-85f3-6eba-7f13-1cef0a0b5d85@codeaurora.org \
--to=okaya@codeaurora.org \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).