ia64/xen-unstable

view linux-2.6-xen-sparse/arch/xen/x86_64/kernel/genapic.c @ 6552:a9873d384da4

Merge.
author adsharma@los-vmm.sc.intel.com
date Thu Aug 25 12:24:48 2005 -0700 (2005-08-25)
parents 112d44270733 fa0754a9f64f
children dfaf788ab18c
line source
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>
20 #include <asm/smp.h>
21 #include <asm/ipi.h>
23 #if defined(CONFIG_ACPI_BUS)
24 #include <acpi/acpi_bus.h>
25 #endif
27 /* which logical CPU number maps to which CPU (physical APIC ID) */
28 u8 x86_cpu_to_apicid[NR_CPUS] = { [0 ... NR_CPUS-1] = BAD_APICID };
29 EXPORT_SYMBOL(x86_cpu_to_apicid);
30 u8 x86_cpu_to_log_apicid[NR_CPUS] = { [0 ... NR_CPUS-1] = BAD_APICID };
32 extern struct genapic apic_cluster;
33 extern struct genapic apic_flat;
35 #ifndef CONFIG_XEN
36 struct genapic *genapic = &apic_flat;
37 #else
38 extern struct genapic apic_xen;
39 struct genapic *genapic = &apic_xen;
40 #endif
43 /*
44 * Check the APIC IDs in bios_cpu_apicid and choose the APIC mode.
45 */
46 void __init clustered_apic_check(void)
47 {
48 #ifndef CONFIG_XEN
49 long i;
50 u8 clusters, max_cluster;
51 u8 id;
52 u8 cluster_cnt[NUM_APIC_CLUSTERS];
54 if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) {
55 /* AMD always uses flat mode right now */
56 genapic = &apic_flat;
57 goto print;
58 }
60 #if defined(CONFIG_ACPI_BUS)
61 /*
62 * Some x86_64 machines use physical APIC mode regardless of how many
63 * procs/clusters are present (x86_64 ES7000 is an example).
64 */
65 if (acpi_fadt.revision > FADT2_REVISION_ID)
66 if (acpi_fadt.force_apic_physical_destination_mode) {
67 genapic = &apic_cluster;
68 goto print;
69 }
70 #endif
72 memset(cluster_cnt, 0, sizeof(cluster_cnt));
74 for (i = 0; i < NR_CPUS; i++) {
75 id = bios_cpu_apicid[i];
76 if (id != BAD_APICID)
77 cluster_cnt[APIC_CLUSTERID(id)]++;
78 }
80 clusters = 0;
81 max_cluster = 0;
82 for (i = 0; i < NUM_APIC_CLUSTERS; i++) {
83 if (cluster_cnt[i] > 0) {
84 ++clusters;
85 if (cluster_cnt[i] > max_cluster)
86 max_cluster = cluster_cnt[i];
87 }
88 }
90 /*
91 * If we have clusters <= 1 and CPUs <= 8 in cluster 0, then flat mode,
92 * else if max_cluster <= 4 and cluster_cnt[15] == 0, clustered logical
93 * else physical mode.
94 * (We don't use lowest priority delivery + HW APIC IRQ steering, so
95 * can ignore the clustered logical case and go straight to physical.)
96 */
97 if (clusters <= 1 && max_cluster <= 8 && cluster_cnt[0] == max_cluster)
98 genapic = &apic_flat;
99 else
100 genapic = &apic_cluster;
102 print:
103 #else
104 /* hardcode to xen apic functions */
105 genapic = &apic_xen;
106 #endif
107 printk(KERN_INFO "Setting APIC routing to %s\n", genapic->name);
108 }
110 /* Same for both flat and clustered. */
112 #ifdef CONFIG_XEN
113 extern void xen_send_IPI_shortcut(unsigned int shortcut, int vector, unsigned int dest);
114 #endif
116 void send_IPI_self(int vector)
117 {
118 #ifndef CONFIG_XEN
119 __send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL);
120 #else
121 xen_send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL);
122 #endif
123 }