Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b5f2fa4e authored by Andi Kleen's avatar Andi Kleen Committed by H. Peter Anvin
Browse files

x86, mce: factor out duplicated struct mce setup into one function



Impact: cleanup

This merely factors out duplicated code to set up
the initial struct mce state into a single function.

Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
Signed-off-by: default avatarH. Peter Anvin <hpa@linux.intel.com>
parent 0d7482e3
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -90,6 +90,7 @@ extern int mce_disabled;


#include <asm/atomic.h>
#include <asm/atomic.h>


void mce_setup(struct mce *m);
void mce_log(struct mce *m);
void mce_log(struct mce *m);
DECLARE_PER_CPU(struct sys_device, device_mce);
DECLARE_PER_CPU(struct sys_device, device_mce);
extern void (*threshold_cpu_callback)(unsigned long action, unsigned int cpu);
extern void (*threshold_cpu_callback)(unsigned long action, unsigned int cpu);
@@ -106,7 +107,7 @@ void mce_amd_feature_init(struct cpuinfo_x86 *c);
static inline void mce_amd_feature_init(struct cpuinfo_x86 *c) { }
static inline void mce_amd_feature_init(struct cpuinfo_x86 *c) { }
#endif
#endif


void mce_log_therm_throt_event(unsigned int cpu, __u64 status);
void mce_log_therm_throt_event(__u64 status);


extern atomic_t mce_entry;
extern atomic_t mce_entry;


+14 −9
Original line number Original line Diff line number Diff line
@@ -65,6 +65,14 @@ static char *trigger_argv[2] = { trigger, NULL };


static DECLARE_WAIT_QUEUE_HEAD(mce_wait);
static DECLARE_WAIT_QUEUE_HEAD(mce_wait);


/* Do initial initialization of a struct mce */
void mce_setup(struct mce *m)
{
	memset(m, 0, sizeof(struct mce));
	m->cpu = smp_processor_id();
	rdtscll(m->tsc);
}

/*
/*
 * Lockless MCE logging infrastructure.
 * Lockless MCE logging infrastructure.
 * This avoids deadlocks on printk locks without having to break locks. Also
 * This avoids deadlocks on printk locks without having to break locks. Also
@@ -208,8 +216,8 @@ void do_machine_check(struct pt_regs * regs, long error_code)
	    || !banks)
	    || !banks)
		goto out2;
		goto out2;


	memset(&m, 0, sizeof(struct mce));
	mce_setup(&m);
	m.cpu = smp_processor_id();

	rdmsrl(MSR_IA32_MCG_STATUS, m.mcgstatus);
	rdmsrl(MSR_IA32_MCG_STATUS, m.mcgstatus);
	/* if the restart IP is not valid, we're done for */
	/* if the restart IP is not valid, we're done for */
	if (!(m.mcgstatus & MCG_STATUS_RIPV))
	if (!(m.mcgstatus & MCG_STATUS_RIPV))
@@ -225,7 +233,6 @@ void do_machine_check(struct pt_regs * regs, long error_code)
		m.misc = 0;
		m.misc = 0;
		m.addr = 0;
		m.addr = 0;
		m.bank = i;
		m.bank = i;
		m.tsc = 0;


		rdmsrl(MSR_IA32_MC0_STATUS + i*4, m.status);
		rdmsrl(MSR_IA32_MC0_STATUS + i*4, m.status);
		if ((m.status & MCI_STATUS_VAL) == 0)
		if ((m.status & MCI_STATUS_VAL) == 0)
@@ -252,8 +259,8 @@ void do_machine_check(struct pt_regs * regs, long error_code)
			rdmsrl(MSR_IA32_MC0_ADDR + i*4, m.addr);
			rdmsrl(MSR_IA32_MC0_ADDR + i*4, m.addr);


		mce_get_rip(&m, regs);
		mce_get_rip(&m, regs);
		if (error_code >= 0)
		if (error_code < 0)
			rdtscll(m.tsc);
			m.tsc = 0;
		if (error_code != -2)
		if (error_code != -2)
			mce_log(&m);
			mce_log(&m);


@@ -341,15 +348,13 @@ void do_machine_check(struct pt_regs * regs, long error_code)
 * and historically has been the register value of the
 * and historically has been the register value of the
 * MSR_IA32_THERMAL_STATUS (Intel) msr.
 * MSR_IA32_THERMAL_STATUS (Intel) msr.
 */
 */
void mce_log_therm_throt_event(unsigned int cpu, __u64 status)
void mce_log_therm_throt_event(__u64 status)
{
{
	struct mce m;
	struct mce m;


	memset(&m, 0, sizeof(m));
	mce_setup(&m);
	m.cpu = cpu;
	m.bank = MCE_THERMAL_BANK;
	m.bank = MCE_THERMAL_BANK;
	m.status = status;
	m.status = status;
	rdtscll(m.tsc);
	mce_log(&m);
	mce_log(&m);
}
}
#endif /* CONFIG_X86_MCE_INTEL */
#endif /* CONFIG_X86_MCE_INTEL */
+1 −3
Original line number Original line Diff line number Diff line
@@ -197,9 +197,7 @@ asmlinkage void mce_threshold_interrupt(void)
	exit_idle();
	exit_idle();
	irq_enter();
	irq_enter();


	memset(&m, 0, sizeof(m));
	mce_setup(&m);
	rdtscll(m.tsc);
	m.cpu = smp_processor_id();


	/* assume first bank caused it */
	/* assume first bank caused it */
	for (bank = 0; bank < NR_BANKS; ++bank) {
	for (bank = 0; bank < NR_BANKS; ++bank) {
+1 −1
Original line number Original line Diff line number Diff line
@@ -24,7 +24,7 @@ asmlinkage void smp_thermal_interrupt(void)


	rdmsrl(MSR_IA32_THERM_STATUS, msr_val);
	rdmsrl(MSR_IA32_THERM_STATUS, msr_val);
	if (therm_throt_process(msr_val & 1))
	if (therm_throt_process(msr_val & 1))
		mce_log_therm_throt_event(smp_processor_id(), msr_val);
		mce_log_therm_throt_event(msr_val);


	inc_irq_stat(irq_thermal_count);
	inc_irq_stat(irq_thermal_count);
	irq_exit();
	irq_exit();