diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/x86_64/kernel/genapic.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'arch/x86_64/kernel/genapic.c')
-rw-r--r-- | arch/x86_64/kernel/genapic.c | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/arch/x86_64/kernel/genapic.c b/arch/x86_64/kernel/genapic.c new file mode 100644 index 000000000000..d2c42fb99cb3 --- /dev/null +++ b/arch/x86_64/kernel/genapic.c | |||
@@ -0,0 +1,89 @@ | |||
1 | /* | ||
2 | * Copyright 2004 James Cleverdon, IBM. | ||
3 | * Subject to the GNU Public License, v.2 | ||
4 | * | ||
5 | * Generic APIC sub-arch probe layer. | ||
6 | * | ||
7 | * Hacked for x86-64 by James Cleverdon from i386 architecture code by | ||
8 | * Martin Bligh, Andi Kleen, James Bottomley, John Stultz, and | ||
9 | * James Cleverdon. | ||
10 | */ | ||
11 | #include <linux/config.h> | ||
12 | #include <linux/threads.h> | ||
13 | #include <linux/cpumask.h> | ||
14 | #include <linux/string.h> | ||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/ctype.h> | ||
17 | #include <linux/init.h> | ||
18 | #include <linux/module.h> | ||
19 | |||
20 | #include <asm/smp.h> | ||
21 | #include <asm/ipi.h> | ||
22 | |||
23 | /* which logical CPU number maps to which CPU (physical APIC ID) */ | ||
24 | u8 x86_cpu_to_apicid[NR_CPUS] = { [0 ... NR_CPUS-1] = BAD_APICID }; | ||
25 | EXPORT_SYMBOL(x86_cpu_to_apicid); | ||
26 | u8 x86_cpu_to_log_apicid[NR_CPUS] = { [0 ... NR_CPUS-1] = BAD_APICID }; | ||
27 | |||
28 | extern struct genapic apic_cluster; | ||
29 | extern struct genapic apic_flat; | ||
30 | |||
31 | struct genapic *genapic = &apic_flat; | ||
32 | |||
33 | |||
34 | /* | ||
35 | * Check the APIC IDs in bios_cpu_apicid and choose the APIC mode. | ||
36 | */ | ||
37 | void __init clustered_apic_check(void) | ||
38 | { | ||
39 | long i; | ||
40 | u8 clusters, max_cluster; | ||
41 | u8 id; | ||
42 | u8 cluster_cnt[NUM_APIC_CLUSTERS]; | ||
43 | |||
44 | if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) { | ||
45 | /* AMD always uses flat mode right now */ | ||
46 | genapic = &apic_flat; | ||
47 | goto print; | ||
48 | } | ||
49 | |||
50 | memset(cluster_cnt, 0, sizeof(cluster_cnt)); | ||
51 | |||
52 | for (i = 0; i < NR_CPUS; i++) { | ||
53 | id = bios_cpu_apicid[i]; | ||
54 | if (id != BAD_APICID) | ||
55 | cluster_cnt[APIC_CLUSTERID(id)]++; | ||
56 | } | ||
57 | |||
58 | clusters = 0; | ||
59 | max_cluster = 0; | ||
60 | for (i = 0; i < NUM_APIC_CLUSTERS; i++) { | ||
61 | if (cluster_cnt[i] > 0) { | ||
62 | ++clusters; | ||
63 | if (cluster_cnt[i] > max_cluster) | ||
64 | max_cluster = cluster_cnt[i]; | ||
65 | } | ||
66 | } | ||
67 | |||
68 | /* | ||
69 | * If we have clusters <= 1 and CPUs <= 8 in cluster 0, then flat mode, | ||
70 | * else if max_cluster <= 4 and cluster_cnt[15] == 0, clustered logical | ||
71 | * else physical mode. | ||
72 | * (We don't use lowest priority delivery + HW APIC IRQ steering, so | ||
73 | * can ignore the clustered logical case and go straight to physical.) | ||
74 | */ | ||
75 | if (clusters <= 1 && max_cluster <= 8 && cluster_cnt[0] == max_cluster) | ||
76 | genapic = &apic_flat; | ||
77 | else | ||
78 | genapic = &apic_cluster; | ||
79 | |||
80 | print: | ||
81 | printk(KERN_INFO "Setting APIC routing to %s\n", genapic->name); | ||
82 | } | ||
83 | |||
84 | /* Same for both flat and clustered. */ | ||
85 | |||
86 | void send_IPI_self(int vector) | ||
87 | { | ||
88 | __send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL); | ||
89 | } | ||