Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: Barrier: Add definitions of SYNC stype values

Add the definitions of sync stype 0 (global completion barrier) and sync
stype 0x10 (local ordering barrier) to barrier.h for use with the sync
instruction.

These types are defined by the MIPS Instruction Set since R2 of the
architecture and are documented in document MD00087 table 6.5.

Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
Reviewed-by: Paul Burton <paul.burton@imgtec.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/14222/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

Matt Redfearn and committed by
Ralf Baechle
6622ada3 f6b43d93

+96
+96
arch/mips/include/asm/barrier.h
··· 10 10 11 11 #include <asm/addrspace.h> 12 12 13 + /* 14 + * Sync types defined by the MIPS architecture (document MD00087 table 6.5) 15 + * These values are used with the sync instruction to perform memory barriers. 16 + * Types of ordering guarantees available through the SYNC instruction: 17 + * - Completion Barriers 18 + * - Ordering Barriers 19 + * As compared to the completion barrier, the ordering barrier is a 20 + * lighter-weight operation as it does not require the specified instructions 21 + * before the SYNC to be already completed. Instead it only requires that those 22 + * specified instructions which are subsequent to the SYNC in the instruction 23 + * stream are never re-ordered for processing ahead of the specified 24 + * instructions which are before the SYNC in the instruction stream. 25 + * This potentially reduces how many cycles the barrier instruction must stall 26 + * before it completes. 27 + * Implementations that do not use any of the non-zero values of stype to define 28 + * different barriers, such as ordering barriers, must make those stype values 29 + * act the same as stype zero. 30 + */ 31 + 32 + /* 33 + * Completion barriers: 34 + * - Every synchronizable specified memory instruction (loads or stores or both) 35 + * that occurs in the instruction stream before the SYNC instruction must be 36 + * already globally performed before any synchronizable specified memory 37 + * instructions that occur after the SYNC are allowed to be performed, with 38 + * respect to any other processor or coherent I/O module. 39 + * 40 + * - The barrier does not guarantee the order in which instruction fetches are 41 + * performed. 42 + * 43 + * - A stype value of zero will always be defined such that it performs the most 44 + * complete set of synchronization operations that are defined.This means 45 + * stype zero always does a completion barrier that affects both loads and 46 + * stores preceding the SYNC instruction and both loads and stores that are 47 + * subsequent to the SYNC instruction. Non-zero values of stype may be defined 48 + * by the architecture or specific implementations to perform synchronization 49 + * behaviors that are less complete than that of stype zero. If an 50 + * implementation does not use one of these non-zero values to define a 51 + * different synchronization behavior, then that non-zero value of stype must 52 + * act the same as stype zero completion barrier. This allows software written 53 + * for an implementation with a lighter-weight barrier to work on another 54 + * implementation which only implements the stype zero completion barrier. 55 + * 56 + * - A completion barrier is required, potentially in conjunction with SSNOP (in 57 + * Release 1 of the Architecture) or EHB (in Release 2 of the Architecture), 58 + * to guarantee that memory reference results are visible across operating 59 + * mode changes. For example, a completion barrier is required on some 60 + * implementations on entry to and exit from Debug Mode to guarantee that 61 + * memory effects are handled correctly. 62 + */ 63 + 64 + /* 65 + * stype 0 - A completion barrier that affects preceding loads and stores and 66 + * subsequent loads and stores. 67 + * Older instructions which must reach the load/store ordering point before the 68 + * SYNC instruction completes: Loads, Stores 69 + * Younger instructions which must reach the load/store ordering point only 70 + * after the SYNC instruction completes: Loads, Stores 71 + * Older instructions which must be globally performed when the SYNC instruction 72 + * completes: Loads, Stores 73 + */ 74 + #define STYPE_SYNC 0x0 75 + 76 + /* 77 + * Ordering barriers: 78 + * - Every synchronizable specified memory instruction (loads or stores or both) 79 + * that occurs in the instruction stream before the SYNC instruction must 80 + * reach a stage in the load/store datapath after which no instruction 81 + * re-ordering is possible before any synchronizable specified memory 82 + * instruction which occurs after the SYNC instruction in the instruction 83 + * stream reaches the same stage in the load/store datapath. 84 + * 85 + * - If any memory instruction before the SYNC instruction in program order, 86 + * generates a memory request to the external memory and any memory 87 + * instruction after the SYNC instruction in program order also generates a 88 + * memory request to external memory, the memory request belonging to the 89 + * older instruction must be globally performed before the time the memory 90 + * request belonging to the younger instruction is globally performed. 91 + * 92 + * - The barrier does not guarantee the order in which instruction fetches are 93 + * performed. 94 + */ 95 + 96 + /* 97 + * stype 0x10 - An ordering barrier that affects preceding loads and stores and 98 + * subsequent loads and stores. 99 + * Older instructions which must reach the load/store ordering point before the 100 + * SYNC instruction completes: Loads, Stores 101 + * Younger instructions which must reach the load/store ordering point only 102 + * after the SYNC instruction completes: Loads, Stores 103 + * Older instructions which must be globally performed when the SYNC instruction 104 + * completes: N/A 105 + */ 106 + #define STYPE_SYNC_MB 0x10 107 + 108 + 13 109 #ifdef CONFIG_CPU_HAS_SYNC 14 110 #define __sync() \ 15 111 __asm__ __volatile__( \