diff options
author | Suresh Siddha <suresh.b.siddha@intel.com> | 2008-07-10 14:16:48 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-07-12 02:44:57 -0400 |
commit | 0c81c746f9bdbfaafe64322d540c8b7b59c27314 (patch) | |
tree | 2f6a291a7b699b930e617909f3476dfafb5a38bb | |
parent | 4dc2f96cacd1e74c688f94348a3bfd0a980817d5 (diff) |
x64, x2apic/intr-remap: introduce read_apic_id() to genapic routines
Move the read_apic_id() to genapic routines.
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
Cc: akpm@linux-foundation.org
Cc: arjan@linux.intel.com
Cc: andi@firstfloor.org
Cc: ebiederm@xmission.com
Cc: jbarnes@virtuousgeek.org
Cc: steiner@sgi.com
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | arch/x86/kernel/apic_64.c | 5 | ||||
-rw-r--r-- | arch/x86/kernel/genapic_64.c | 11 | ||||
-rw-r--r-- | arch/x86/kernel/genapic_flat_64.c | 14 | ||||
-rw-r--r-- | arch/x86/kernel/genx2apic_uv_x.c | 14 | ||||
-rw-r--r-- | include/asm-x86/genapic_64.h | 1 | ||||
-rw-r--r-- | include/asm-x86/mach-default/mach_apic.h | 1 | ||||
-rw-r--r-- | include/asm-x86/mach-default/mach_apicdef.h | 3 | ||||
-rw-r--r-- | include/asm-x86/smp.h | 4 |
8 files changed, 36 insertions, 17 deletions
diff --git a/arch/x86/kernel/apic_64.c b/arch/x86/kernel/apic_64.c index 1e3d32e27c14..9dd4ee4735f5 100644 --- a/arch/x86/kernel/apic_64.c +++ b/arch/x86/kernel/apic_64.c | |||
@@ -1096,6 +1096,11 @@ void __cpuinit generic_processor_info(int apicid, int version) | |||
1096 | cpu_set(cpu, cpu_present_map); | 1096 | cpu_set(cpu, cpu_present_map); |
1097 | } | 1097 | } |
1098 | 1098 | ||
1099 | int hard_smp_processor_id(void) | ||
1100 | { | ||
1101 | return read_apic_id(); | ||
1102 | } | ||
1103 | |||
1099 | /* | 1104 | /* |
1100 | * Power management | 1105 | * Power management |
1101 | */ | 1106 | */ |
diff --git a/arch/x86/kernel/genapic_64.c b/arch/x86/kernel/genapic_64.c index 1fa8be5bd217..7414871751a7 100644 --- a/arch/x86/kernel/genapic_64.c +++ b/arch/x86/kernel/genapic_64.c | |||
@@ -79,17 +79,6 @@ int __init acpi_madt_oem_check(char *oem_id, char *oem_table_id) | |||
79 | return 0; | 79 | return 0; |
80 | } | 80 | } |
81 | 81 | ||
82 | unsigned int read_apic_id(void) | ||
83 | { | ||
84 | unsigned int id; | ||
85 | |||
86 | WARN_ON(preemptible() && num_online_cpus() > 1); | ||
87 | id = apic_read(APIC_ID); | ||
88 | if (uv_system_type >= UV_X2APIC) | ||
89 | id |= __get_cpu_var(x2apic_extra_bits); | ||
90 | return id; | ||
91 | } | ||
92 | |||
93 | enum uv_system_type get_uv_system_type(void) | 82 | enum uv_system_type get_uv_system_type(void) |
94 | { | 83 | { |
95 | return uv_system_type; | 84 | return uv_system_type; |
diff --git a/arch/x86/kernel/genapic_flat_64.c b/arch/x86/kernel/genapic_flat_64.c index 1a9c68845ee8..400ed8df8b4e 100644 --- a/arch/x86/kernel/genapic_flat_64.c +++ b/arch/x86/kernel/genapic_flat_64.c | |||
@@ -15,9 +15,11 @@ | |||
15 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
16 | #include <linux/ctype.h> | 16 | #include <linux/ctype.h> |
17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
18 | #include <linux/hardirq.h> | ||
18 | #include <asm/smp.h> | 19 | #include <asm/smp.h> |
19 | #include <asm/ipi.h> | 20 | #include <asm/ipi.h> |
20 | #include <asm/genapic.h> | 21 | #include <asm/genapic.h> |
22 | #include <mach_apicdef.h> | ||
21 | 23 | ||
22 | static cpumask_t flat_target_cpus(void) | 24 | static cpumask_t flat_target_cpus(void) |
23 | { | 25 | { |
@@ -95,9 +97,17 @@ static void flat_send_IPI_all(int vector) | |||
95 | __send_IPI_shortcut(APIC_DEST_ALLINC, vector, APIC_DEST_LOGICAL); | 97 | __send_IPI_shortcut(APIC_DEST_ALLINC, vector, APIC_DEST_LOGICAL); |
96 | } | 98 | } |
97 | 99 | ||
100 | static unsigned int read_xapic_id(void) | ||
101 | { | ||
102 | unsigned int id; | ||
103 | |||
104 | id = GET_XAPIC_ID(apic_read(APIC_ID)); | ||
105 | return id; | ||
106 | } | ||
107 | |||
98 | static int flat_apic_id_registered(void) | 108 | static int flat_apic_id_registered(void) |
99 | { | 109 | { |
100 | return physid_isset(GET_APIC_ID(read_apic_id()), phys_cpu_present_map); | 110 | return physid_isset(read_xapic_id(), phys_cpu_present_map); |
101 | } | 111 | } |
102 | 112 | ||
103 | static unsigned int flat_cpu_mask_to_apicid(cpumask_t cpumask) | 113 | static unsigned int flat_cpu_mask_to_apicid(cpumask_t cpumask) |
@@ -123,6 +133,7 @@ struct genapic apic_flat = { | |||
123 | .send_IPI_mask = flat_send_IPI_mask, | 133 | .send_IPI_mask = flat_send_IPI_mask, |
124 | .cpu_mask_to_apicid = flat_cpu_mask_to_apicid, | 134 | .cpu_mask_to_apicid = flat_cpu_mask_to_apicid, |
125 | .phys_pkg_id = phys_pkg_id, | 135 | .phys_pkg_id = phys_pkg_id, |
136 | .read_apic_id = read_xapic_id, | ||
126 | }; | 137 | }; |
127 | 138 | ||
128 | /* | 139 | /* |
@@ -187,4 +198,5 @@ struct genapic apic_physflat = { | |||
187 | .send_IPI_mask = physflat_send_IPI_mask, | 198 | .send_IPI_mask = physflat_send_IPI_mask, |
188 | .cpu_mask_to_apicid = physflat_cpu_mask_to_apicid, | 199 | .cpu_mask_to_apicid = physflat_cpu_mask_to_apicid, |
189 | .phys_pkg_id = phys_pkg_id, | 200 | .phys_pkg_id = phys_pkg_id, |
201 | .read_apic_id = read_xapic_id, | ||
190 | }; | 202 | }; |
diff --git a/arch/x86/kernel/genx2apic_uv_x.c b/arch/x86/kernel/genx2apic_uv_x.c index 711f11c30b06..1ef99be18488 100644 --- a/arch/x86/kernel/genx2apic_uv_x.c +++ b/arch/x86/kernel/genx2apic_uv_x.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/sched.h> | 18 | #include <linux/sched.h> |
19 | #include <linux/bootmem.h> | 19 | #include <linux/bootmem.h> |
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | #include <linux/hardirq.h> | ||
21 | #include <asm/smp.h> | 22 | #include <asm/smp.h> |
22 | #include <asm/ipi.h> | 23 | #include <asm/ipi.h> |
23 | #include <asm/genapic.h> | 24 | #include <asm/genapic.h> |
@@ -134,9 +135,19 @@ static unsigned int uv_cpu_mask_to_apicid(cpumask_t cpumask) | |||
134 | return BAD_APICID; | 135 | return BAD_APICID; |
135 | } | 136 | } |
136 | 137 | ||
138 | static unsigned int uv_read_apic_id(void) | ||
139 | { | ||
140 | unsigned int id; | ||
141 | |||
142 | WARN_ON(preemptible() && num_online_cpus() > 1); | ||
143 | id = apic_read(APIC_ID) | __get_cpu_var(x2apic_extra_bits); | ||
144 | |||
145 | return id; | ||
146 | } | ||
147 | |||
137 | static unsigned int phys_pkg_id(int index_msb) | 148 | static unsigned int phys_pkg_id(int index_msb) |
138 | { | 149 | { |
139 | return GET_APIC_ID(read_apic_id()) >> index_msb; | 150 | return uv_read_apic_id() >> index_msb; |
140 | } | 151 | } |
141 | 152 | ||
142 | #ifdef ZZZ /* Needs x2apic patch */ | 153 | #ifdef ZZZ /* Needs x2apic patch */ |
@@ -159,6 +170,7 @@ struct genapic apic_x2apic_uv_x = { | |||
159 | /* ZZZ.send_IPI_self = uv_send_IPI_self, */ | 170 | /* ZZZ.send_IPI_self = uv_send_IPI_self, */ |
160 | .cpu_mask_to_apicid = uv_cpu_mask_to_apicid, | 171 | .cpu_mask_to_apicid = uv_cpu_mask_to_apicid, |
161 | .phys_pkg_id = phys_pkg_id, /* Fixme ZZZ */ | 172 | .phys_pkg_id = phys_pkg_id, /* Fixme ZZZ */ |
173 | .read_apic_id = uv_read_apic_id, | ||
162 | }; | 174 | }; |
163 | 175 | ||
164 | static __cpuinit void set_x2apic_extra_bits(int pnode) | 176 | static __cpuinit void set_x2apic_extra_bits(int pnode) |
diff --git a/include/asm-x86/genapic_64.h b/include/asm-x86/genapic_64.h index 647e4e5c2580..d567abc347a9 100644 --- a/include/asm-x86/genapic_64.h +++ b/include/asm-x86/genapic_64.h | |||
@@ -27,6 +27,7 @@ struct genapic { | |||
27 | /* */ | 27 | /* */ |
28 | unsigned int (*cpu_mask_to_apicid)(cpumask_t cpumask); | 28 | unsigned int (*cpu_mask_to_apicid)(cpumask_t cpumask); |
29 | unsigned int (*phys_pkg_id)(int index_msb); | 29 | unsigned int (*phys_pkg_id)(int index_msb); |
30 | unsigned int (*read_apic_id)(void); | ||
30 | }; | 31 | }; |
31 | 32 | ||
32 | extern struct genapic *genapic; | 33 | extern struct genapic *genapic; |
diff --git a/include/asm-x86/mach-default/mach_apic.h b/include/asm-x86/mach-default/mach_apic.h index 0b2cde5e1b74..d172c554ab9f 100644 --- a/include/asm-x86/mach-default/mach_apic.h +++ b/include/asm-x86/mach-default/mach_apic.h | |||
@@ -30,6 +30,7 @@ static inline cpumask_t target_cpus(void) | |||
30 | #define cpu_mask_to_apicid (genapic->cpu_mask_to_apicid) | 30 | #define cpu_mask_to_apicid (genapic->cpu_mask_to_apicid) |
31 | #define phys_pkg_id (genapic->phys_pkg_id) | 31 | #define phys_pkg_id (genapic->phys_pkg_id) |
32 | #define vector_allocation_domain (genapic->vector_allocation_domain) | 32 | #define vector_allocation_domain (genapic->vector_allocation_domain) |
33 | #define read_apic_id (genapic->read_apic_id) | ||
33 | extern void setup_apic_routing(void); | 34 | extern void setup_apic_routing(void); |
34 | #else | 35 | #else |
35 | #define INT_DELIVERY_MODE dest_LowestPrio | 36 | #define INT_DELIVERY_MODE dest_LowestPrio |
diff --git a/include/asm-x86/mach-default/mach_apicdef.h b/include/asm-x86/mach-default/mach_apicdef.h index e4b29ba37de6..453b58a67e29 100644 --- a/include/asm-x86/mach-default/mach_apicdef.h +++ b/include/asm-x86/mach-default/mach_apicdef.h | |||
@@ -5,8 +5,9 @@ | |||
5 | 5 | ||
6 | #ifdef CONFIG_X86_64 | 6 | #ifdef CONFIG_X86_64 |
7 | #define APIC_ID_MASK (0xFFu<<24) | 7 | #define APIC_ID_MASK (0xFFu<<24) |
8 | #define GET_APIC_ID(x) (((x)>>24)&0xFFu) | 8 | #define GET_APIC_ID(x) (x) |
9 | #define SET_APIC_ID(x) (((x)<<24)) | 9 | #define SET_APIC_ID(x) (((x)<<24)) |
10 | #define GET_XAPIC_ID(x) (((x) >> 24) & 0xFFu) | ||
10 | #else | 11 | #else |
11 | #define APIC_ID_MASK (0xF<<24) | 12 | #define APIC_ID_MASK (0xF<<24) |
12 | static inline unsigned get_apic_id(unsigned long x) | 13 | static inline unsigned get_apic_id(unsigned long x) |
diff --git a/include/asm-x86/smp.h b/include/asm-x86/smp.h index 2e221f1ce0b2..9848715fbd9e 100644 --- a/include/asm-x86/smp.h +++ b/include/asm-x86/smp.h | |||
@@ -169,12 +169,10 @@ static inline unsigned int read_apic_id(void) | |||
169 | { | 169 | { |
170 | return *(u32 *)(APIC_BASE + APIC_ID); | 170 | return *(u32 *)(APIC_BASE + APIC_ID); |
171 | } | 171 | } |
172 | #else | ||
173 | extern unsigned int read_apic_id(void); | ||
174 | #endif | 172 | #endif |
175 | 173 | ||
176 | 174 | ||
177 | # ifdef APIC_DEFINITION | 175 | # if defined(APIC_DEFINITION) || defined(CONFIG_X86_64) |
178 | extern int hard_smp_processor_id(void); | 176 | extern int hard_smp_processor_id(void); |
179 | # else | 177 | # else |
180 | # include <mach_apicdef.h> | 178 | # include <mach_apicdef.h> |