aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/cpu/intel_cacheinfo.c
diff options
context:
space:
mode:
authorAndreas Herrmann <andreas.herrmann3@amd.com>2012-10-19 04:59:33 -0400
committerH. Peter Anvin <hpa@linux.intel.com>2012-11-13 14:22:29 -0500
commit04a1541828ea223169eb44a336bfad8ec0dfb46a (patch)
treea670df6305266009a488f52ad763eb5a13767abf /arch/x86/kernel/cpu/intel_cacheinfo.c
parent193f3fcb3ab769bab4a2b9fa181eef3e5699a352 (diff)
x86, cacheinfo: Determine number of cache leafs using CPUID 0x8000001d on AMD
CPUID 0x8000001d works quite similar to Intels' CPUID function 4. Use it to determine number of cache leafs. Signed-off-by: Andreas Herrmann <andreas.herrmann3@amd.com> Link: http://lkml.kernel.org/r/20121019085933.GE26718@alberich Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'arch/x86/kernel/cpu/intel_cacheinfo.c')
-rw-r--r--arch/x86/kernel/cpu/intel_cacheinfo.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
index 93c5451bdd52..8ce7a83252f9 100644
--- a/arch/x86/kernel/cpu/intel_cacheinfo.c
+++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
@@ -557,21 +557,39 @@ __cpuinit cpuid4_cache_lookup_regs(int index,
557 return 0; 557 return 0;
558} 558}
559 559
560static int __cpuinit find_num_cache_leaves(void) 560static int __cpuinit find_num_cache_leaves(struct cpuinfo_x86 *c)
561{ 561{
562 unsigned int eax, ebx, ecx, edx; 562 unsigned int eax, ebx, ecx, edx, op;
563 union _cpuid4_leaf_eax cache_eax; 563 union _cpuid4_leaf_eax cache_eax;
564 int i = -1; 564 int i = -1;
565 565
566 if (c->x86_vendor == X86_VENDOR_AMD)
567 op = 0x8000001d;
568 else
569 op = 4;
570
566 do { 571 do {
567 ++i; 572 ++i;
568 /* Do cpuid(4) loop to find out num_cache_leaves */ 573 /* Do cpuid(op) loop to find out num_cache_leaves */
569 cpuid_count(4, i, &eax, &ebx, &ecx, &edx); 574 cpuid_count(op, i, &eax, &ebx, &ecx, &edx);
570 cache_eax.full = eax; 575 cache_eax.full = eax;
571 } while (cache_eax.split.type != CACHE_TYPE_NULL); 576 } while (cache_eax.split.type != CACHE_TYPE_NULL);
572 return i; 577 return i;
573} 578}
574 579
580void __cpuinit init_amd_cacheinfo(struct cpuinfo_x86 *c)
581{
582
583 if (cpu_has_topoext) {
584 num_cache_leaves = find_num_cache_leaves(c);
585 } else if (c->extended_cpuid_level >= 0x80000006) {
586 if (cpuid_edx(0x80000006) & 0xf000)
587 num_cache_leaves = 4;
588 else
589 num_cache_leaves = 3;
590 }
591}
592
575unsigned int __cpuinit init_intel_cacheinfo(struct cpuinfo_x86 *c) 593unsigned int __cpuinit init_intel_cacheinfo(struct cpuinfo_x86 *c)
576{ 594{
577 /* Cache sizes */ 595 /* Cache sizes */
@@ -588,7 +606,7 @@ unsigned int __cpuinit init_intel_cacheinfo(struct cpuinfo_x86 *c)
588 606
589 if (is_initialized == 0) { 607 if (is_initialized == 0) {
590 /* Init num_cache_leaves from boot CPU */ 608 /* Init num_cache_leaves from boot CPU */
591 num_cache_leaves = find_num_cache_leaves(); 609 num_cache_leaves = find_num_cache_leaves(c);
592 is_initialized++; 610 is_initialized++;
593 } 611 }
594 612