diff options
| -rw-r--r-- | arch/x86/kernel/cpu/mcheck/mce_amd.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mcheck/mce_amd.c index e3d81a8d646b..9cb52767999a 100644 --- a/arch/x86/kernel/cpu/mcheck/mce_amd.c +++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c | |||
| @@ -33,7 +33,6 @@ | |||
| 33 | #include <asm/mce.h> | 33 | #include <asm/mce.h> |
| 34 | #include <asm/msr.h> | 34 | #include <asm/msr.h> |
| 35 | 35 | ||
| 36 | #define NR_BANKS 6 | ||
| 37 | #define NR_BLOCKS 9 | 36 | #define NR_BLOCKS 9 |
| 38 | #define THRESHOLD_MAX 0xFFF | 37 | #define THRESHOLD_MAX 0xFFF |
| 39 | #define INT_TYPE_APIC 0x00020000 | 38 | #define INT_TYPE_APIC 0x00020000 |
| @@ -57,7 +56,7 @@ static const char * const th_names[] = { | |||
| 57 | "execution_unit", | 56 | "execution_unit", |
| 58 | }; | 57 | }; |
| 59 | 58 | ||
| 60 | static DEFINE_PER_CPU(struct threshold_bank * [NR_BANKS], threshold_banks); | 59 | static DEFINE_PER_CPU(struct threshold_bank **, threshold_banks); |
| 61 | static DEFINE_PER_CPU(unsigned char, bank_map); /* see which banks are on */ | 60 | static DEFINE_PER_CPU(unsigned char, bank_map); /* see which banks are on */ |
| 62 | 61 | ||
| 63 | static void amd_threshold_interrupt(void); | 62 | static void amd_threshold_interrupt(void); |
| @@ -215,7 +214,7 @@ void mce_amd_feature_init(struct cpuinfo_x86 *c) | |||
| 215 | unsigned int bank, block; | 214 | unsigned int bank, block; |
| 216 | int offset = -1; | 215 | int offset = -1; |
| 217 | 216 | ||
| 218 | for (bank = 0; bank < NR_BANKS; ++bank) { | 217 | for (bank = 0; bank < mca_cfg.banks; ++bank) { |
| 219 | for (block = 0; block < NR_BLOCKS; ++block) { | 218 | for (block = 0; block < NR_BLOCKS; ++block) { |
| 220 | if (block == 0) | 219 | if (block == 0) |
| 221 | address = MSR_IA32_MC0_MISC + bank * 4; | 220 | address = MSR_IA32_MC0_MISC + bank * 4; |
| @@ -277,7 +276,7 @@ static void amd_threshold_interrupt(void) | |||
| 277 | mce_setup(&m); | 276 | mce_setup(&m); |
| 278 | 277 | ||
| 279 | /* assume first bank caused it */ | 278 | /* assume first bank caused it */ |
| 280 | for (bank = 0; bank < NR_BANKS; ++bank) { | 279 | for (bank = 0; bank < mca_cfg.banks; ++bank) { |
| 281 | if (!(per_cpu(bank_map, m.cpu) & (1 << bank))) | 280 | if (!(per_cpu(bank_map, m.cpu) & (1 << bank))) |
| 282 | continue; | 281 | continue; |
| 283 | for (block = 0; block < NR_BLOCKS; ++block) { | 282 | for (block = 0; block < NR_BLOCKS; ++block) { |
| @@ -468,7 +467,7 @@ static __cpuinit int allocate_threshold_blocks(unsigned int cpu, | |||
| 468 | u32 low, high; | 467 | u32 low, high; |
| 469 | int err; | 468 | int err; |
| 470 | 469 | ||
| 471 | if ((bank >= NR_BANKS) || (block >= NR_BLOCKS)) | 470 | if ((bank >= mca_cfg.banks) || (block >= NR_BLOCKS)) |
| 472 | return 0; | 471 | return 0; |
| 473 | 472 | ||
| 474 | if (rdmsr_safe_on_cpu(cpu, address, &low, &high)) | 473 | if (rdmsr_safe_on_cpu(cpu, address, &low, &high)) |
| @@ -636,9 +635,17 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank) | |||
| 636 | static __cpuinit int threshold_create_device(unsigned int cpu) | 635 | static __cpuinit int threshold_create_device(unsigned int cpu) |
| 637 | { | 636 | { |
| 638 | unsigned int bank; | 637 | unsigned int bank; |
| 638 | struct threshold_bank **bp; | ||
| 639 | int err = 0; | 639 | int err = 0; |
| 640 | 640 | ||
| 641 | for (bank = 0; bank < NR_BANKS; ++bank) { | 641 | bp = kzalloc(sizeof(struct threshold_bank *) * mca_cfg.banks, |
| 642 | GFP_KERNEL); | ||
| 643 | if (!bp) | ||
| 644 | return -ENOMEM; | ||
| 645 | |||
| 646 | per_cpu(threshold_banks, cpu) = bp; | ||
| 647 | |||
| 648 | for (bank = 0; bank < mca_cfg.banks; ++bank) { | ||
| 642 | if (!(per_cpu(bank_map, cpu) & (1 << bank))) | 649 | if (!(per_cpu(bank_map, cpu) & (1 << bank))) |
| 643 | continue; | 650 | continue; |
| 644 | err = threshold_create_bank(cpu, bank); | 651 | err = threshold_create_bank(cpu, bank); |
| @@ -720,11 +727,12 @@ static void threshold_remove_device(unsigned int cpu) | |||
| 720 | { | 727 | { |
| 721 | unsigned int bank; | 728 | unsigned int bank; |
| 722 | 729 | ||
| 723 | for (bank = 0; bank < NR_BANKS; ++bank) { | 730 | for (bank = 0; bank < mca_cfg.banks; ++bank) { |
| 724 | if (!(per_cpu(bank_map, cpu) & (1 << bank))) | 731 | if (!(per_cpu(bank_map, cpu) & (1 << bank))) |
| 725 | continue; | 732 | continue; |
| 726 | threshold_remove_bank(cpu, bank); | 733 | threshold_remove_bank(cpu, bank); |
| 727 | } | 734 | } |
| 735 | kfree(per_cpu(threshold_banks, cpu)); | ||
| 728 | } | 736 | } |
| 729 | 737 | ||
| 730 | /* get notified when a cpu comes on/off */ | 738 | /* get notified when a cpu comes on/off */ |
