soc/amd/picasso,stoneyridge/mca: factor out mca_clear_errors

Change-Id: Id7a716a2598a6a7bea2d2d56898ea6329b5a3bec
Signed-off-by: Felix Held <felix-coreboot@felixheld.de>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/56240
Reviewed-by: Raul Rangel <rrangel@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Felix Held 2021-07-12 22:29:18 +02:00
parent 2d0346a521
commit 7830e3a836
2 changed files with 22 additions and 12 deletions

View File

@ -164,12 +164,21 @@ static void mca_print_error(unsigned int bank)
printk(BIOS_WARNING, " MC%u_CTL_MASK = %08x_%08x\n", bank, msr.hi, msr.lo); printk(BIOS_WARNING, " MC%u_CTL_MASK = %08x_%08x\n", bank, msr.hi, msr.lo);
} }
static void mca_clear_errors(void)
{
const unsigned int num_banks = mca_get_bank_count();
const msr_t msr = {.lo = 0, .hi = 0};
/* Zero all machine check error status registers */
for (unsigned int i = 0 ; i < num_banks ; i++)
wrmsr(MCAX_STATUS_MSR(i), msr);
}
/* Check the Machine Check Architecture Extension registers */ /* Check the Machine Check Architecture Extension registers */
void check_mca(void) void check_mca(void)
{ {
unsigned int i; unsigned int i;
struct mca_bank_status mci; struct mca_bank_status mci;
msr_t msr;
const unsigned int num_banks = mca_get_bank_count(); const unsigned int num_banks = mca_get_bank_count();
for (i = 0 ; i < num_banks ; i++) { for (i = 0 ; i < num_banks ; i++) {
@ -183,9 +192,5 @@ void check_mca(void)
} }
} }
/* zero the machine check error status registers */ mca_clear_errors();
msr.lo = 0;
msr.hi = 0;
for (i = 0 ; i < num_banks ; i++)
wrmsr(MCAX_STATUS_MSR(i), msr);
} }

View File

@ -164,11 +164,20 @@ static void mca_print_error(unsigned int bank)
printk(BIOS_WARNING, " MC%u_CTL_MASK = %08x_%08x\n", bank, msr.hi, msr.lo); printk(BIOS_WARNING, " MC%u_CTL_MASK = %08x_%08x\n", bank, msr.hi, msr.lo);
} }
static void mca_clear_errors(void)
{
const unsigned int num_banks = mca_get_bank_count();
const msr_t msr = {.lo = 0, .hi = 0};
/* Zero all machine check error status registers */
for (unsigned int i = 0 ; i < num_banks ; i++)
wrmsr(IA32_MC0_STATUS + (i * 4), msr);
}
void check_mca(void) void check_mca(void)
{ {
unsigned int i; unsigned int i;
struct mca_bank_status mci; struct mca_bank_status mci;
msr_t msr;
const unsigned int num_banks = mca_get_bank_count(); const unsigned int num_banks = mca_get_bank_count();
if (is_warm_reset()) { if (is_warm_reset()) {
@ -187,9 +196,5 @@ void check_mca(void)
} }
} }
/* zero the machine check error status registers */ mca_clear_errors();
msr.lo = 0;
msr.hi = 0;
for (i = 0 ; i < num_banks ; i++)
wrmsr(IA32_MC0_STATUS + (i * 4), msr);
} }