Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 277492
b: refs/heads/master
c: a228b58
h: refs/heads/master
v: v3
  • Loading branch information
Ingo Molnar committed Dec 18, 2011
1 parent 08c5342 commit c37cc2d
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 39 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2c29d9dd577b74b44e580f957ea44d1df73af23a
refs/heads/master: a228b5892b0527b8574c06edc72cacaf8c25418d
3 changes: 2 additions & 1 deletion trunk/arch/x86/include/asm/mce.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ struct mce_log {

#ifdef __KERNEL__

extern struct atomic_notifier_head x86_mce_decoder_chain;
extern void mce_register_decode_chain(struct notifier_block *nb);
extern void mce_unregister_decode_chain(struct notifier_block *nb);

#include <linux/percpu.h>
#include <linux/init.h>
Expand Down
64 changes: 57 additions & 7 deletions trunk/arch/x86/kernel/cpu/mcheck/mce.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,19 @@ static DECLARE_WAIT_QUEUE_HEAD(mce_chrdev_wait);
static DEFINE_PER_CPU(struct mce, mces_seen);
static int cpu_missing;

/*
* CPU/chipset specific EDAC code can register a notifier call here to print
* MCE errors in a human-readable form.
*/
ATOMIC_NOTIFIER_HEAD(x86_mce_decoder_chain);
EXPORT_SYMBOL_GPL(x86_mce_decoder_chain);

/* MCA banks polled by the period polling timer for corrected events */
DEFINE_PER_CPU(mce_banks_t, mce_poll_banks) = {
[0 ... BITS_TO_LONGS(MAX_NR_BANKS)-1] = ~0UL
};

static DEFINE_PER_CPU(struct work_struct, mce_work);

/*
* CPU/chipset specific EDAC code can register a notifier call here to print
* MCE errors in a human-readable form.
*/
ATOMIC_NOTIFIER_HEAD(x86_mce_decoder_chain);

/* Do initial initialization of a struct mce */
void mce_setup(struct mce *m)
{
Expand Down Expand Up @@ -190,6 +189,57 @@ void mce_log(struct mce *mce)
set_bit(0, &mce_need_notify);
}

static void drain_mcelog_buffer(void)
{
unsigned int next, i, prev = 0;

next = rcu_dereference_check_mce(mcelog.next);

do {
struct mce *m;

/* drain what was logged during boot */
for (i = prev; i < next; i++) {
unsigned long start = jiffies;
unsigned retries = 1;

m = &mcelog.entry[i];

while (!m->finished) {
if (time_after_eq(jiffies, start + 2*retries))
retries++;

cpu_relax();

if (!m->finished && retries >= 4) {
pr_err("MCE: skipping error being logged currently!\n");
break;
}
}
smp_rmb();
atomic_notifier_call_chain(&x86_mce_decoder_chain, 0, m);
}

memset(mcelog.entry + prev, 0, (next - prev) * sizeof(*m));
prev = next;
next = cmpxchg(&mcelog.next, prev, 0);
} while (next != prev);
}


void mce_register_decode_chain(struct notifier_block *nb)
{
atomic_notifier_chain_register(&x86_mce_decoder_chain, nb);
drain_mcelog_buffer();
}
EXPORT_SYMBOL_GPL(mce_register_decode_chain);

void mce_unregister_decode_chain(struct notifier_block *nb)
{
atomic_notifier_chain_unregister(&x86_mce_decoder_chain, nb);
}
EXPORT_SYMBOL_GPL(mce_unregister_decode_chain);

static void print_mce(struct mce *m)
{
int ret = 0;
Expand Down
29 changes: 7 additions & 22 deletions trunk/arch/x86/kernel/cpu/mcheck/therm_throt.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,17 +323,6 @@ device_initcall(thermal_throttle_init_device);

#endif /* CONFIG_SYSFS */

/*
* Set up the most two significant bit to notify mce log that this thermal
* event type.
* This is a temp solution. May be changed in the future with mce log
* infrasture.
*/
#define CORE_THROTTLED (0)
#define CORE_POWER_LIMIT ((__u64)1 << 62)
#define PACKAGE_THROTTLED ((__u64)2 << 62)
#define PACKAGE_POWER_LIMIT ((__u64)3 << 62)

static void notify_thresholds(__u64 msr_val)
{
/* check whether the interrupt handler is defined;
Expand Down Expand Up @@ -363,27 +352,23 @@ static void intel_thermal_interrupt(void)
if (therm_throt_process(msr_val & THERM_STATUS_PROCHOT,
THERMAL_THROTTLING_EVENT,
CORE_LEVEL) != 0)
mce_log_therm_throt_event(CORE_THROTTLED | msr_val);
mce_log_therm_throt_event(msr_val);

if (this_cpu_has(X86_FEATURE_PLN))
if (therm_throt_process(msr_val & THERM_STATUS_POWER_LIMIT,
therm_throt_process(msr_val & THERM_STATUS_POWER_LIMIT,
POWER_LIMIT_EVENT,
CORE_LEVEL) != 0)
mce_log_therm_throt_event(CORE_POWER_LIMIT | msr_val);
CORE_LEVEL);

if (this_cpu_has(X86_FEATURE_PTS)) {
rdmsrl(MSR_IA32_PACKAGE_THERM_STATUS, msr_val);
if (therm_throt_process(msr_val & PACKAGE_THERM_STATUS_PROCHOT,
therm_throt_process(msr_val & PACKAGE_THERM_STATUS_PROCHOT,
THERMAL_THROTTLING_EVENT,
PACKAGE_LEVEL) != 0)
mce_log_therm_throt_event(PACKAGE_THROTTLED | msr_val);
PACKAGE_LEVEL);
if (this_cpu_has(X86_FEATURE_PLN))
if (therm_throt_process(msr_val &
therm_throt_process(msr_val &
PACKAGE_THERM_STATUS_POWER_LIMIT,
POWER_LIMIT_EVENT,
PACKAGE_LEVEL) != 0)
mce_log_therm_throt_event(PACKAGE_POWER_LIMIT
| msr_val);
PACKAGE_LEVEL);
}
}

Expand Down
4 changes: 2 additions & 2 deletions trunk/drivers/edac/i7core_edac.c
Original file line number Diff line number Diff line change
Expand Up @@ -2234,7 +2234,7 @@ static void i7core_unregister_mci(struct i7core_dev *i7core_dev)
if (pvt->enable_scrub)
disable_sdram_scrub_setting(mci);

atomic_notifier_chain_unregister(&x86_mce_decoder_chain, &i7_mce_dec);
mce_unregister_decode_chain(&i7_mce_dec);

/* Disable EDAC polling */
i7core_pci_ctl_release(pvt);
Expand Down Expand Up @@ -2336,7 +2336,7 @@ static int i7core_register_mci(struct i7core_dev *i7core_dev)
/* DCLK for scrub rate setting */
pvt->dclk_freq = get_dclk_freq();

atomic_notifier_chain_register(&x86_mce_decoder_chain, &i7_mce_dec);
mce_register_decode_chain(&i7_mce_dec);

return 0;

Expand Down
4 changes: 2 additions & 2 deletions trunk/drivers/edac/mce_amd.c
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ static int __init mce_amd_init(void)

pr_info("MCE: In-kernel MCE decoding enabled.\n");

atomic_notifier_chain_register(&x86_mce_decoder_chain, &amd_mce_dec_nb);
mce_register_decode_chain(&amd_mce_dec_nb);

return 0;
}
Expand All @@ -893,7 +893,7 @@ early_initcall(mce_amd_init);
#ifdef MODULE
static void __exit mce_amd_exit(void)
{
atomic_notifier_chain_unregister(&x86_mce_decoder_chain, &amd_mce_dec_nb);
mce_unregister_decode_chain(&amd_mce_dec_nb);
kfree(fam_ops);
}

Expand Down
6 changes: 2 additions & 4 deletions trunk/drivers/edac/sb_edac.c
Original file line number Diff line number Diff line change
Expand Up @@ -1661,8 +1661,7 @@ static void sbridge_unregister_mci(struct sbridge_dev *sbridge_dev)
debugf0("MC: " __FILE__ ": %s(): mci = %p, dev = %p\n",
__func__, mci, &sbridge_dev->pdev[0]->dev);

atomic_notifier_chain_unregister(&x86_mce_decoder_chain,
&sbridge_mce_dec);
mce_unregister_decode_chain(&sbridge_mce_dec);

/* Remove MC sysfs nodes */
edac_mc_del_mc(mci->dev);
Expand Down Expand Up @@ -1731,8 +1730,7 @@ static int sbridge_register_mci(struct sbridge_dev *sbridge_dev)
goto fail0;
}

atomic_notifier_chain_register(&x86_mce_decoder_chain,
&sbridge_mce_dec);
mce_register_decode_chain(&sbridge_mce_dec);
return 0;

fail0:
Expand Down

0 comments on commit c37cc2d

Please sign in to comment.