Skip to content

Commit 97e914b

Browse files
Mark Tomlinsonpaulburton
authored andcommitted
MIPS: cavium_octeon: Fix syncw generation.
The Cavium Octeon CPU uses a special sync instruction for implementing wmb, and due to a CPU bug, the instruction must appear twice. A macro had been defined to hide this: #define __SYNC_rpt(type) (1 + (type == __SYNC_wmb)) which was intended to evaluate to 2 for __SYNC_wmb, and 1 for any other type of sync. However, this expression is evaluated by the assembler, and not the compiler, and the result of '==' in the assembler is 0 or -1, not 0 or 1 as it is in C. The net result was wmb() producing no code at all. The simple fix in this patch is to change the '+' to '-'. Fixes: bf92927 ("MIPS: barrier: Add __SYNC() infrastructure") Signed-off-by: Mark Tomlinson <[email protected]> Tested-by: Chris Packham <[email protected]> Signed-off-by: Paul Burton <[email protected]> Cc: [email protected] Cc: [email protected]
1 parent 976c23a commit 97e914b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

arch/mips/include/asm/sync.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,11 @@
155155
* effective barrier as noted by commit 6b07d38aaa52 ("MIPS: Octeon: Use
156156
* optimized memory barrier primitives."). Here we specify that the affected
157157
* sync instructions should be emitted twice.
158+
* Note that this expression is evaluated by the assembler (not the compiler),
159+
* and that the assembler evaluates '==' as 0 or -1, not 0 or 1.
158160
*/
159161
#ifdef CONFIG_CPU_CAVIUM_OCTEON
160-
# define __SYNC_rpt(type) (1 + (type == __SYNC_wmb))
162+
# define __SYNC_rpt(type) (1 - (type == __SYNC_wmb))
161163
#else
162164
# define __SYNC_rpt(type) 1
163165
#endif

0 commit comments

Comments
 (0)