arch/x86/cpu: introduce and use device_match_mask
Instead of always doing exact matches between the CPUID read in identify_cpu and the device entries of the CPU device ID table, offer the possibility to use a bit mask in the CPUID matching. This allows covering all steppings of a CPU family/model with one entry and avoids that case of a missing new stepping causing the CPUs not being properly initialized. Some of the CPU device ID tables can now be deduplicated using the CPUID_ALL_STEPPINGS_MASK define, but that's outside of the scope of this patch. Signed-off-by: Felix Held <felix-coreboot@felixheld.de> Change-Id: I0540b514ca42591c0d3468307a82b5612585f614 Reviewed-on: https://review.coreboot.org/c/coreboot/+/72847 Reviewed-by: Fred Reitberger <reitbergerfred@gmail.com> Reviewed-by: Martin Roth <martin.roth@amd.corp-partner.google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
This commit is contained in:
@@ -188,6 +188,11 @@ static void identify_cpu(struct device *cpu)
|
||||
}
|
||||
}
|
||||
|
||||
static bool cpuid_match(uint32_t a, uint32_t b, uint32_t mask)
|
||||
{
|
||||
return (a & mask) == (b & mask);
|
||||
}
|
||||
|
||||
struct cpu_driver *find_cpu_driver(struct device *cpu)
|
||||
{
|
||||
struct cpu_driver *driver;
|
||||
@@ -196,7 +201,7 @@ struct cpu_driver *find_cpu_driver(struct device *cpu)
|
||||
for (id = driver->id_table;
|
||||
id->vendor != X86_VENDOR_INVALID; id++) {
|
||||
if ((cpu->vendor == id->vendor) &&
|
||||
(cpu->device == id->device))
|
||||
cpuid_match(cpu->device, id->device, id->device_match_mask))
|
||||
return driver;
|
||||
if (id->vendor == X86_VENDOR_ANY)
|
||||
return driver;
|
||||
|
@@ -111,9 +111,13 @@ static inline bool cpu_is_intel(void)
|
||||
|
||||
struct device;
|
||||
|
||||
#define CPUID_EXACT_MATCH_MASK 0xffffffff
|
||||
#define CPUID_ALL_STEPPINGS_MASK 0xfffffff0
|
||||
|
||||
struct cpu_device_id {
|
||||
unsigned int vendor;
|
||||
uint32_t device;
|
||||
uint32_t device_match_mask;
|
||||
};
|
||||
|
||||
struct cpu_driver {
|
||||
|
Reference in New Issue
Block a user