LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Sinan Kaya <okaya@codeaurora.org>,
	linux-parisc@vger.kernel.org, arnd@arndb.de,
	timur@codeaurora.org, sulrich@codeaurora.org
Cc: linux-arm-msm@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Helge Deller <deller@gmx.de>,
	Philippe Ombredanne <pombredanne@nexb.com>,
	Kate Stewart <kstewart@linuxfoundation.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] parisc: define stronger ordering for the default readX()
Date: Tue, 17 Apr 2018 10:37:32 +0100	[thread overview]
Message-ID: <1523957852.3250.9.camel@HansenPartnership.com> (raw)
In-Reply-To: <1523938133-3224-2-git-send-email-okaya@codeaurora.org>

On Tue, 2018-04-17 at 00:08 -0400, Sinan Kaya wrote:
> parisc architecture seems to be mapping readX() and readX_relaxed()
> APIs
> to __raw_readX() API.
> 
> __raw_readX() API doesn't provide any kind of ordering guarantees.
> commit 032d59e1cde9 ("io: define stronger ordering for the default
> readX()
> implementation") changed asm-generic implementation to use a more
> conservative approach towards the readX() API.

I don't follow your logic here.  function calls (even inline ones) are
sequence points and the compiler guarantees volatile variables are
stable before sequencing, so these two rules strictly compile order the
raw_read/write because the address is volatile.

> Place a barrier() after the register read so that compiler doesn't
> optimize across the regiter operation.

barrier() provides exactly the same guarantees as the sequence
point/volatile already above, so it seems to be completely unnecessary.

Perhaps if you gave an example of the actual problem you're trying to
fix we could assess if it affects parisc.

James


> Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
> ---
>  arch/parisc/include/asm/io.h | 23 +++++++++++++++++++----
>  1 file changed, 19 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/parisc/include/asm/io.h
> b/arch/parisc/include/asm/io.h
> index 2ec6405..e04c4ef 100644
> --- a/arch/parisc/include/asm/io.h
> +++ b/arch/parisc/include/asm/io.h
> @@ -179,19 +179,34 @@ static inline void __raw_writeq(unsigned long
> long b, volatile void __iomem *add
>  
>  static inline unsigned char readb(const volatile void __iomem *addr)
>  {
> -	return __raw_readb(addr);
> +	unsigned char ret;
> +
> +	ret = __raw_readb(addr);
> +	barrier();
> +	return ret;
>  }
>  static inline unsigned short readw(const volatile void __iomem
> *addr)
>  {
> -	return le16_to_cpu((__le16 __force) __raw_readw(addr));
> +	unsigned short ret;
> +
> +	ret = le16_to_cpu((__le16 __force) __raw_readw(addr));
> +	barrier();
> +	return ret;
>  }
>  static inline unsigned int readl(const volatile void __iomem *addr)
>  {
> -	return le32_to_cpu((__le32 __force) __raw_readl(addr));
> +	unsigned int ret;
> +	ret = le32_to_cpu((__le32 __force) __raw_readl(addr));
> +	barrier();
> +	return ret;
>  }
>  static inline unsigned long long readq(const volatile void __iomem
> *addr)
>  {
> -	return le64_to_cpu((__le64 __force) __raw_readq(addr));
> +	unsigned long long ret;
> +
> +	ret = le64_to_cpu((__le64 __force) __raw_readq(addr));
> +	barrier();
> +	return ret;
>  }
>  
>  static inline void writeb(unsigned char b, volatile void __iomem
> *addr)

  reply	other threads:[~2018-04-17  9:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-17  4:08 [PATCH v2 1/2] parisc: define stronger ordering for the default writeX() Sinan Kaya
2018-04-17  4:08 ` [PATCH v2 2/2] parisc: define stronger ordering for the default readX() Sinan Kaya
2018-04-17  9:37   ` James Bottomley [this message]
2018-04-17 14:13     ` Sinan Kaya
2018-04-17 15:55       ` James Bottomley
2018-04-17 18:28         ` Sinan Kaya
2018-04-17 22:53           ` John David Anglin
2018-04-18 13:39             ` Sinan Kaya

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=1523957852.3250.9.camel@HansenPartnership.com \
    --to=james.bottomley@hansenpartnership.com \
    --cc=arnd@arndb.de \
    --cc=deller@gmx.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=kstewart@linuxfoundation.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=okaya@codeaurora.org \
    --cc=pombredanne@nexb.com \
    --cc=sulrich@codeaurora.org \
    --cc=tglx@linutronix.de \
    --cc=timur@codeaurora.org \
    --subject='Re: [PATCH v2 2/2] parisc: define stronger ordering for the default readX()' \
    /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

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).