public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel•crashing.org>
To: Linus Torvalds <torvalds@linux-foundation•org>
Cc: Alexander Duyck <alexander.duyck@gmail•com>,
	Will Deacon <will.deacon@arm•com>,
	Sinan Kaya <okaya@codeaurora•org>, Arnd Bergmann <arnd@arndb•de>,
	Jason Gunthorpe <jgg@ziepe•ca>,
	David Laight <David.Laight@aculab•com>, Oliver <oohall@gmail•com>,
	"open list:LINUX FOR POWERPC (32-BIT AND 64-BIT)"
	<linuxppc-dev@lists•ozlabs.org>,
	"linux-rdma@vger•kernel.org" <linux-rdma@vger•kernel.org>,
	Alexander Duyck <alexander.h.duyck@redhat•com>,
	"Paul E. McKenney" <paulmck@linux•vnet.ibm.com>,
	"netdev@vger•kernel.org" <netdev@vger•kernel.org>
Subject: Re: RFC on writel and writel_relaxed
Date: Wed, 28 Mar 2018 15:33:40 +1100	[thread overview]
Message-ID: <1522211620.7364.94.camel@kernel.crashing.org> (raw)
In-Reply-To: <CA+55aFyTeuXPmC5-1JGh2ow-rf5wMA6Vcv0aeS_q0_EnptSK9Q@mail.gmail.com>

On Tue, 2018-03-27 at 16:51 -1000, Linus Torvalds wrote:
> On Tue, Mar 27, 2018 at 3:03 PM, Benjamin Herrenschmidt
> <benh@kernel•crashing.org> wrote:
> > 
> > The discussion at hand is about
> > 
> >         dma_buffer->foo = 1;                    /* WB */
> >         writel(KICK, DMA_KICK_REGISTER);        /* UC */
> 
> Yes. That certainly is ordered on x86. In fact, afaik it's ordered
> even if that writel() might be of type WC, because that only delays
> writes, it doesn't move them earlier.

Ok so this is our answer ...

 ... snip ... (thanks for the background info !)

> Oh, the above UC case is absoutely guaranteed.

Good.

Then....

> The only issue really is that 99.9% of all testing gets done on x86
> unless you look at specific SoC drivers.
> 
> On ARM, for example, there is likely little reason to care about x86
> memory ordering, because there is almost zero driver overlap between
> x86 and ARM.
> 
> *Historically*, the reason for following the x86 IO ordering was
> simply that a lot of architectures used the drivers that were
> developed on x86. The alpha and powerpc workstations were *designed*
> with the x86 IO bus (PCI, then PCIe) and to work with the devices that
> came with it.
> 
> ARM? PCIe is almost irrelevant. For ARM servers, if they ever take
> off, sure. But 99.99% of ARM is about their own SoC's, and so "x86
> test coverage" is simply not an issue.
> 
> How much of an issue is it for Power? Maybe you decide it's not a big deal.
> 
> Then all the above is almost irrelevant.

So the overlap may not be that NIL in practice :-) But even then that
doesn't matter as ARM has been happily implementing the same semantic
you describe above for years, as do we powerpc.

This is why, I want (with your agreement) to define clearly and once
and for all, that the Linux semantics of writel are that it is ordered
with previous writes to coherent memory (*)

This is already what ARM and powerpc provide, from what you say, what
x86 provides, I don't see any reason to keep that badly documented and
have drivers randomly growing useless wmb()'s because they don't think
it works on x86 without them !

Once that's sorted, let's tackle the problem of mmiowb vs. spin_unlock
and the problem of writel_relaxed semantics but as separate issues :-)

Also, can I assume the above ordering with writel() equally applies to
readl() or not ?

IE:
	dma_buf->foo = 1;
	readl(STUPID_DEVICE_DMA_KICK_ON_READ);

Also works on x86 ? (It does on power, maybe not on ARM).

Cheers,
Ben.

(*) From an Linux API perspective, all of this is only valid if the
memory was allocated by dma_alloc_coherent(). Anything obtained by
dma_map_something() might have been bounced bufferred or might require
extra cache flushes on some architectures, and thus needs
dma_sync_for_{cpu,device} calls.

Cheers,
Ben.

  parent reply	other threads:[~2018-03-28  4:34 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1521692689.16434.293.camel@kernel.crashing.org>
     [not found] ` <CAOSf1CFv1HHCL3YOVhRn2U=grdNjaQ=A4m3xwxN2Rek1-_TySg@mail.gmail.com>
     [not found]   ` <1521726722.16434.312.camel@kernel.crashing.org>
     [not found]     ` <20180323163510.GC13033@ziepe.ca>
     [not found]       ` <1521854626.16434.359.camel@kernel.crashing.org>
     [not found]         ` <58ce5b83f40f4775bec1be8db66adb0d@AcuMS.aculab.com>
     [not found]           ` <20180326165425.GA15554@ziepe.ca>
     [not found]             ` <CAK8P3a1zeMyj+Z-y4ER4moY6Zip9EWNOinf+VnboGOrgiwbBZA@mail.gmail.com>
     [not found]               ` <20180326202545.GB15554@ziepe.ca>
     [not found]                 ` <CAK8P3a3fc43ZcW626hmsd3DVcLw7hGkdUMxp7s4Rn3mdkziwMQ@mail.gmail.com>
     [not found]                   ` <20180326210951.GD15554@ziepe.ca>
     [not found]                     ` <CAK8P3a2UU1xAM0NLo7Q4-Xgo1SzY3De1uqpFudr+2ZW7nHEPmA@mail.gmail.com>
     [not found]                       ` <1522101616.7364.13.camel@kernel.crashing.org>
2018-03-27 14:46                         ` RFC on writel and writel_relaxed Sinan Kaya
2018-03-27 15:01                           ` Jose Abreu
2018-03-27 15:10                           ` Will Deacon
2018-03-27 18:54                             ` Alexander Duyck
2018-03-27 19:54                               ` Arnd Bergmann
2018-03-27 20:46                                 ` Arnd Bergmann
2018-03-27 21:33                               ` Benjamin Herrenschmidt
2018-03-28  0:39                                 ` Linus Torvalds
2018-03-28  1:03                                   ` Benjamin Herrenschmidt
2018-03-28  2:51                                     ` Linus Torvalds
2018-03-28  3:24                                       ` Sinan Kaya
2018-03-28  4:41                                         ` Benjamin Herrenschmidt
2018-03-28  6:14                                         ` Linus Torvalds
2018-03-28 11:41                                           ` okaya
2018-03-28 15:13                                             ` Benjamin Herrenschmidt
2018-03-28 15:55                                               ` David Miller
2018-03-28 16:23                                                 ` Nicholas Piggin
2018-03-28 21:31                                                   ` Benjamin Herrenschmidt
2018-03-28 22:09                                                     ` Nicholas Piggin
2018-03-29  9:20                                                     ` Will Deacon
2018-03-29 13:56                                                 ` Sinan Kaya
2018-03-29 14:04                                                   ` David Miller
2018-03-29 16:29                                                   ` Arnd Bergmann
2018-03-29 16:59                                                     ` Sinan Kaya
2018-03-30  1:40                                                   ` Benjamin Herrenschmidt
2018-04-02 13:01                                                     ` Sinan Kaya
2018-03-28  4:33                                       ` Benjamin Herrenschmidt [this message]
2018-03-28  6:26                                         ` Linus Torvalds
2018-03-28  6:42                                           ` Benjamin Herrenschmidt
2018-03-28  6:53                                             ` Linus Torvalds
2018-03-28  6:56                                               ` Benjamin Herrenschmidt
2018-03-28  7:11                                                 ` Arnd Bergmann
2018-03-28  7:42                                                   ` Benjamin Herrenschmidt
2018-03-28  9:07                                             ` Will Deacon
2018-03-28  9:56                                               ` Benjamin Herrenschmidt
2018-03-28 10:13                                                 ` Aw: " Lino Sanfilippo
2018-03-28 10:20                                                   ` Benjamin Herrenschmidt
2018-03-28 11:30                                                 ` David Laight
2018-03-28 15:12                                                   ` Benjamin Herrenschmidt
2018-03-28 16:16                                                     ` David Laight
2018-03-28  1:21                             ` Benjamin Herrenschmidt
2018-03-27 21:35                           ` Benjamin Herrenschmidt
2018-03-27 21:54 Alexander Duyck
2018-03-27 22:35 ` Sinan Kaya
2018-03-27 23:43 ` Benjamin Herrenschmidt

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=1522211620.7364.94.camel@kernel.crashing.org \
    --to=benh@kernel$(echo .)crashing.org \
    --cc=David.Laight@aculab$(echo .)com \
    --cc=alexander.duyck@gmail$(echo .)com \
    --cc=alexander.h.duyck@redhat$(echo .)com \
    --cc=arnd@arndb$(echo .)de \
    --cc=jgg@ziepe$(echo .)ca \
    --cc=linux-rdma@vger$(echo .)kernel.org \
    --cc=linuxppc-dev@lists$(echo .)ozlabs.org \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=okaya@codeaurora$(echo .)org \
    --cc=oohall@gmail$(echo .)com \
    --cc=paulmck@linux$(echo .)vnet.ibm.com \
    --cc=torvalds@linux-foundation$(echo .)org \
    --cc=will.deacon@arm$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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