x86: Move PCI IO ECS code to x86/pci
[linux-2.6] / arch / x86 / kernel / cpu / intel_64.c
1 #include <linux/init.h>
2 #include <linux/smp.h>
3 #include <asm/processor.h>
4 #include <asm/ptrace.h>
5 #include <asm/topology.h>
6 #include <asm/numa_64.h>
7
8 void __cpuinit early_init_intel(struct cpuinfo_x86 *c)
9 {
10         if ((c->x86 == 0xf && c->x86_model >= 0x03) ||
11             (c->x86 == 0x6 && c->x86_model >= 0x0e))
12                 set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
13 }
14
15 /*
16  * find out the number of processor cores on the die
17  */
18 static int __cpuinit intel_num_cpu_cores(struct cpuinfo_x86 *c)
19 {
20         unsigned int eax, t;
21
22         if (c->cpuid_level < 4)
23                 return 1;
24
25         cpuid_count(4, 0, &eax, &t, &t, &t);
26
27         if (eax & 0x1f)
28                 return ((eax >> 26) + 1);
29         else
30                 return 1;
31 }
32
33 static void __cpuinit srat_detect_node(void)
34 {
35 #ifdef CONFIG_NUMA
36         unsigned node;
37         int cpu = smp_processor_id();
38         int apicid = hard_smp_processor_id();
39
40         /* Don't do the funky fallback heuristics the AMD version employs
41            for now. */
42         node = apicid_to_node[apicid];
43         if (node == NUMA_NO_NODE || !node_online(node))
44                 node = first_node(node_online_map);
45         numa_set_node(cpu, node);
46
47         printk(KERN_INFO "CPU %d/%x -> Node %d\n", cpu, apicid, node);
48 #endif
49 }
50
51 void __cpuinit init_intel(struct cpuinfo_x86 *c)
52 {
53         /* Cache sizes */
54         unsigned n;
55
56         init_intel_cacheinfo(c);
57         if (c->cpuid_level > 9) {
58                 unsigned eax = cpuid_eax(10);
59                 /* Check for version and the number of counters */
60                 if ((eax & 0xff) && (((eax>>8) & 0xff) > 1))
61                         set_cpu_cap(c, X86_FEATURE_ARCH_PERFMON);
62         }
63
64         if (cpu_has_ds) {
65                 unsigned int l1, l2;
66                 rdmsr(MSR_IA32_MISC_ENABLE, l1, l2);
67                 if (!(l1 & (1<<11)))
68                         set_cpu_cap(c, X86_FEATURE_BTS);
69                 if (!(l1 & (1<<12)))
70                         set_cpu_cap(c, X86_FEATURE_PEBS);
71         }
72
73
74         if (cpu_has_bts)
75                 ds_init_intel(c);
76
77         n = c->extended_cpuid_level;
78         if (n >= 0x80000008) {
79                 unsigned eax = cpuid_eax(0x80000008);
80                 c->x86_virt_bits = (eax >> 8) & 0xff;
81                 c->x86_phys_bits = eax & 0xff;
82         }
83
84         if (c->x86 == 15)
85                 c->x86_cache_alignment = c->x86_clflush_size * 2;
86         if (c->x86 == 6)
87                 set_cpu_cap(c, X86_FEATURE_REP_GOOD);
88         set_cpu_cap(c, X86_FEATURE_LFENCE_RDTSC);
89         c->x86_max_cores = intel_num_cpu_cores(c);
90
91         srat_detect_node();
92 }