xref: /freebsd/lib/libc/arm/gen/arm_drain_writebuf.2 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
1*805eb13aSIan Lepore.\" Copyright (c) 2019 Ian Lepore <ian@FreeBSD.org>
2*805eb13aSIan Lepore.\"
3*805eb13aSIan Lepore.\" Redistribution and use in source and binary forms, with or without
4*805eb13aSIan Lepore.\" modification, are permitted provided that the following conditions
5*805eb13aSIan Lepore.\" are met:
6*805eb13aSIan Lepore.\" 1. Redistributions of source code must retain the above copyright
7*805eb13aSIan Lepore.\"    notice, this list of conditions and the following disclaimer.
8*805eb13aSIan Lepore.\" 2. Redistributions in binary form must reproduce the above copyright
9*805eb13aSIan Lepore.\"    notice, this list of conditions and the following disclaimer in the
10*805eb13aSIan Lepore.\"    documentation and/or other materials provided with the distribution.
11*805eb13aSIan Lepore.\"
12*805eb13aSIan Lepore.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
13*805eb13aSIan Lepore.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14*805eb13aSIan Lepore.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15*805eb13aSIan Lepore.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
16*805eb13aSIan Lepore.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
17*805eb13aSIan Lepore.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
18*805eb13aSIan Lepore.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19*805eb13aSIan Lepore.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20*805eb13aSIan Lepore.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
21*805eb13aSIan Lepore.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
22*805eb13aSIan Lepore.\" SUCH DAMAGE.
23*805eb13aSIan Lepore.\"
24*805eb13aSIan Lepore.Dd July 10, 2019
25*805eb13aSIan Lepore.Dt ARM_DRAIN_WRITEBUF 2
26*805eb13aSIan Lepore.Os
27*805eb13aSIan Lepore.Sh NAME
28*805eb13aSIan Lepore.Nm arm_drain_writebuf
29*805eb13aSIan Lepore.Nd drain pending writes from cores and caches
30*805eb13aSIan Lepore.Sh LIBRARY
31*805eb13aSIan Lepore.Lb libc
32*805eb13aSIan Lepore.Sh SYNOPSIS
33*805eb13aSIan Lepore.In machine/sysarch.h
34*805eb13aSIan Lepore.Ft int
35*805eb13aSIan Lepore.Fn arm_drain_writebuf void
36*805eb13aSIan Lepore.Sh DESCRIPTION
37*805eb13aSIan LeporeThe
38*805eb13aSIan Lepore.Nm
39*805eb13aSIan Leporesystem call causes all pending writes from ARM cores and caches to be
40*805eb13aSIan Leporewritten out to main memory or memory-mapped I/O registers.
41*805eb13aSIan LeporeNot all hardware supports buffered writes; on such systems the
42*805eb13aSIan Lepore.Nm
43*805eb13aSIan Leporefunction is a no-op.
44*805eb13aSIan Lepore.Pp
45*805eb13aSIan LeporeOn ARMv5 systems, this executes a cp15 coprocessor
46*805eb13aSIan Lepore.Dq drain write buffer
47*805eb13aSIan Leporeoperation.
48*805eb13aSIan LeporeOn ARMv6 and ARMv7 systems, this executes a
49*805eb13aSIan Lepore.Dq DSB SY
50*805eb13aSIan Leporesynchronization barrier, followed by an L2 cache drain on
51*805eb13aSIan Leporesystems where the DSB does not include L2 automatically.
52*805eb13aSIan Lepore.Pp
53*805eb13aSIan Lepore.Nm
54*805eb13aSIan Leporeattempts to wait for the drain operation to complete, but cannot
55*805eb13aSIan Leporeguarantee the writes have reached their ultimate destination on all hardware.
56*805eb13aSIan LeporeFor example, on an ARMv7 system,
57*805eb13aSIan Lepore.Nm
58*805eb13aSIan Leporetells the L2 cache controller to drain its buffers, and it waits until
59*805eb13aSIan Leporethe controller indicates that operation is complete.
60*805eb13aSIan LeporeHowever, all the L2 controller knows is that the data was accepted for
61*805eb13aSIan Leporedelivery by the AXI bus.
62*805eb13aSIan LeporeIf the ultimate destination of the write is a device on a subordinate
63*805eb13aSIan Leporebus connected to the AXI bus, more buffering or other delays may occur
64*805eb13aSIan Leporeon that subordinate bus.
65*805eb13aSIan LeporeThe only way to be certain a pending write has reached its
66*805eb13aSIan Leporeultimate destination is to issue a read from that destination after
67*805eb13aSIan Lepore.Nm
68*805eb13aSIan Leporereturns.
69*805eb13aSIan Lepore.Sh RETURN VALUES
70*805eb13aSIan LeporeThe
71*805eb13aSIan Lepore.Nm
72*805eb13aSIan Leporesystem call cannot fail, and always returns 0.
73*805eb13aSIan Lepore.Sh AUTHORS
74*805eb13aSIan LeporeThis man page was written by
75*805eb13aSIan Lepore.An Ian Lepore .
76