1186d6adaSFrançois Tigeot /* 2*2cecdd68SFrançois Tigeot * Copyright (c) 2015-2020 François Tigeot <ftigeot@wolfpond.org> 3186d6adaSFrançois Tigeot * All rights reserved. 4186d6adaSFrançois Tigeot * 5186d6adaSFrançois Tigeot * Redistribution and use in source and binary forms, with or without 6186d6adaSFrançois Tigeot * modification, are permitted provided that the following conditions 7186d6adaSFrançois Tigeot * are met: 8186d6adaSFrançois Tigeot * 1. Redistributions of source code must retain the above copyright 9186d6adaSFrançois Tigeot * notice unmodified, this list of conditions, and the following 10186d6adaSFrançois Tigeot * disclaimer. 11186d6adaSFrançois Tigeot * 2. Redistributions in binary form must reproduce the above copyright 12186d6adaSFrançois Tigeot * notice, this list of conditions and the following disclaimer in the 13186d6adaSFrançois Tigeot * documentation and/or other materials provided with the distribution. 14186d6adaSFrançois Tigeot * 15186d6adaSFrançois Tigeot * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16186d6adaSFrançois Tigeot * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17186d6adaSFrançois Tigeot * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18186d6adaSFrançois Tigeot * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19186d6adaSFrançois Tigeot * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20186d6adaSFrançois Tigeot * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21186d6adaSFrançois Tigeot * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22186d6adaSFrançois Tigeot * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23186d6adaSFrançois Tigeot * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24186d6adaSFrançois Tigeot * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25186d6adaSFrançois Tigeot */ 26186d6adaSFrançois Tigeot 27186d6adaSFrançois Tigeot #ifndef _ASM_BARRIER_H_ 28186d6adaSFrançois Tigeot #define _ASM_BARRIER_H_ 29186d6adaSFrançois Tigeot 30186d6adaSFrançois Tigeot #define mb() cpu_mfence() 31186d6adaSFrançois Tigeot #define rmb() cpu_lfence() 32186d6adaSFrançois Tigeot #define wmb() cpu_sfence() 33186d6adaSFrançois Tigeot 34186d6adaSFrançois Tigeot #define smp_mb() mb() 35186d6adaSFrançois Tigeot #define smp_rmb() rmb() 36186d6adaSFrançois Tigeot #define smp_wmb() barrier() 37186d6adaSFrançois Tigeot 381bc7ad41SFrançois Tigeot #define smp_store_mb(var, value) do { \ 391bc7ad41SFrançois Tigeot WRITE_ONCE(var, value); \ 401bc7ad41SFrançois Tigeot cpu_mfence(); \ 411bc7ad41SFrançois Tigeot } while (0) 421bc7ad41SFrançois Tigeot 43*2cecdd68SFrançois Tigeot #define smp_store_release(p, v) do { \ 44*2cecdd68SFrançois Tigeot cpu_ccfence(); \ 45*2cecdd68SFrançois Tigeot WRITE_ONCE(*p, v); \ 46*2cecdd68SFrançois Tigeot } while (0) 47*2cecdd68SFrançois Tigeot 48186d6adaSFrançois Tigeot #endif /* _ASM_BARRIER_H_ */ 49