Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 6 Sep 2015 21:03:11 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Leonardo Fogel <leonardofogel@yahoo.com.br>
Cc:        freebsd-drivers@freebsd.org
Subject:   Re: Memory barrier
Message-ID:  <20150906180311.GS2072@kib.kiev.ua>
In-Reply-To: <1441547636.78646.YahooMailBasic@web120801.mail.ne1.yahoo.com>
References:  <2149458.2Hg3JbBXY3@ralph.baldwin.cx> <1441547636.78646.YahooMailBasic@web120801.mail.ne1.yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Sep 06, 2015 at 06:53:56AM -0700, Leonardo Fogel wrote:
> Hi.
> Please, what are the correct barriers for the following cases?
> 
> Case 1:
>    bus_write_1(region_0, ...);
>    /* barrier here */
>    DELAY(some_time);
> 
> Case 2:
>    bus_write_1(region_0, ...);
>    /* barrier here */
>    bus_write_1(region_2, ...);
> 
> In the first one, I want the write to reach the device before the thread busy-waits. As I understand it, bus_space_barrier(9) is not adequate, because it does not prevent the processor from executing instructions (or load/store to RAM) before the write completes.
> 
> In the second one, I want the write to a device (e.g. power management) to complete before the write to another starts/completes. Again, bus_space_barrier() seems not to be adequate because it can not cover two regions.

I believe that the bus_write semantic includes the required serialization.
E.g., on x86 all CPU write buffers are flushed before the write instruction
is declared completed, because this is the semantic of the uncacheable
memory.  For powerpc, the system automatically inserts powerpc_iomb() after
the write, which is full sync.  I am not aware of other architectures.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20150906180311.GS2072>