Attention is currently required from: Mariusz Szafrański, Suresh Bellampalli, Vanessa Eusebio, Michal Motyl, Patrick Rudolph.

Angel Pons has uploaded this change for review.

View Change

soc/intel/denverton_ns: Refactor `detect_num_cpus_via_cpuid()`

Rewrite level type check and use unsigned types. In addition, also use
unsigned types in the `get_cpu_count()` function.

Change-Id: I63f236f0f94f9412ec03ae25781befe619cf7c1f
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
---
M src/soc/intel/denverton_ns/cpu.c
1 file changed, 10 insertions(+), 11 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/13/58913/1
diff --git a/src/soc/intel/denverton_ns/cpu.c b/src/soc/intel/denverton_ns/cpu.c
index c1bb4a9..96eb79a 100644
--- a/src/soc/intel/denverton_ns/cpu.c
+++ b/src/soc/intel/denverton_ns/cpu.c
@@ -162,21 +162,20 @@
*smm_save_state_size = sizeof(em64t100_smm_state_save_area_t);
}

-static int detect_num_cpus_via_cpuid(void)
+static unsigned int detect_num_cpus_via_cpuid(void)
{
- register int ecx = 0;
- struct cpuid_result leaf_b;
+ unsigned int ecx = 0;

while (1) {
- leaf_b = cpuid_ext(0xb, ecx);
+ const struct cpuid_result leaf_b = cpuid_ext(0xb, ecx);

/* Processor doesn't have hyperthreading so just determine the
- * number of cores by from level type (ecx[15:8] == * 2). */
- if ((leaf_b.ecx & 0xff00) == 0x0200)
- break;
+ number of cores from level type (ecx[15:8] == 2). */
+ if ((leaf_b.ecx >> 8 & 0xff) == 2)
+ return leaf_b.ebx & 0xffff;
+
ecx++;
}
- return (leaf_b.ebx & 0xffff);
}

/* Assumes that FSP has already programmed the cores disabled register */
@@ -200,11 +199,11 @@
/* Find CPU topology */
int get_cpu_count(void)
{
- int num_cpus = detect_num_cpus_via_mch();
+ unsigned int num_cpus = detect_num_cpus_via_mch();

- if (num_cpus <= 0 || num_cpus > CONFIG_MAX_CPUS) {
+ if (num_cpus == 0 || num_cpus > CONFIG_MAX_CPUS) {
num_cpus = detect_num_cpus_via_cpuid();
- printk(BIOS_DEBUG, "Number of Cores (CPUID): %d.\n", num_cpus);
+ printk(BIOS_DEBUG, "Number of Cores (CPUID): %u.\n", num_cpus);
}
return num_cpus;
}

To view, visit change 58913. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I63f236f0f94f9412ec03ae25781befe619cf7c1f
Gerrit-Change-Number: 58913
Gerrit-PatchSet: 1
Gerrit-Owner: Angel Pons <th3fanbus@gmail.com>
Gerrit-Reviewer: Mariusz Szafrański <mariuszx.szafranski@intel.com>
Gerrit-Reviewer: Michal Motyl <michalx.motyl@intel.com>
Gerrit-Reviewer: Patrick Rudolph <siro@das-labor.org>
Gerrit-Reviewer: Suresh Bellampalli <suresh.bellampalli@intel.com>
Gerrit-Reviewer: Vanessa Eusebio <vanessa.f.eusebio@intel.com>
Gerrit-Attention: Mariusz Szafrański <mariuszx.szafranski@intel.com>
Gerrit-Attention: Suresh Bellampalli <suresh.bellampalli@intel.com>
Gerrit-Attention: Vanessa Eusebio <vanessa.f.eusebio@intel.com>
Gerrit-Attention: Michal Motyl <michalx.motyl@intel.com>
Gerrit-Attention: Patrick Rudolph <siro@das-labor.org>
Gerrit-MessageType: newchange