cpu/intel/microcode: Add caching layer in intel_microcode_find
Cache the found microcode for faster subsequent accesses. Change-Id: Ic40d57964600f8f20ddb26c7d1691b043fd89f29 Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/49896 Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Arthur Heymans <arthur@aheymans.xyz> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
committed by
Patrick Georgi
parent
27c9fcfc48
commit
0bea950a47
@@ -119,13 +119,16 @@ uint32_t get_microcode_checksum(const void *microcode)
|
|||||||
|
|
||||||
const void *intel_microcode_find(void)
|
const void *intel_microcode_find(void)
|
||||||
{
|
{
|
||||||
const struct microcode *ucode_updates;
|
static const struct microcode *ucode_updates;
|
||||||
size_t microcode_len;
|
size_t microcode_len;
|
||||||
u32 eax;
|
u32 eax;
|
||||||
u32 pf, rev, sig, update_size;
|
u32 pf, rev, sig, update_size;
|
||||||
unsigned int x86_model, x86_family;
|
unsigned int x86_model, x86_family;
|
||||||
msr_t msr;
|
msr_t msr;
|
||||||
|
|
||||||
|
if (ucode_updates)
|
||||||
|
return ucode_updates;
|
||||||
|
|
||||||
ucode_updates = cbfs_map(MICROCODE_CBFS_FILE, µcode_len);
|
ucode_updates = cbfs_map(MICROCODE_CBFS_FILE, µcode_len);
|
||||||
if (ucode_updates == NULL)
|
if (ucode_updates == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -173,6 +176,8 @@ const void *intel_microcode_find(void)
|
|||||||
microcode_len -= update_size;
|
microcode_len -= update_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ucode_updates = NULL;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -6,8 +6,10 @@
|
|||||||
|
|
||||||
void intel_update_microcode_from_cbfs(void);
|
void intel_update_microcode_from_cbfs(void);
|
||||||
/* Find a microcode that matches the revision and platform family returning
|
/* Find a microcode that matches the revision and platform family returning
|
||||||
* NULL if none found. */
|
* NULL if none found. The found microcode is cached for faster access on
|
||||||
|
* subsequent calls of this function. */
|
||||||
const void *intel_microcode_find(void);
|
const void *intel_microcode_find(void);
|
||||||
|
|
||||||
/* It is up to the caller to determine if parallel loading is possible as
|
/* It is up to the caller to determine if parallel loading is possible as
|
||||||
* well as ensuring the microcode matches the family and revision (i.e. with
|
* well as ensuring the microcode matches the family and revision (i.e. with
|
||||||
* intel_microcode_find()). */
|
* intel_microcode_find()). */
|
||||||
|
Reference in New Issue
Block a user