1*4f8ce3b3Sriastradh/* $NetBSD: membar_ops.S,v 1.9 2022/04/09 23:32:52 riastradh Exp $ */ 277ca26a2Sad 377ca26a2Sad/*- 477ca26a2Sad * Copyright (c) 2007 The NetBSD Foundation, Inc. 577ca26a2Sad * All rights reserved. 677ca26a2Sad * 777ca26a2Sad * This code is derived from software contributed to The NetBSD Foundation 877ca26a2Sad * by Jason R. Thorpe, and by Andrew Doran. 977ca26a2Sad * 1077ca26a2Sad * Redistribution and use in source and binary forms, with or without 1177ca26a2Sad * modification, are permitted provided that the following conditions 1277ca26a2Sad * are met: 1377ca26a2Sad * 1. Redistributions of source code must retain the above copyright 1477ca26a2Sad * notice, this list of conditions and the following disclaimer. 1577ca26a2Sad * 2. Redistributions in binary form must reproduce the above copyright 1677ca26a2Sad * notice, this list of conditions and the following disclaimer in the 1777ca26a2Sad * documentation and/or other materials provided with the distribution. 1877ca26a2Sad * 1977ca26a2Sad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 2077ca26a2Sad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 2177ca26a2Sad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2277ca26a2Sad * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 2377ca26a2Sad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2477ca26a2Sad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2577ca26a2Sad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2677ca26a2Sad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2777ca26a2Sad * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2877ca26a2Sad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 2977ca26a2Sad * POSSIBILITY OF SUCH DAMAGE. 3077ca26a2Sad */ 3177ca26a2Sad 3277ca26a2Sad#include "atomic_op_asm.h" 3377ca26a2Sad 3477ca26a2Sad .text 3577ca26a2Sad 36ffe06880Sriastradh/* 37ffe06880Sriastradh * These assume Total Store Order (TSO), which may reorder 3848b2cb5aSriastradh * store-before-load but nothing else. Hence, only membar_sync (and 3948b2cb5aSriastradh * its deprecated alias membar_enter) must issue anything -- namely, 4048b2cb5aSriastradh * membar #StoreLoad. 41ffe06880Sriastradh * 42ffe06880Sriastradh * If we ran with Partial Store Order (PSO), we would also need to 43ffe06880Sriastradh * issue membar #StoreStore for membar_exit (load/store-before-store) 44ffe06880Sriastradh * and membar_producer (store-before-store). 45ffe06880Sriastradh */ 4677ca26a2Sad 47*4f8ce3b3SriastradhENTRY(_membar_acquire) 48f6c08490Sad retl 49f6c08490Sad nop 50*4f8ce3b3SriastradhEND(_membar_acquire) 51*4f8ce3b3SriastradhATOMIC_OP_ALIAS(membar_acquire,_membar_acquire) 52*4f8ce3b3Sriastradh 53*4f8ce3b3SriastradhENTRY(_membar_release) 54*4f8ce3b3Sriastradh retl 55*4f8ce3b3Sriastradh nop 56*4f8ce3b3SriastradhEND(_membar_release) 57*4f8ce3b3SriastradhATOMIC_OP_ALIAS(membar_release,_membar_release) 5877ca26a2Sad 59ffe06880SriastradhENTRY(_membar_sync) 60ffe06880Sriastradh /* 61ffe06880Sriastradh * Some SPARC CPUs have errata with MEMBAR in the delay slot of 62ffe06880Sriastradh * a branch, such as the UltraSPARC-IIi: 63ffe06880Sriastradh * 64ffe06880Sriastradh * `Apparently, the deadlock is most easily caused if the 65ffe06880Sriastradh * delay slot of the JMPL is a MEMBAR #Sync, or any 66ffe06880Sriastradh * instruction that synchronizes on the load or store 67ffe06880Sriastradh * buffers being empty.' 68ffe06880Sriastradh * 69ffe06880Sriastradh * UltraSPARC-IIi User's Manual, Part No. 805-0087-01, Sun 70ffe06880Sriastradh * Microsystems, October 1997, Appendix K.2 `Errata 71ffe06880Sriastradh * Created by UltraSPARC-I', Erratum 51, p. 476. 72ffe06880Sriastradh * https://www.oracle.com/technetwork/server-storage/sun-sparc-enterprise/documentation/sparc-2i-usersmanual-2516677.pdf#page=518 73ffe06880Sriastradh * 74ffe06880Sriastradh * So let's avoid doing that. 75ffe06880Sriastradh */ 76ffe06880Sriastradh membar #StoreLoad 77ffe06880Sriastradh retl 78ffe06880Sriastradh nop 79ffe06880SriastradhEND(_membar_sync) 80*4f8ce3b3SriastradhATOMIC_OP_ALIAS(membar_sync,_membar_sync) 81ffe06880Sriastradh 82*4f8ce3b3SriastradhATOMIC_OP_ALIAS(membar_producer,_membar_release) 83*4f8ce3b3SriastradhSTRONG_ALIAS(_membar_producer,_membar_release) 84*4f8ce3b3SriastradhATOMIC_OP_ALIAS(membar_consumer,_membar_acquire) 85*4f8ce3b3SriastradhSTRONG_ALIAS(_membar_consumer,_membar_acquire) 8648b2cb5aSriastradhATOMIC_OP_ALIAS(membar_enter,_membar_sync) 8748b2cb5aSriastradhSTRONG_ALIAS(_membar_enter,_membar_sync) 88*4f8ce3b3SriastradhATOMIC_OP_ALIAS(membar_exit,_membar_release) 89*4f8ce3b3SriastradhSTRONG_ALIAS(_membar_exit,_membar_release) 90