diff options
Diffstat (limited to 'arch/x86/oprofile/op_model_amd.c')
| -rw-r--r-- | arch/x86/oprofile/op_model_amd.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c index 8ff657b3ff89..98658f25f542 100644 --- a/arch/x86/oprofile/op_model_amd.c +++ b/arch/x86/oprofile/op_model_amd.c | |||
| @@ -106,11 +106,6 @@ struct ibs_op_sample { | |||
| 106 | unsigned int ibs_dc_phys_high; | 106 | unsigned int ibs_dc_phys_high; |
| 107 | }; | 107 | }; |
| 108 | 108 | ||
| 109 | /* | ||
| 110 | * unitialize the APIC for the IBS interrupts if needed on AMD Family10h+ | ||
| 111 | */ | ||
| 112 | static void clear_ibs_nmi(void); | ||
| 113 | |||
| 114 | static int ibs_allowed; /* AMD Family10h and later */ | 109 | static int ibs_allowed; /* AMD Family10h and later */ |
| 115 | 110 | ||
| 116 | struct op_ibs_config { | 111 | struct op_ibs_config { |
| @@ -390,7 +385,7 @@ static inline void apic_clear_ibs_nmi_per_cpu(void *arg) | |||
| 390 | setup_APIC_eilvt_ibs(0, APIC_EILVT_MSG_FIX, 1); | 385 | setup_APIC_eilvt_ibs(0, APIC_EILVT_MSG_FIX, 1); |
| 391 | } | 386 | } |
| 392 | 387 | ||
| 393 | static int pfm_amd64_setup_eilvt(void) | 388 | static int init_ibs_nmi(void) |
| 394 | { | 389 | { |
| 395 | #define IBSCTL_LVTOFFSETVAL (1 << 8) | 390 | #define IBSCTL_LVTOFFSETVAL (1 << 8) |
| 396 | #define IBSCTL 0x1cc | 391 | #define IBSCTL 0x1cc |
| @@ -438,15 +433,22 @@ static int pfm_amd64_setup_eilvt(void) | |||
| 438 | return 0; | 433 | return 0; |
| 439 | } | 434 | } |
| 440 | 435 | ||
| 436 | /* uninitialize the APIC for the IBS interrupts if needed */ | ||
| 437 | static void clear_ibs_nmi(void) | ||
| 438 | { | ||
| 439 | if (ibs_allowed) | ||
| 440 | on_each_cpu(apic_clear_ibs_nmi_per_cpu, NULL, 1); | ||
| 441 | } | ||
| 442 | |||
| 441 | /* initialize the APIC for the IBS interrupts if available */ | 443 | /* initialize the APIC for the IBS interrupts if available */ |
| 442 | static void setup_ibs(void) | 444 | static void ibs_init(void) |
| 443 | { | 445 | { |
| 444 | ibs_allowed = boot_cpu_has(X86_FEATURE_IBS); | 446 | ibs_allowed = boot_cpu_has(X86_FEATURE_IBS); |
| 445 | 447 | ||
| 446 | if (!ibs_allowed) | 448 | if (!ibs_allowed) |
| 447 | return; | 449 | return; |
| 448 | 450 | ||
| 449 | if (pfm_amd64_setup_eilvt()) { | 451 | if (init_ibs_nmi()) { |
| 450 | ibs_allowed = 0; | 452 | ibs_allowed = 0; |
| 451 | return; | 453 | return; |
| 452 | } | 454 | } |
| @@ -454,12 +456,12 @@ static void setup_ibs(void) | |||
| 454 | printk(KERN_INFO "oprofile: AMD IBS detected\n"); | 456 | printk(KERN_INFO "oprofile: AMD IBS detected\n"); |
| 455 | } | 457 | } |
| 456 | 458 | ||
| 457 | 459 | static void ibs_exit(void) | |
| 458 | /* uninitialize the APIC for the IBS interrupts if needed */ | ||
| 459 | static void clear_ibs_nmi(void) | ||
| 460 | { | 460 | { |
| 461 | if (ibs_allowed) | 461 | if (!ibs_allowed) |
| 462 | on_each_cpu(apic_clear_ibs_nmi_per_cpu, NULL, 1); | 462 | return; |
| 463 | |||
| 464 | clear_ibs_nmi(); | ||
| 463 | } | 465 | } |
| 464 | 466 | ||
| 465 | static int (*create_arch_files)(struct super_block *sb, struct dentry *root); | 467 | static int (*create_arch_files)(struct super_block *sb, struct dentry *root); |
| @@ -509,7 +511,7 @@ static int setup_ibs_files(struct super_block *sb, struct dentry *root) | |||
| 509 | 511 | ||
| 510 | static int op_amd_init(struct oprofile_operations *ops) | 512 | static int op_amd_init(struct oprofile_operations *ops) |
| 511 | { | 513 | { |
| 512 | setup_ibs(); | 514 | ibs_init(); |
| 513 | create_arch_files = ops->create_files; | 515 | create_arch_files = ops->create_files; |
| 514 | ops->create_files = setup_ibs_files; | 516 | ops->create_files = setup_ibs_files; |
| 515 | return 0; | 517 | return 0; |
| @@ -517,7 +519,7 @@ static int op_amd_init(struct oprofile_operations *ops) | |||
| 517 | 519 | ||
| 518 | static void op_amd_exit(void) | 520 | static void op_amd_exit(void) |
| 519 | { | 521 | { |
| 520 | clear_ibs_nmi(); | 522 | ibs_exit(); |
| 521 | } | 523 | } |
| 522 | 524 | ||
| 523 | #else | 525 | #else |
