From becce2aedc7ee62641f381d380af4f4a7b04fd6f Mon Sep 17 00:00:00 2001 From: Prarit Bhargava <prarit@redhat.com> Date: Thu, 3 Jul 2008 16:52:38 -0400 Subject: [PATCH] [x86_64]: extend MCE banks support for Dunnington, Nehalem Message-id: <20080617155241.3713.47987.sendpatchset@prarit.bos.redhat.com> O-Subject: [RHEL5 PATCH]: extend MCE banks support for Dunnington, Nehalem Bugzilla: 446673 Backport of http://marc.info/?t=121028166500001&r=1&w=2 Remove 6 bank limitation in 64 bit MCE reporting code. Newer Intel processors support more than 6 banks. Geoff Gustafson posted a similar patch for RHEL4 back in May. Tested by Intel. Compile and boot tested on Nehalem by me. Resolve BZ 445573. Acked-by: Brian Maly <bmaly@redhat.com> Acked-by: John Feeney <jfeeney@redhat.com> --- arch/x86_64/kernel/mce.c | 22 +++++++++++++--------- 1 files changed, 13 insertions(+), 9 deletions(-) diff --git a/arch/x86_64/kernel/mce.c b/arch/x86_64/kernel/mce.c index bbea888..d370a4e 100644 --- a/arch/x86_64/kernel/mce.c +++ b/arch/x86_64/kernel/mce.c @@ -27,7 +27,7 @@ #include <asm/smp.h> #define MISC_MCELOG_MINOR 227 -#define NR_BANKS 6 +#define NR_SYSFS_BANKS 6 atomic_t mce_entry; @@ -37,7 +37,7 @@ static int mce_dont_init; 3: never panic or exit (for testing only) */ static int tolerant = 1; static int banks; -static unsigned long bank[NR_BANKS] = { [0 ... NR_BANKS-1] = ~0UL }; +static unsigned long bank[NR_SYSFS_BANKS] = { [0 ... NR_SYSFS_BANKS-1] = ~0UL }; static unsigned long console_logged; static int notify_user; static int rip_msr; @@ -191,7 +191,7 @@ void do_machine_check(struct pt_regs * regs, long error_code) barrier(); for (i = 0; i < banks; i++) { - if (!bank[i]) + if (i < NR_SYSFS_BANKS && !bank[i]) continue; m.misc = 0; @@ -354,9 +354,10 @@ static void mce_init(void *dummy) rdmsrl(MSR_IA32_MCG_CAP, cap); banks = cap & 0xff; - if (banks > NR_BANKS) { - printk(KERN_INFO "MCE: warning: using only %d banks\n", banks); - banks = NR_BANKS; + if (banks > MCE_EXTENDED_BANK) { + printk(KERN_INFO "MCE: warning: using only %d banks\n", + MCE_EXTENDED_BANK); + banks = MCE_EXTENDED_BANK; } /* Use accurate RIP reporting if available. */ if ((cap & (1<<9)) && ((cap >> 16) & 0xff) >= 9) @@ -372,7 +373,7 @@ static void mce_init(void *dummy) wrmsr(MSR_IA32_MCG_CTL, 0xffffffff, 0xffffffff); for (i = 0; i < banks; i++) { - wrmsrl(MSR_IA32_MC0_CTL+4*i, bank[i]); + wrmsrl(MSR_IA32_MC0_CTL+4*i, ~0UL); wrmsrl(MSR_IA32_MC0_STATUS+4*i, 0); } } @@ -606,13 +607,16 @@ DEFINE_PER_CPU(struct sys_device, device_mce); } \ static SYSDEV_ATTR(name, 0644, show_ ## name, set_ ## name); +/* TBD should generate these dynamically based on number of available banks. + * Have only 6 contol banks in /sysfs until then. + */ ACCESSOR(bank0ctl,bank[0],mce_restart()) ACCESSOR(bank1ctl,bank[1],mce_restart()) ACCESSOR(bank2ctl,bank[2],mce_restart()) ACCESSOR(bank3ctl,bank[3],mce_restart()) ACCESSOR(bank4ctl,bank[4],mce_restart()) ACCESSOR(bank5ctl,bank[5],mce_restart()) -static struct sysdev_attribute * bank_attributes[NR_BANKS] = { +static struct sysdev_attribute * bank_attributes[NR_SYSFS_BANKS] = { &attr_bank0ctl, &attr_bank1ctl, &attr_bank2ctl, &attr_bank3ctl, &attr_bank4ctl, &attr_bank5ctl}; ACCESSOR(tolerant,tolerant,) @@ -632,7 +636,7 @@ static __cpuinit int mce_create_device(unsigned int cpu) err = sysdev_register(&per_cpu(device_mce,cpu)); if (!err) { - for (i = 0; i < banks; i++) + for (i = 0; i < NR_SYSFS_BANKS; i++) sysdev_create_file(&per_cpu(device_mce,cpu), bank_attributes[i]); sysdev_create_file(&per_cpu(device_mce,cpu), &attr_tolerant); -- 1.5.5.1