Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 Oct 2015 09:38:47 -0600
From:      Warner Losh <imp@bsdimp.com>
To:        Leonardo Fogel <leonardofogel@yahoo.com.br>
Cc:        John-Mark Gurney <jmg@funkthat.com>,  "freebsd-drivers@freebsd.org" <freebsd-drivers@freebsd.org>
Subject:   Re: Memory barrier
Message-ID:  <CANCZdfoFYESa1qfFjX43eR8-ZaJvzthqfe77yS%2BUvBTDFJqnAg@mail.gmail.com>
In-Reply-To: <1444392942.1258.YahooMailBasic@web120801.mail.ne1.yahoo.com>
References:  <20151008223935.GH67524@funkthat.com> <1444392942.1258.YahooMailBasic@web120801.mail.ne1.yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Oct 9, 2015 at 6:15 AM, Leonardo Fogel <leonardofogel@yahoo.com.br>
wrote:

> On Thu, 10/8/15, John-Mark Gurney wrote:
>
> > If this is a PCI device, you need to do a read from the device before
> > it is guaranteed that all the bridges have flushed the writes to the
> > device...  A barrier only guarantees from the processor's perspective
> > that the write "has completed", but not that it will reach the device..
> >
> > If this is a different bus, then the rules are probably different...
>
> Good points. I've ignored them.
> It is a System-on-Chip based on ARM, which has different buses and
> bridges. Device registers are memory-mapped (MMIO).
> The formal definition of memory barriers is quite obscure; in simple
> terms: memory accesses before the barrier are "observed" before memory
> accesses after the barrier. However, the definition of an "observer" is not
> provided. Since the device registers are memory-mapped, I've assumed that a
> write before the barrier would reach the device before a write after the
> barrier. But, on a second thought, the buses and bridges might reorder
> them. I really don't know, but, to be on the safe side, I'll include the
> read.
> Thanks for your attention.
>

Yes, memory barriers are CPU artifacts. They tell you nothing about what
any bridges or other bus technology has done before it reaches the actual
device. If you need write ordering in the actual device, you almost
certainly need to do a read to act as a write barrier.

Warner



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CANCZdfoFYESa1qfFjX43eR8-ZaJvzthqfe77yS%2BUvBTDFJqnAg>