diff options
| author | Borislav Petkov <bp@amd64.org> | 2011-08-05 14:04:09 -0400 |
|---|---|---|
| committer | Herton Ronaldo Krzesinski <herton.krzesinski@canonical.com> | 2011-10-17 13:32:18 -0400 |
| commit | 4c19ac326b0b273f17d72a76e33b60f419f4c33d (patch) | |
| tree | c22aa0aa0e0f8ae24a8c5bd23b82a43c71a6771c /arch/x86/kernel/cpu | |
| parent | da6315e988dfdcf51de6b22e49855fa7f7e1899e (diff) | |
x86, amd: Move BSP code to cpu_dev helper
BugLink: http://bugs.launchpad.net/bugs/862583
Move code which is run once on the BSP during boot into the cpu_dev
helper.
[ hpa: removed bogus cpu_has -> static_cpu_has conversion ]
Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
Link: http://lkml.kernel.org/r/20110805180409.GC26217@aftab
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
(cherry picked from git://tesla.tglx.de/git/linux-2.6-tip x86/cpu commit 8fa8b035085e7320c15875c1f6b03b290ca2dd66)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
Acked-by: Leann Ogasawara <leann.ogasawara@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: John Johansen <john.johansen@canonical.com>
Diffstat (limited to 'arch/x86/kernel/cpu')
| -rw-r--r-- | arch/x86/kernel/cpu/amd.c | 59 |
1 files changed, 29 insertions, 30 deletions
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index b0234bcbd32..b6e3e87d25f 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c | |||
| @@ -410,6 +410,34 @@ static void __cpuinit early_init_amd_mc(struct cpuinfo_x86 *c) | |||
| 410 | #endif | 410 | #endif |
| 411 | } | 411 | } |
| 412 | 412 | ||
| 413 | static void __cpuinit bsp_init_amd(struct cpuinfo_x86 *c) | ||
| 414 | { | ||
| 415 | if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) { | ||
| 416 | |||
| 417 | if (c->x86 > 0x10 || | ||
| 418 | (c->x86 == 0x10 && c->x86_model >= 0x2)) { | ||
| 419 | u64 val; | ||
| 420 | |||
| 421 | rdmsrl(MSR_K7_HWCR, val); | ||
| 422 | if (!(val & BIT(24))) | ||
| 423 | printk(KERN_WARNING FW_BUG "TSC doesn't count " | ||
| 424 | "with P0 frequency!\n"); | ||
| 425 | } | ||
| 426 | } | ||
| 427 | |||
| 428 | if (c->x86 == 0x15) { | ||
| 429 | unsigned long upperbit; | ||
| 430 | u32 cpuid, assoc; | ||
| 431 | |||
| 432 | cpuid = cpuid_edx(0x80000005); | ||
| 433 | assoc = cpuid >> 16 & 0xff; | ||
| 434 | upperbit = ((cpuid >> 24) << 10) / assoc; | ||
| 435 | |||
| 436 | va_align.mask = (upperbit - 1) & PAGE_MASK; | ||
| 437 | va_align.flags = ALIGN_VA_32 | ALIGN_VA_64; | ||
| 438 | } | ||
| 439 | } | ||
| 440 | |||
| 413 | static void __cpuinit early_init_amd(struct cpuinfo_x86 *c) | 441 | static void __cpuinit early_init_amd(struct cpuinfo_x86 *c) |
| 414 | { | 442 | { |
| 415 | early_init_amd_mc(c); | 443 | early_init_amd_mc(c); |
| @@ -441,36 +469,6 @@ static void __cpuinit early_init_amd(struct cpuinfo_x86 *c) | |||
| 441 | set_cpu_cap(c, X86_FEATURE_EXTD_APICID); | 469 | set_cpu_cap(c, X86_FEATURE_EXTD_APICID); |
| 442 | } | 470 | } |
| 443 | #endif | 471 | #endif |
| 444 | |||
| 445 | /* We need to do the following only once */ | ||
| 446 | if (c != &boot_cpu_data) | ||
| 447 | return; | ||
| 448 | |||
| 449 | if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) { | ||
| 450 | |||
| 451 | if (c->x86 > 0x10 || | ||
| 452 | (c->x86 == 0x10 && c->x86_model >= 0x2)) { | ||
| 453 | u64 val; | ||
| 454 | |||
| 455 | rdmsrl(MSR_K7_HWCR, val); | ||
| 456 | if (!(val & BIT(24))) | ||
| 457 | printk(KERN_WARNING FW_BUG "TSC doesn't count " | ||
| 458 | "with P0 frequency!\n"); | ||
| 459 | } | ||
| 460 | } | ||
| 461 | |||
| 462 | if (c->x86 == 0x15) { | ||
| 463 | unsigned long upperbit; | ||
| 464 | u32 cpuid, assoc; | ||
| 465 | |||
| 466 | cpuid = cpuid_edx(0x80000005); | ||
| 467 | assoc = cpuid >> 16 & 0xff; | ||
| 468 | upperbit = ((cpuid >> 24) << 10) / assoc; | ||
| 469 | |||
| 470 | va_align.mask = (upperbit - 1) & PAGE_MASK; | ||
| 471 | va_align.flags = ALIGN_VA_32 | ALIGN_VA_64; | ||
| 472 | |||
| 473 | } | ||
| 474 | } | 472 | } |
| 475 | 473 | ||
| 476 | static void __cpuinit init_amd(struct cpuinfo_x86 *c) | 474 | static void __cpuinit init_amd(struct cpuinfo_x86 *c) |
| @@ -692,6 +690,7 @@ static const struct cpu_dev __cpuinitconst amd_cpu_dev = { | |||
| 692 | .c_size_cache = amd_size_cache, | 690 | .c_size_cache = amd_size_cache, |
| 693 | #endif | 691 | #endif |
| 694 | .c_early_init = early_init_amd, | 692 | .c_early_init = early_init_amd, |
| 693 | .c_bsp_init = bsp_init_amd, | ||
| 695 | .c_init = init_amd, | 694 | .c_init = init_amd, |
| 696 | .c_x86_vendor = X86_VENDOR_AMD, | 695 | .c_x86_vendor = X86_VENDOR_AMD, |
| 697 | }; | 696 | }; |
