From: Hans Rosenfeld <hans.rosenfeld@amd.com>
To: <hpa@zytor.com>
Cc: <tglx@linutronix.de>, <mingo@elte.hu>,
<linux-kernel@vger.kernel.org>, <x86@kernel.org>,
Hans Rosenfeld <hans.rosenfeld@amd.com>
Subject: [PATCH 4/5] x86, cacheinfo: use find_num_cache_leaves on AMD systems
Date: Thu, 7 Jun 2012 18:45:58 +0200 [thread overview]
Message-ID: <1339087559-32604-4-git-send-email-hans.rosenfeld@amd.com> (raw)
In-Reply-To: <1339087559-32604-1-git-send-email-hans.rosenfeld@amd.com>
When AMD topology extensions are available, find_num_cache_leaves() can
be used to find out how many cache leaves there are.
Signed-off-by: Hans Rosenfeld <hans.rosenfeld@amd.com>
---
arch/x86/kernel/cpu/amd.c | 5 ++++-
arch/x86/kernel/cpu/cacheinfo.c | 6 +++---
arch/x86/kernel/cpu/cacheinfo.h | 2 +-
arch/x86/kernel/cpu/intel_cacheinfo.c | 2 +-
4 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 146bb62..ad1a59c 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -18,6 +18,7 @@
#endif
#include "cpu.h"
+#include "cacheinfo.h"
#ifdef CONFIG_X86_32
/*
@@ -610,7 +611,9 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
detect_ht(c);
#endif
- if (c->extended_cpuid_level >= 0x80000006) {
+ if (cpu_has_topoext) {
+ num_cache_leaves = find_num_cache_leaves(0x8000001d);
+ } else if (c->extended_cpuid_level >= 0x80000006) {
if (cpuid_edx(0x80000006) & 0xf000)
num_cache_leaves = 4;
else
diff --git a/arch/x86/kernel/cpu/cacheinfo.c b/arch/x86/kernel/cpu/cacheinfo.c
index 111617e..db04501 100644
--- a/arch/x86/kernel/cpu/cacheinfo.c
+++ b/arch/x86/kernel/cpu/cacheinfo.c
@@ -53,7 +53,7 @@ int __cpuinit cpuid_cacheinfo_lookup_regs(int index,
return 0;
}
-int __cpuinit find_num_cache_leaves(void)
+int __cpuinit find_num_cache_leaves(unsigned int leaf)
{
unsigned int eax, ebx, ecx, edx;
union _cpuid_cacheinfo_eax cache_eax;
@@ -61,8 +61,8 @@ int __cpuinit find_num_cache_leaves(void)
do {
++i;
- /* Do cpuid(4) loop to find out num_cache_leaves */
- cpuid_count(4, i, &eax, &ebx, &ecx, &edx);
+ /* Do cpuid loop to find out num_cache_leaves */
+ cpuid_count(leaf, i, &eax, &ebx, &ecx, &edx);
cache_eax.full = eax;
} while (cache_eax.split.type != CACHE_TYPE_NULL);
return i;
diff --git a/arch/x86/kernel/cpu/cacheinfo.h b/arch/x86/kernel/cpu/cacheinfo.h
index df5b83e..fe39da7 100644
--- a/arch/x86/kernel/cpu/cacheinfo.h
+++ b/arch/x86/kernel/cpu/cacheinfo.h
@@ -71,6 +71,6 @@ extern void amd_init_l3_cache(struct _cpuid_cacheinfo_regs *, int);
extern void cache_shared_amd_cpu_map_setup(unsigned int, int);
extern void cache_shared_intel_cpu_map_setup(unsigned int, int);
extern int cpuid_cacheinfo_lookup_regs(int, struct _cpuid_cacheinfo_regs *);
-extern int find_num_cache_leaves(void);
+extern int find_num_cache_leaves(unsigned int);
#endif /* __CACHEINFO_H */
diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
index 7e5b1fb..2fc1b8b 100644
--- a/arch/x86/kernel/cpu/intel_cacheinfo.c
+++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
@@ -132,7 +132,7 @@ unsigned int __cpuinit init_intel_cacheinfo(struct cpuinfo_x86 *c)
if (is_initialized == 0) {
/* Init num_cache_leaves from boot CPU */
- num_cache_leaves = find_num_cache_leaves();
+ num_cache_leaves = find_num_cache_leaves(4);
is_initialized++;
}
--
1.7.7
next prev parent reply other threads:[~2012-06-07 16:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-07 16:45 [PATCH 1/5] x86, cacheinfo, amd: use cpuid topology extensions to enumerate caches Hans Rosenfeld
2012-06-07 16:45 ` [PATCH 2/5] x86, cacheinfo: it's not only cpuid 4 anymore Hans Rosenfeld
2012-06-07 16:45 ` [PATCH 3/5] x86, cacheinfo: split intel_cacheinfo.c Hans Rosenfeld
2012-06-07 16:45 ` Hans Rosenfeld [this message]
2012-06-07 16:45 ` [PATCH 5/5] x86, cacheinfo, amd: fix reported cache parameters for family 0x10 Hans Rosenfeld
2012-06-08 18:16 ` H. Peter Anvin
2012-06-11 10:33 ` Hans Rosenfeld
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1339087559-32604-4-git-send-email-hans.rosenfeld@amd.com \
--to=hans.rosenfeld@amd.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®