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

powerpc/perf: Create mmcra_sihv/mmcra_sipv helpers

We want to access the MMCRA_SIHV and MMCRA_SIPR bits elsewhere so
create mmcra_sihv and mmcra_sipr which hide the differences between
the old and new layout of the bits.

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

authored by

Anton Blanchard and committed by
Benjamin Herrenschmidt
68b30bb9 962cffbd

+22 -9
+22 -9
arch/powerpc/perf/core-book3s.c
··· 116 116 *addrp = mfspr(SPRN_SDAR); 117 117 } 118 118 119 + static bool mmcra_sihv(unsigned long mmcra) 120 + { 121 + unsigned long sihv = MMCRA_SIHV; 122 + 123 + if (ppmu->flags & PPMU_ALT_SIPR) 124 + sihv = POWER6_MMCRA_SIHV; 125 + 126 + return !!(mmcra & sihv); 127 + } 128 + 129 + static bool mmcra_sipr(unsigned long mmcra) 130 + { 131 + unsigned long sipr = MMCRA_SIPR; 132 + 133 + if (ppmu->flags & PPMU_ALT_SIPR) 134 + sipr = POWER6_MMCRA_SIPR; 135 + 136 + return !!(mmcra & sipr); 137 + } 138 + 119 139 static inline u32 perf_flags_from_msr(struct pt_regs *regs) 120 140 { 121 141 if (regs->msr & MSR_PR) ··· 148 128 static inline u32 perf_get_misc_flags(struct pt_regs *regs) 149 129 { 150 130 unsigned long mmcra = regs->dsisr; 151 - unsigned long sihv = MMCRA_SIHV; 152 - unsigned long sipr = MMCRA_SIPR; 153 131 154 132 /* Not a PMU interrupt: Make up flags from regs->msr */ 155 133 if (TRAP(regs) != 0xf00) ··· 174 156 return PERF_RECORD_MISC_USER; 175 157 } 176 158 177 - if (ppmu->flags & PPMU_ALT_SIPR) { 178 - sihv = POWER6_MMCRA_SIHV; 179 - sipr = POWER6_MMCRA_SIPR; 180 - } 181 - 182 159 /* PR has priority over HV, so order below is important */ 183 - if (mmcra & sipr) 160 + if (mmcra_sipr(mmcra)) 184 161 return PERF_RECORD_MISC_USER; 185 - if ((mmcra & sihv) && (freeze_events_kernel != MMCR0_FCHV)) 162 + if (mmcra_sihv(mmcra) && (freeze_events_kernel != MMCR0_FCHV)) 186 163 return PERF_RECORD_MISC_HYPERVISOR; 187 164 return PERF_RECORD_MISC_KERNEL; 188 165 }