All of lore.kernel.org
 help / color / mirror / Atom feed
From: mark.rutland@arm.com (Mark Rutland)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC v2 4/4] ARM: keystone: dma-coherent with safe fallback
Date: Mon, 6 Jun 2016 12:59:18 +0100	[thread overview]
Message-ID: <20160606115918.GG6831@leverpostej> (raw)
In-Reply-To: <20160606114321.GJ1041@n2100.armlinux.org.uk>

On Mon, Jun 06, 2016 at 12:43:21PM +0100, Russell King - ARM Linux wrote:
> On Mon, Jun 06, 2016 at 09:56:27AM +0100, Mark Rutland wrote:
> > I very much do not like this. As I previously mentioned [1],
> > dma-coherent has de-facto semantics today. This series deliberately
> > changes that, and inverts the relationship between DT and kernel (as the
> > describption in the DT would now depend on the configuration of the
> > kernel).
> 
> dma-coherent's semantics are not very well defined - just grep for it
> in Documention/devicetree/ and you'll find several different wordings
> for what this property means.

Indeed. This is the tip of the iceberg w.r.t. under-specification of
memory attribute usage.

> Anyway, my point here is that all of these merely say that the hardware
> is coherent in _some regard_ - it doesn't specify under what conditions
> DMA coherency is guaranteed by the hardware.  It happens that on ARM,
> most platforms give that guarantee when using inner shared mappings.  If
> we were to use some other sharing, or disable sharing altogether (eg, by
> disabling SMP support) then all these platforms would immediately break.
> 
> In other words, DMA coherence today already depends on the kernel's setup
> of the page tables corresponding to the requirements of the hardware.

I agree that whether or not devices are coherent in practice depends on
the kernel's configuration. The flip side, as you point out, is that
devices are coherent when a specific set of attributes are used.

i.e. that if you read dma-coherent as meaning "coherent iff Normal,
Inner Shareable, Inner WB Cacheable, Outer WB Cacheable", then
dma-coherent consistently describes the same thing, rather than
depending on the configuration of the OS.

DT is a datastructure provided to the kernel, potentially without deep
internal knowledge of that kernel configuration. Having a consistent
rule that is independent of the kernel configuration seems worth aiming
for.

A dma-outer-coherent property would allow us to accurately describe the
keystone case in the same way, independent of kernel configuration.

> Keystone II is just slightly different - and as I understand it, TI
> followed one of the early specifications that ARM Ltd produced.  That
> specification may have contained errors, but unfortunately, we now have
> a situation where there is hardware out there which followed in good
> faith.

To be clear, I am not arguing against supporting keystone. I just wish
to avoid muddying the waters further w.r.t. the semantics of
dma-coherent, which I believe can be salvaged and made consistent.

Clearly, those semantics are the point of contention here.

Thanks,
Mark.

WARNING: multiple messages have this Message-ID (diff)
From: Mark Rutland <mark.rutland@arm.com>
To: Russell King - ARM Linux <linux@armlinux.org.uk>
Cc: Bill Mills <wmills@ti.com>,
	t-kristo@ti.com, ssantosh@kernel.org, catalin.marinas@arm.com,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, r-woodruff2@ti.com,
	devicetree@vger.kernel.org
Subject: Re: [RFC v2 4/4] ARM: keystone: dma-coherent with safe fallback
Date: Mon, 6 Jun 2016 12:59:18 +0100	[thread overview]
Message-ID: <20160606115918.GG6831@leverpostej> (raw)
In-Reply-To: <20160606114321.GJ1041@n2100.armlinux.org.uk>

On Mon, Jun 06, 2016 at 12:43:21PM +0100, Russell King - ARM Linux wrote:
> On Mon, Jun 06, 2016 at 09:56:27AM +0100, Mark Rutland wrote:
> > I very much do not like this. As I previously mentioned [1],
> > dma-coherent has de-facto semantics today. This series deliberately
> > changes that, and inverts the relationship between DT and kernel (as the
> > describption in the DT would now depend on the configuration of the
> > kernel).
> 
> dma-coherent's semantics are not very well defined - just grep for it
> in Documention/devicetree/ and you'll find several different wordings
> for what this property means.

Indeed. This is the tip of the iceberg w.r.t. under-specification of
memory attribute usage.

> Anyway, my point here is that all of these merely say that the hardware
> is coherent in _some regard_ - it doesn't specify under what conditions
> DMA coherency is guaranteed by the hardware.  It happens that on ARM,
> most platforms give that guarantee when using inner shared mappings.  If
> we were to use some other sharing, or disable sharing altogether (eg, by
> disabling SMP support) then all these platforms would immediately break.
> 
> In other words, DMA coherence today already depends on the kernel's setup
> of the page tables corresponding to the requirements of the hardware.

I agree that whether or not devices are coherent in practice depends on
the kernel's configuration. The flip side, as you point out, is that
devices are coherent when a specific set of attributes are used.

i.e. that if you read dma-coherent as meaning "coherent iff Normal,
Inner Shareable, Inner WB Cacheable, Outer WB Cacheable", then
dma-coherent consistently describes the same thing, rather than
depending on the configuration of the OS.

DT is a datastructure provided to the kernel, potentially without deep
internal knowledge of that kernel configuration. Having a consistent
rule that is independent of the kernel configuration seems worth aiming
for.

A dma-outer-coherent property would allow us to accurately describe the
keystone case in the same way, independent of kernel configuration.

> Keystone II is just slightly different - and as I understand it, TI
> followed one of the early specifications that ARM Ltd produced.  That
> specification may have contained errors, but unfortunately, we now have
> a situation where there is hardware out there which followed in good
> faith.

To be clear, I am not arguing against supporting keystone. I just wish
to avoid muddying the waters further w.r.t. the semantics of
dma-coherent, which I believe can be salvaged and made consistent.

Clearly, those semantics are the point of contention here.

Thanks,
Mark.

  reply	other threads:[~2016-06-06 11:59 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-06  3:20 [RFC v2 0/4] ARM LPAE Outer Shared v2 Bill Mills
2016-06-06  3:20 ` Bill Mills
2016-06-06  3:20 ` [RFC v2 1/4] ARM: mm: add early page table attribute modification ability Bill Mills
2016-06-06  3:20   ` Bill Mills
2016-06-06 12:18   ` Russell King - ARM Linux
2016-06-06 12:18     ` Russell King - ARM Linux
2016-06-06 12:31     ` William Mills
2016-06-06 12:31       ` William Mills
2016-06-06  3:20 ` [RFC v2 2/4] ARM: mm: Add LPAE support for outer shared Bill Mills
2016-06-06  3:20   ` Bill Mills
2016-06-06  3:20 ` [RFC v2 3/4] ARM: mm: add inner/outer sharing value command line Bill Mills
2016-06-06  3:20   ` Bill Mills
2016-06-06  3:20 ` [RFC v2 4/4] ARM: keystone: dma-coherent with safe fallback Bill Mills
2016-06-06  3:20   ` Bill Mills
2016-06-06  8:56   ` Mark Rutland
2016-06-06  8:56     ` Mark Rutland
2016-06-06  9:09     ` Arnd Bergmann
2016-06-06  9:09       ` Arnd Bergmann
2016-06-06 11:42       ` Mark Rutland
2016-06-06 11:42         ` Mark Rutland
2016-06-06 12:37         ` Arnd Bergmann
2016-06-06 12:37           ` Arnd Bergmann
2016-06-06 12:50         ` William Mills
2016-06-06 12:50           ` William Mills
2016-06-06 12:50           ` William Mills
2016-06-06 16:18           ` Santosh Shilimkar
2016-06-06 16:18             ` Santosh Shilimkar
2016-06-06 11:43     ` Russell King - ARM Linux
2016-06-06 11:43       ` Russell King - ARM Linux
2016-06-06 11:43       ` Russell King - ARM Linux
2016-06-06 11:59       ` Mark Rutland [this message]
2016-06-06 11:59         ` Mark Rutland
2016-06-06 12:19         ` William Mills
2016-06-06 12:19           ` William Mills
2016-06-06 12:19           ` William Mills
2016-06-06 12:32         ` Russell King - ARM Linux
2016-06-06 12:32           ` Russell King - ARM Linux
2016-06-06 16:28           ` Santosh Shilimkar
2016-06-06 16:28             ` Santosh Shilimkar
2016-06-07 10:01           ` Mark Rutland
2016-06-07 10:01             ` Mark Rutland
2016-06-07 10:01             ` Mark Rutland
2016-06-07 12:32             ` Russell King - ARM Linux
2016-06-07 12:32               ` Russell King - ARM Linux
2016-06-07 12:55               ` Mark Rutland
2016-06-07 12:55                 ` Mark Rutland
2016-06-07 12:55                 ` Mark Rutland

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=20160606115918.GG6831@leverpostej \
    --to=mark.rutland@arm.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.