Re: [Xen-devel] [PATCH v7 5/9] PCI: Add pci_iomap_wc() variants

2015-07-02 Thread Casey Leedom
> On Jul 2, 2015, at 11:49 AM, Luis R. Rodriguez wrote: > > On Sat, Jun 27, 2015 at 08:00:48AM +1000, Benjamin Herrenschmidt wrote: >> On Fri, 2015-06-26 at 16:24 +, Casey Leedom wrote: >>> Thanks for looking into this Ben. As it stands now, it seems as >>> if Write Combined mappings simpl

Re: [Xen-devel] [PATCH v7 5/9] PCI: Add pci_iomap_wc() variants

2015-07-02 Thread Benjamin Herrenschmidt
On Thu, 2015-07-02 at 20:49 +0200, Luis R. Rodriguez wrote: > > The question then is what is "the right thing". In the powerpc case, > > we'll have a non-garded mapping, which means we also get no ordering > > between load and stores. > > I don't follow, you *ordering* between load and stores for

Re: [Xen-devel] [PATCH v7 5/9] PCI: Add pci_iomap_wc() variants

2015-07-02 Thread Luis R. Rodriguez
On Sat, Jun 27, 2015 at 08:00:48AM +1000, Benjamin Herrenschmidt wrote: > On Fri, 2015-06-26 at 16:24 +, Casey Leedom wrote: > > Thanks for looking into this Ben. As it stands now, it seems as > > if Write Combined mappings simply aren't supported and/or all > > driver writers trying to util

Re: [Xen-devel] [PATCH v7 5/9] PCI: Add pci_iomap_wc() variants

2015-06-26 Thread Luis R. Rodriguez
On Fri, Jun 26, 2015 at 4:54 PM, Benjamin Herrenschmidt wrote: > On Fri, 2015-06-26 at 15:41 -0700, Luis R. Rodriguez wrote: > >> > It wasn't nullified for the main user at the time, the fb. And I >> > mentioned an IB adapter or two for which the code had been hand >> tuned. >> >> This still means

Re: [Xen-devel] [PATCH v7 5/9] PCI: Add pci_iomap_wc() variants

2015-06-26 Thread Benjamin Herrenschmidt
On Fri, 2015-06-26 at 15:41 -0700, Luis R. Rodriguez wrote: > > It wasn't nullified for the main user at the time, the fb. And I > > mentioned an IB adapter or two for which the code had been hand > tuned. > > This still means there could be some affected drivers when used on > powerpc, no? Yes.

Re: [Xen-devel] [PATCH v7 5/9] PCI: Add pci_iomap_wc() variants

2015-06-26 Thread Luis R. Rodriguez
On Jun 26, 2015 3:05 PM, "Benjamin Herrenschmidt" wrote: > > On Fri, 2015-06-26 at 21:31 +0200, Luis R. Rodriguez wrote: > > > Yeah either, we need to fix our relaxed implementation (patch > > > welcome :-) > > > > Yikes, so although powerpc has useful heuristics to automatically > > enable WC the

Re: [Xen-devel] [PATCH v7 5/9] PCI: Add pci_iomap_wc() variants

2015-06-26 Thread Benjamin Herrenschmidt
On Fri, 2015-06-26 at 21:31 +0200, Luis R. Rodriguez wrote: > > Yeah either, we need to fix our relaxed implementation (patch > > welcome :-) > > Yikes, so although powerpc has useful heuristics to automatically > enable WC the default write ops have been nullifying its effects? The heuristic is

Re: [Xen-devel] [PATCH v7 5/9] PCI: Add pci_iomap_wc() variants

2015-06-26 Thread Benjamin Herrenschmidt
On Fri, 2015-06-26 at 16:24 +, Casey Leedom wrote: > Thanks for looking into this Ben. As it stands now, it seems as > if Write Combined mappings simply aren't supported and/or all > driver writers trying to utilize Write Combined mappings have to > "hand roll" their own solutions which real

Re: [Xen-devel] [PATCH v7 5/9] PCI: Add pci_iomap_wc() variants

2015-06-26 Thread Luis R. Rodriguez
On Fri, Jun 26, 2015 at 08:51:58AM +1000, Benjamin Herrenschmidt wrote: > On Thu, 2015-06-25 at 21:40 +, Casey Leedom wrote: > > Hhmmm, so what do PowerPC Drivers do when they want to take > > advantage of Write Combining? Do their own Endian Swizzling > > with the __raw_*() APIs? > > Yeah ei

Re: [Xen-devel] [PATCH v7 5/9] PCI: Add pci_iomap_wc() variants

2015-06-26 Thread Casey Leedom
Thanks for looking into this Ben. As it stands now, it seems as if Write Combined mappings simply aren't supported and/or all driver writers trying to utilize Write Combined mappings have to "hand roll" their own solutions which really isn't supportable. One thing that might be considered is

Re: [Xen-devel] [PATCH v7 5/9] PCI: Add pci_iomap_wc() variants

2015-06-25 Thread Benjamin Herrenschmidt
On Thu, 2015-06-25 at 21:40 +, Casey Leedom wrote: > > Ah, thanks. I see now that the __raw_*() APIs don't do any of the > Endian Swizzling. Unfortunately the *_relaxed() APIs on PowerPC > are just defined as the normal *() routines. From > arch/powerpc/include/asm/io.h: > > /* >

Re: [Xen-devel] [PATCH v7 5/9] PCI: Add pci_iomap_wc() variants

2015-06-25 Thread Benjamin Herrenschmidt
On Thu, 2015-06-25 at 21:40 +, Casey Leedom wrote: > Hhmmm, so what do PowerPC Drivers do when they want to take > advantage of Write Combining? Do their own Endian Swizzling > with the __raw_*() APIs? Yeah either, we need to fix our relaxed implementation (patch welcome :-) Cheers, Ben.

Re: [Xen-devel] [PATCH v7 5/9] PCI: Add pci_iomap_wc() variants

2015-06-25 Thread Casey Leedom
| From: Arnd Bergmann [a...@arndb.de] | Sent: Thursday, June 25, 2015 1:44 PM | | On Thursday 25 June 2015 15:01:56 Casey Leedom wrote: | > | > Is there a reference I can read on this so I can understand | > when and where we can use the __raw_*() APIs? Can these | > Raw Read/Write operations b

Re: [Xen-devel] [PATCH v7 5/9] PCI: Add pci_iomap_wc() variants

2015-06-25 Thread Arnd Bergmann
On Thursday 25 June 2015 15:01:56 Casey Leedom wrote: > > Is there a reference I can read on this so I can understand > when and where we can use the __raw_*() APIs? Can these > Raw Read/Write operations be reordered with respect to > each other or are the use of the various flavors of SYNC > i

Re: [Xen-devel] [PATCH v7 5/9] PCI: Add pci_iomap_wc() variants

2015-06-25 Thread Casey Leedom
/ From: Benjamin Herrenschmidt [b...@kernel.crashing.org] | Sent: Wednesday, June 24, 2015 4:38 PM | | It is to be noted that on powerpc at least, writel() and co will never | combine due to the memory barriers in them. Only "normal" stores (or \ __raw_writel) will. / From: Benjamin Herrenschmidt

Re: [Xen-devel] [PATCH v7 5/9] PCI: Add pci_iomap_wc() variants

2015-06-24 Thread Benjamin Herrenschmidt
On Wed, 2015-06-24 at 17:58 -0700, Luis R. Rodriguez wrote: > On Wed, Jun 24, 2015 at 5:52 PM, Benjamin Herrenschmidt > wrote: > > On Thu, 2015-06-25 at 02:08 +0200, Luis R. Rodriguez wrote: > >> > >> OK thanks I'll proceed with these patches then. > >> > >> > As for user mappings, > >> > >> Which

Re: [Xen-devel] [PATCH v7 5/9] PCI: Add pci_iomap_wc() variants

2015-06-24 Thread Luis R. Rodriguez
On Wed, Jun 24, 2015 at 5:52 PM, Benjamin Herrenschmidt wrote: > On Thu, 2015-06-25 at 02:08 +0200, Luis R. Rodriguez wrote: >> >> OK thanks I'll proceed with these patches then. >> >> > As for user mappings, >> >> Which APIs were you considering in this regard BTW? > > mmap of the generic /sys/bu

Re: [Xen-devel] [PATCH v7 5/9] PCI: Add pci_iomap_wc() variants

2015-06-24 Thread Benjamin Herrenschmidt
On Thu, 2015-06-25 at 02:08 +0200, Luis R. Rodriguez wrote: > > OK thanks I'll proceed with these patches then. > > > As for user mappings, > > Which APIs were you considering in this regard BTW? mmap of the generic /sys/bus/pci/.../resource* > > maybe the right thing to do is to let us do wha

Re: [Xen-devel] [PATCH v7 5/9] PCI: Add pci_iomap_wc() variants

2015-06-24 Thread Luis R. Rodriguez
On Thu, Jun 25, 2015 at 09:38:01AM +1000, Benjamin Herrenschmidt wrote: > On Wed, 2015-06-24 at 15:29 -0700, Luis R. Rodriguez wrote: > > > Nope but at least what made me squint at this being a possible > > "feature" was that in practice when reviewing all of the kernels > > pending device drivers

Re: [Xen-devel] [PATCH v7 5/9] PCI: Add pci_iomap_wc() variants

2015-06-24 Thread Benjamin Herrenschmidt
On Wed, 2015-06-24 at 15:29 -0700, Luis R. Rodriguez wrote: > Nope but at least what made me squint at this being a possible > "feature" was that in practice when reviewing all of the kernels > pending device drivers using MTRR (potential write-combine candidates) > I encountered a slew of them wh

Re: [Xen-devel] [PATCH v7 5/9] PCI: Add pci_iomap_wc() variants

2015-06-24 Thread Luis R. Rodriguez
On Wed, Jun 24, 2015 at 3:05 PM, Benjamin Herrenschmidt wrote: > On Wed, 2015-06-24 at 18:38 +0200, Luis R. Rodriguez wrote: >> On Wed, Jun 24, 2015 at 08:42:23AM +1000, Benjamin Herrenschmidt wrote: >> > On Fri, 2015-06-19 at 15:08 -0700, Luis R. Rodriguez wrote: >> > > From: "Luis R. Rodriguez"

Re: [Xen-devel] [PATCH v7 5/9] PCI: Add pci_iomap_wc() variants

2015-06-24 Thread Benjamin Herrenschmidt
On Wed, 2015-06-24 at 18:38 +0200, Luis R. Rodriguez wrote: > On Wed, Jun 24, 2015 at 08:42:23AM +1000, Benjamin Herrenschmidt wrote: > > On Fri, 2015-06-19 at 15:08 -0700, Luis R. Rodriguez wrote: > > > From: "Luis R. Rodriguez" > > > > > > PCI BARs tell us whether prefetching is safe, but they

Re: [Xen-devel] [PATCH v7 5/9] PCI: Add pci_iomap_wc() variants

2015-06-24 Thread Luis R. Rodriguez
On Wed, Jun 24, 2015 at 08:42:23AM +1000, Benjamin Herrenschmidt wrote: > On Fri, 2015-06-19 at 15:08 -0700, Luis R. Rodriguez wrote: > > From: "Luis R. Rodriguez" > > > > PCI BARs tell us whether prefetching is safe, but they don't say anything > > about write combining (WC). WC changes orderin

Re: [Xen-devel] [PATCH v7 5/9] PCI: Add pci_iomap_wc() variants

2015-06-23 Thread Benjamin Herrenschmidt
On Fri, 2015-06-19 at 15:08 -0700, Luis R. Rodriguez wrote: > From: "Luis R. Rodriguez" > > PCI BARs tell us whether prefetching is safe, but they don't say anything > about write combining (WC). WC changes ordering rules and allows writes to > be collapsed, so it's not safe in general to use it

[Xen-devel] [PATCH v7 5/9] PCI: Add pci_iomap_wc() variants

2015-06-19 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" PCI BARs tell us whether prefetching is safe, but they don't say anything about write combining (WC). WC changes ordering rules and allows writes to be collapsed, so it's not safe in general to use it on a prefetchable region. Add pci_iomap_wc() and pci_iomap_wc_range(