powerpc/ppc-opcode: Add PPC_RAW_MFSPR()
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Tue, 24 Nov 2020 15:24:59 +0000 (15:24 +0000)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 9 Dec 2020 12:48:13 +0000 (23:48 +1100)
Add PPC_RAW_MFSPR() to replace open coding done in 8xx-pmu.c

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/e281e3a611eead8817c49cf06a60072a021af823.1606231483.git.christophe.leroy@csgroup.eu
arch/powerpc/include/asm/ppc-opcode.h
arch/powerpc/perf/8xx-pmu.c

index a6e3700c4566adbe194f76643f2464bfdc16d2b1..da6f300e9788b4daeda81dd0f839df082fade825 100644 (file)
 #define PPC_INST_POPCNTB_MASK          0xfc0007fe
 #define PPC_INST_RFEBB                 0x4c000124
 #define PPC_INST_RFID                  0x4c000024
-#define PPC_INST_MFSPR                 0x7c0002a6
 #define PPC_INST_MFSPR_DSCR            0x7c1102a6
 #define PPC_INST_MFSPR_DSCR_MASK       0xfc1ffffe
 #define PPC_INST_MTSPR_DSCR            0x7c1103a6
 
 #define PPC_RAW_NEG(d, a)              (0x7c0000d0 | ___PPC_RT(d) | ___PPC_RA(a))
 
+#define PPC_RAW_MFSPR(d, spr)          (0x7c0002a6 | ___PPC_RT(d) | __PPC_SPR(spr))
+
 /* Deal with instructions that older assemblers aren't aware of */
 #define        PPC_BCCTR_FLUSH         stringify_in_c(.long PPC_INST_BCCTR_FLUSH)
 #define        PPC_CP_ABORT            stringify_in_c(.long PPC_RAW_CP_ABORT)
index 93004ee586a1a1d176705aac621ec4089533445d..f970d1510d3d7a4d89ce9f87590931849d8f8dc0 100644 (file)
@@ -153,10 +153,7 @@ static void mpc8xx_pmu_read(struct perf_event *event)
 
 static void mpc8xx_pmu_del(struct perf_event *event, int flags)
 {
-       struct ppc_inst insn;
-
-       /* mfspr r10, SPRN_SPRG_SCRATCH2 */
-       insn = ppc_inst(PPC_INST_MFSPR | __PPC_RS(R10) | __PPC_SPR(SPRN_SPRG_SCRATCH2));
+       struct ppc_inst insn = ppc_inst(PPC_RAW_MFSPR(10, SPRN_SPRG_SCRATCH2));
 
        mpc8xx_pmu_read(event);