diff options
Diffstat (limited to 'arch/x86/kernel/cpu/amd.c')
| -rw-r--r-- | arch/x86/kernel/cpu/amd.c | 77 |
1 files changed, 53 insertions, 24 deletions
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index ba5f62f45f01..9e093f8fe78c 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c | |||
| @@ -148,7 +148,7 @@ static void __cpuinit amd_k7_smp_check(struct cpuinfo_x86 *c) | |||
| 148 | { | 148 | { |
| 149 | #ifdef CONFIG_SMP | 149 | #ifdef CONFIG_SMP |
| 150 | /* calling is from identify_secondary_cpu() ? */ | 150 | /* calling is from identify_secondary_cpu() ? */ |
| 151 | if (c->cpu_index == boot_cpu_id) | 151 | if (!c->cpu_index) |
| 152 | return; | 152 | return; |
| 153 | 153 | ||
| 154 | /* | 154 | /* |
| @@ -253,37 +253,51 @@ static int __cpuinit nearby_node(int apicid) | |||
| 253 | #endif | 253 | #endif |
| 254 | 254 | ||
| 255 | /* | 255 | /* |
| 256 | * Fixup core topology information for AMD multi-node processors. | 256 | * Fixup core topology information for |
| 257 | * Assumption: Number of cores in each internal node is the same. | 257 | * (1) AMD multi-node processors |
| 258 | * Assumption: Number of cores in each internal node is the same. | ||
| 259 | * (2) AMD processors supporting compute units | ||
| 258 | */ | 260 | */ |
| 259 | #ifdef CONFIG_X86_HT | 261 | #ifdef CONFIG_X86_HT |
| 260 | static void __cpuinit amd_fixup_dcm(struct cpuinfo_x86 *c) | 262 | static void __cpuinit amd_get_topology(struct cpuinfo_x86 *c) |
| 261 | { | 263 | { |
| 262 | unsigned long long value; | 264 | u32 nodes; |
| 263 | u32 nodes, cores_per_node; | 265 | u8 node_id; |
| 264 | int cpu = smp_processor_id(); | 266 | int cpu = smp_processor_id(); |
| 265 | 267 | ||
| 266 | if (!cpu_has(c, X86_FEATURE_NODEID_MSR)) | 268 | /* get information required for multi-node processors */ |
| 267 | return; | 269 | if (cpu_has(c, X86_FEATURE_TOPOEXT)) { |
| 270 | u32 eax, ebx, ecx, edx; | ||
| 268 | 271 | ||
| 269 | /* fixup topology information only once for a core */ | 272 | cpuid(0x8000001e, &eax, &ebx, &ecx, &edx); |
| 270 | if (cpu_has(c, X86_FEATURE_AMD_DCM)) | 273 | nodes = ((ecx >> 8) & 7) + 1; |
| 271 | return; | 274 | node_id = ecx & 7; |
| 272 | 275 | ||
| 273 | rdmsrl(MSR_FAM10H_NODE_ID, value); | 276 | /* get compute unit information */ |
| 277 | smp_num_siblings = ((ebx >> 8) & 3) + 1; | ||
| 278 | c->compute_unit_id = ebx & 0xff; | ||
| 279 | } else if (cpu_has(c, X86_FEATURE_NODEID_MSR)) { | ||
| 280 | u64 value; | ||
| 274 | 281 | ||
| 275 | nodes = ((value >> 3) & 7) + 1; | 282 | rdmsrl(MSR_FAM10H_NODE_ID, value); |
| 276 | if (nodes == 1) | 283 | nodes = ((value >> 3) & 7) + 1; |
| 284 | node_id = value & 7; | ||
| 285 | } else | ||
| 277 | return; | 286 | return; |
| 278 | 287 | ||
| 279 | set_cpu_cap(c, X86_FEATURE_AMD_DCM); | 288 | /* fixup multi-node processor information */ |
| 280 | cores_per_node = c->x86_max_cores / nodes; | 289 | if (nodes > 1) { |
| 290 | u32 cores_per_node; | ||
| 291 | |||
| 292 | set_cpu_cap(c, X86_FEATURE_AMD_DCM); | ||
| 293 | cores_per_node = c->x86_max_cores / nodes; | ||
| 281 | 294 | ||
| 282 | /* store NodeID, use llc_shared_map to store sibling info */ | 295 | /* store NodeID, use llc_shared_map to store sibling info */ |
| 283 | per_cpu(cpu_llc_id, cpu) = value & 7; | 296 | per_cpu(cpu_llc_id, cpu) = node_id; |
| 284 | 297 | ||
| 285 | /* fixup core id to be in range from 0 to (cores_per_node - 1) */ | 298 | /* core id to be in range from 0 to (cores_per_node - 1) */ |
| 286 | c->cpu_core_id = c->cpu_core_id % cores_per_node; | 299 | c->cpu_core_id = c->cpu_core_id % cores_per_node; |
| 300 | } | ||
| 287 | } | 301 | } |
| 288 | #endif | 302 | #endif |
| 289 | 303 | ||
| @@ -304,9 +318,7 @@ static void __cpuinit amd_detect_cmp(struct cpuinfo_x86 *c) | |||
| 304 | c->phys_proc_id = c->initial_apicid >> bits; | 318 | c->phys_proc_id = c->initial_apicid >> bits; |
| 305 | /* use socket ID also for last level cache */ | 319 | /* use socket ID also for last level cache */ |
| 306 | per_cpu(cpu_llc_id, cpu) = c->phys_proc_id; | 320 | per_cpu(cpu_llc_id, cpu) = c->phys_proc_id; |
| 307 | /* fixup topology information on multi-node processors */ | 321 | amd_get_topology(c); |
| 308 | if ((c->x86 == 0x10) && (c->x86_model == 9)) | ||
| 309 | amd_fixup_dcm(c); | ||
| 310 | #endif | 322 | #endif |
| 311 | } | 323 | } |
| 312 | 324 | ||
| @@ -412,6 +424,23 @@ static void __cpuinit early_init_amd(struct cpuinfo_x86 *c) | |||
| 412 | set_cpu_cap(c, X86_FEATURE_EXTD_APICID); | 424 | set_cpu_cap(c, X86_FEATURE_EXTD_APICID); |
| 413 | } | 425 | } |
| 414 | #endif | 426 | #endif |
| 427 | |||
| 428 | /* We need to do the following only once */ | ||
| 429 | if (c != &boot_cpu_data) | ||
| 430 | return; | ||
| 431 | |||
| 432 | if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) { | ||
| 433 | |||
| 434 | if (c->x86 > 0x10 || | ||
| 435 | (c->x86 == 0x10 && c->x86_model >= 0x2)) { | ||
| 436 | u64 val; | ||
| 437 | |||
| 438 | rdmsrl(MSR_K7_HWCR, val); | ||
| 439 | if (!(val & BIT(24))) | ||
| 440 | printk(KERN_WARNING FW_BUG "TSC doesn't count " | ||
| 441 | "with P0 frequency!\n"); | ||
| 442 | } | ||
| 443 | } | ||
| 415 | } | 444 | } |
| 416 | 445 | ||
| 417 | static void __cpuinit init_amd(struct cpuinfo_x86 *c) | 446 | static void __cpuinit init_amd(struct cpuinfo_x86 *c) |
| @@ -523,7 +552,7 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c) | |||
| 523 | #endif | 552 | #endif |
| 524 | 553 | ||
| 525 | if (c->extended_cpuid_level >= 0x80000006) { | 554 | if (c->extended_cpuid_level >= 0x80000006) { |
| 526 | if ((c->x86 >= 0x0f) && (cpuid_edx(0x80000006) & 0xf000)) | 555 | if (cpuid_edx(0x80000006) & 0xf000) |
| 527 | num_cache_leaves = 4; | 556 | num_cache_leaves = 4; |
| 528 | else | 557 | else |
| 529 | num_cache_leaves = 3; | 558 | num_cache_leaves = 3; |
