From 7061cc6bfc5a8270061b70cc55cf010e6c8e68b1 Mon Sep 17 00:00:00 2001 From: Ahmed Samy Date: Fri, 11 Oct 2013 13:09:19 +0200 Subject: [PATCH] cpuid: cache processor brand string Signed-off-by: Ahmed Samy --- ccan/cpuid/cpuid.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ccan/cpuid/cpuid.c b/ccan/cpuid/cpuid.c index 55a08921..1a09c5e6 100644 --- a/ccan/cpuid/cpuid.c +++ b/ccan/cpuid/cpuid.c @@ -248,9 +248,16 @@ void cpuid(cpuid_t info, uint32_t *buf) return; if (info == CPU_PROC_BRAND_STRING) { - ___cpuid(CPU_PROC_BRAND_STRING, &buf[0], &buf[1], &buf[2], &buf[3]); - ___cpuid(CPU_PROC_BRAND_STRING_INTERNAL0, &buf[4], &buf[5], &buf[6], &buf[7]); - ___cpuid(CPU_PROC_BRAND_STRING_INTERNAL1, &buf[8], &buf[9], &buf[10], &buf[11]); + static char cached[48] = { 0 }; + if (cached[0] == '\0') { + ___cpuid(CPU_PROC_BRAND_STRING, &buf[0], &buf[1], &buf[2], &buf[3]); + ___cpuid(CPU_PROC_BRAND_STRING_INTERNAL0, &buf[4], &buf[5], &buf[6], &buf[7]); + ___cpuid(CPU_PROC_BRAND_STRING_INTERNAL1, &buf[8], &buf[9], &buf[10], &buf[11]); + + memcpy(cached, buf, sizeof cached); + } else + buf = (uint32_t *)cached; + return; } else if (info == CPU_HIGHEST_EXTENDED_FUNCTION_SUPPORTED) { *buf = cpuid_highest_ext_func_supported(); -- 2.39.2