powerpc: Don't hide eh field of lwarx behind a macro
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Tue, 2 Aug 2022 09:02:37 +0000 (11:02 +0200)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 10 Aug 2022 05:32:02 +0000 (15:32 +1000)
The eh field must remain 0 for PPC32 and is only used
by PPC64.

Don't hide that behind a macro, just leave the responsibility
to the user.

At the time being, the only users of PPC_RAW_L{WDQ}ARX are
setting the eh field to 0, so the special handling of __PPC_EH
is useless. Just take the value given by the caller.

Same for DEFINE_TESTOP(), don't do special handling in that
macro, ensure the caller hands over the proper eh value.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
[mpe: Use 'n' constraint per Segher]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/8b9c8a1a14f9143552a85fcbf96698224a8c2469.1659430931.git.christophe.leroy@csgroup.eu
arch/powerpc/include/asm/bitops.h
arch/powerpc/include/asm/ppc-opcode.h

index 344fba3b16eb1f9c1699d56e80b267389dfdddc9..7e0f0322912b6bd90119dae29fee999f3273593a 100644 (file)
@@ -163,7 +163,7 @@ static inline unsigned long fn(                     \
        "bne- 1b\n"                                     \
        postfix                                         \
        : "=&r" (old), "=&r" (t)                        \
-       : "rK" (mask), "r" (p), "i" (IS_ENABLED(CONFIG_PPC64) ? eh : 0) \
+       : "rK" (mask), "r" (p), "n" (eh)                \
        : "cc", "memory");                              \
        return (old & mask);                            \
 }
@@ -171,7 +171,7 @@ static inline unsigned long fn(                     \
 DEFINE_TESTOP(test_and_set_bits, or, PPC_ATOMIC_ENTRY_BARRIER,
              PPC_ATOMIC_EXIT_BARRIER, 0)
 DEFINE_TESTOP(test_and_set_bits_lock, or, "",
-             PPC_ACQUIRE_BARRIER, 1)
+             PPC_ACQUIRE_BARRIER, IS_ENABLED(CONFIG_PPC64))
 DEFINE_TESTOP(test_and_change_bits, xor, PPC_ATOMIC_ENTRY_BARRIER,
              PPC_ATOMIC_EXIT_BARRIER, 0)
 
index 7b81b37a191ea53cebf39d95d3c8326fa4eb19e2..d9703c5fd71347471a0982aae81a63961848405d 100644 (file)
 #define __PPC_SPR(r)   ((((r) & 0x1f) << 16) | ((((r) >> 5) & 0x1f) << 11))
 #define __PPC_RC21     (0x1 << 10)
 #define __PPC_PRFX_R(r)        (((r) & 0x1) << 20)
+#define __PPC_EH(eh)   (((eh) & 0x1) << 0)
 
 /*
  * Both low and high 16 bits are added as SIGNED additions, so if low 16 bits
 #define PPC_LI_MASK    0x03fffffc
 #define PPC_LI(v)      ((v) & PPC_LI_MASK)
 
-/*
- * Only use the larx hint bit on 64bit CPUs. e500v1/v2 based CPUs will treat a
- * larx with EH set as an illegal instruction.
- */
-#ifdef CONFIG_PPC64
-#define __PPC_EH(eh)   (((eh) & 0x1) << 0)
-#else
-#define __PPC_EH(eh)   0
-#endif
-
 /* Base instruction encoding */
 #define PPC_RAW_CP_ABORT               (0x7c00068c)
 #define PPC_RAW_COPY(a, b)             (PPC_INST_COPY | ___PPC_RA(a) | ___PPC_RB(b))