aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/oprofile/op_model_amd.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/oprofile/op_model_amd.c')
-rw-r--r--arch/x86/oprofile/op_model_amd.c80
1 files changed, 46 insertions, 34 deletions
diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
index 8fdf06e4edf9..b54c0880b7dc 100644
--- a/arch/x86/oprofile/op_model_amd.c
+++ b/arch/x86/oprofile/op_model_amd.c
@@ -220,6 +220,50 @@ op_amd_handle_ibs(struct pt_regs * const regs,
220 return 1; 220 return 1;
221} 221}
222 222
223static inline void op_amd_start_ibs(void)
224{
225 unsigned int low, high;
226 if (has_ibs && ibs_config.fetch_enabled) {
227 low = (ibs_config.max_cnt_fetch >> 4) & 0xFFFF;
228 high = ((ibs_config.rand_en & 0x1) << 25) /* bit 57 */
229 + IBS_FETCH_HIGH_ENABLE;
230 wrmsr(MSR_AMD64_IBSFETCHCTL, low, high);
231 }
232
233 if (has_ibs && ibs_config.op_enabled) {
234 low = ((ibs_config.max_cnt_op >> 4) & 0xFFFF)
235 + ((ibs_config.dispatched_ops & 0x1) << 19) /* bit 19 */
236 + IBS_OP_LOW_ENABLE;
237 high = 0;
238 wrmsr(MSR_AMD64_IBSOPCTL, low, high);
239 }
240}
241
242static void op_amd_stop_ibs(void)
243{
244 unsigned int low, high;
245 if (has_ibs && ibs_config.fetch_enabled) {
246 /* clear max count and enable */
247 low = 0;
248 high = 0;
249 wrmsr(MSR_AMD64_IBSFETCHCTL, low, high);
250 }
251
252 if (has_ibs && ibs_config.op_enabled) {
253 /* clear max count and enable */
254 low = 0;
255 high = 0;
256 wrmsr(MSR_AMD64_IBSOPCTL, low, high);
257 }
258}
259
260#else
261
262static inline int op_amd_handle_ibs(struct pt_regs * const regs,
263 struct op_msrs const * const msrs) { }
264static inline void op_amd_start_ibs(void) { }
265static inline void op_amd_stop_ibs(void) { }
266
223#endif 267#endif
224 268
225static int op_amd_check_ctrs(struct pt_regs * const regs, 269static int op_amd_check_ctrs(struct pt_regs * const regs,
@@ -238,9 +282,7 @@ static int op_amd_check_ctrs(struct pt_regs * const regs,
238 } 282 }
239 } 283 }
240 284
241#ifdef CONFIG_OPROFILE_IBS
242 op_amd_handle_ibs(regs, msrs); 285 op_amd_handle_ibs(regs, msrs);
243#endif
244 286
245 /* See op_model_ppro.c */ 287 /* See op_model_ppro.c */
246 return 1; 288 return 1;
@@ -258,25 +300,9 @@ static void op_amd_start(struct op_msrs const * const msrs)
258 } 300 }
259 } 301 }
260 302
261#ifdef CONFIG_OPROFILE_IBS 303 op_amd_start_ibs();
262 if (has_ibs && ibs_config.fetch_enabled) {
263 low = (ibs_config.max_cnt_fetch >> 4) & 0xFFFF;
264 high = ((ibs_config.rand_en & 0x1) << 25) /* bit 57 */
265 + IBS_FETCH_HIGH_ENABLE;
266 wrmsr(MSR_AMD64_IBSFETCHCTL, low, high);
267 }
268
269 if (has_ibs && ibs_config.op_enabled) {
270 low = ((ibs_config.max_cnt_op >> 4) & 0xFFFF)
271 + ((ibs_config.dispatched_ops & 0x1) << 19) /* bit 19 */
272 + IBS_OP_LOW_ENABLE;
273 high = 0;
274 wrmsr(MSR_AMD64_IBSOPCTL, low, high);
275 }
276#endif
277} 304}
278 305
279
280static void op_amd_stop(struct op_msrs const * const msrs) 306static void op_amd_stop(struct op_msrs const * const msrs)
281{ 307{
282 unsigned int low, high; 308 unsigned int low, high;
@@ -294,21 +320,7 @@ static void op_amd_stop(struct op_msrs const * const msrs)
294 CTRL_WRITE(low, high, msrs, i); 320 CTRL_WRITE(low, high, msrs, i);
295 } 321 }
296 322
297#ifdef CONFIG_OPROFILE_IBS 323 op_amd_stop_ibs();
298 if (has_ibs && ibs_config.fetch_enabled) {
299 /* clear max count and enable */
300 low = 0;
301 high = 0;
302 wrmsr(MSR_AMD64_IBSFETCHCTL, low, high);
303 }
304
305 if (has_ibs && ibs_config.op_enabled) {
306 /* clear max count and enable */
307 low = 0;
308 high = 0;
309 wrmsr(MSR_AMD64_IBSOPCTL, low, high);
310 }
311#endif
312} 324}
313 325
314static void op_amd_shutdown(struct op_msrs const * const msrs) 326static void op_amd_shutdown(struct op_msrs const * const msrs)