cpu/amd/*/model_*_init: use mca_get_bank_count()

Use the common mca_get_bank_count function instead of open-coding the
functionality to get the MCA bank number. Also re-type the num_banks
variable from signed in to unsigned int, since the number of MCA bank is
always positive.

Change-Id: I70ad423aab484cf4ec8f51b43624cd434647aad4
Signed-off-by: Felix Held <felix-coreboot@felixheld.de>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/56184
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Michał Żygowski <michal.zygowski@3mdeb.com>
This commit is contained in:
Felix Held
2021-07-09 23:02:51 +02:00
parent 3f1b70640a
commit 2828fee7e0
4 changed files with 8 additions and 12 deletions

View File

@@ -17,7 +17,7 @@ static void model_14_init(struct device *dev)
{ {
u8 i; u8 i;
msr_t msr; msr_t msr;
int num_banks; unsigned int num_banks;
int msrno; int msrno;
#if CONFIG(LOGICAL_CPUS) #if CONFIG(LOGICAL_CPUS)
u32 siblings; u32 siblings;
@@ -59,8 +59,7 @@ static void model_14_init(struct device *dev)
x86_enable_cache(); x86_enable_cache();
/* zero the machine check error status registers */ /* zero the machine check error status registers */
msr = rdmsr(IA32_MCG_CAP); num_banks = mca_get_bank_count();
num_banks = msr.lo & MCA_BANKS_MASK;
msr.lo = 0; msr.lo = 0;
msr.hi = 0; msr.hi = 0;
for (i = 0; i < num_banks; i++) for (i = 0; i < num_banks; i++)

View File

@@ -20,7 +20,7 @@ static void model_15_init(struct device *dev)
u8 i; u8 i;
msr_t msr; msr_t msr;
int num_banks; unsigned int num_banks;
int msrno; int msrno;
unsigned int cpu_idx; unsigned int cpu_idx;
#if CONFIG(LOGICAL_CPUS) #if CONFIG(LOGICAL_CPUS)
@@ -58,8 +58,7 @@ static void model_15_init(struct device *dev)
x86_enable_cache(); x86_enable_cache();
/* zero the machine check error status registers */ /* zero the machine check error status registers */
msr = rdmsr(IA32_MCG_CAP); num_banks = mca_get_bank_count();
num_banks = msr.lo & MCA_BANKS_MASK;
msr.lo = 0; msr.lo = 0;
msr.hi = 0; msr.hi = 0;
for (i = 0; i < num_banks; i++) for (i = 0; i < num_banks; i++)

View File

@@ -19,7 +19,7 @@ static void model_16_init(struct device *dev)
u8 i; u8 i;
msr_t msr; msr_t msr;
int num_banks; unsigned int num_banks;
int msrno; int msrno;
#if CONFIG(LOGICAL_CPUS) #if CONFIG(LOGICAL_CPUS)
u32 siblings; u32 siblings;
@@ -56,8 +56,7 @@ static void model_16_init(struct device *dev)
x86_enable_cache(); x86_enable_cache();
/* zero the machine check error status registers */ /* zero the machine check error status registers */
msr = rdmsr(IA32_MCG_CAP); num_banks = mca_get_bank_count();
num_banks = msr.lo & MCA_BANKS_MASK;
msr.lo = 0; msr.lo = 0;
msr.hi = 0; msr.hi = 0;
for (i = 0; i < num_banks; i++) for (i = 0; i < num_banks; i++)

View File

@@ -22,7 +22,7 @@ static void model_16_init(struct device *dev)
u8 i; u8 i;
msr_t msr; msr_t msr;
int num_banks; unsigned int num_banks;
u32 siblings; u32 siblings;
/* /*
@@ -41,8 +41,7 @@ static void model_16_init(struct device *dev)
x86_mtrr_check(); x86_mtrr_check();
/* zero the machine check error status registers */ /* zero the machine check error status registers */
msr = rdmsr(IA32_MCG_CAP); num_banks = mca_get_bank_count();
num_banks = msr.lo & MCA_BANKS_MASK;
msr.lo = 0; msr.lo = 0;
msr.hi = 0; msr.hi = 0;
for (i = 0; i < num_banks; i++) for (i = 0; i < num_banks; i++)