1 From: Suresh Siddha <suresh.b.siddha@intel.com>
2 Subject: x64, x2apic/intr-remap: introduce read_apic_id() to genapic routines
3 References: fate #303948 and fate #303984
4 Patch-Mainline: queued for .28
5 Commit-ID: 0c81c746f9bdbfaafe64322d540c8b7b59c27314
7 Signed-off-by: Thomas Renninger <trenn@suse.de>
9 Move the read_apic_id() to genapic routines.
11 Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
12 Cc: akpm@linux-foundation.org
13 Cc: arjan@linux.intel.com
14 Cc: andi@firstfloor.org
15 Cc: ebiederm@xmission.com
16 Cc: jbarnes@virtuousgeek.org
18 Signed-off-by: Ingo Molnar <mingo@elte.hu>
21 arch/x86/kernel/apic_64.c | 5 +++++
22 arch/x86/kernel/genapic_64.c | 11 -----------
23 arch/x86/kernel/genapic_flat_64.c | 14 +++++++++++++-
24 arch/x86/kernel/genx2apic_uv_x.c | 14 +++++++++++++-
25 include/asm-x86/genapic_64.h | 1 +
26 include/asm-x86/mach-default/mach_apic.h | 1 +
27 include/asm-x86/mach-default/mach_apicdef.h | 3 ++-
28 include/asm-x86/smp.h | 4 +---
29 8 files changed, 36 insertions(+), 17 deletions(-)
31 Index: linux-2.6.26/arch/x86/kernel/apic_64.c
32 ===================================================================
33 --- linux-2.6.26.orig/arch/x86/kernel/apic_64.c
34 +++ linux-2.6.26/arch/x86/kernel/apic_64.c
35 @@ -1095,6 +1095,11 @@ void __cpuinit generic_processor_info(in
36 cpu_set(cpu, cpu_present_map);
39 +int hard_smp_processor_id(void)
41 + return read_apic_id();
47 Index: linux-2.6.26/arch/x86/kernel/genapic_64.c
48 ===================================================================
49 --- linux-2.6.26.orig/arch/x86/kernel/genapic_64.c
50 +++ linux-2.6.26/arch/x86/kernel/genapic_64.c
51 @@ -79,17 +79,6 @@ int __init acpi_madt_oem_check(char *oem
55 -unsigned int read_apic_id(void)
59 - WARN_ON(preemptible() && num_online_cpus() > 1);
60 - id = apic_read(APIC_ID);
61 - if (uv_system_type >= UV_X2APIC)
62 - id |= __get_cpu_var(x2apic_extra_bits);
66 enum uv_system_type get_uv_system_type(void)
68 return uv_system_type;
69 Index: linux-2.6.26/arch/x86/kernel/genapic_flat_64.c
70 ===================================================================
71 --- linux-2.6.26.orig/arch/x86/kernel/genapic_flat_64.c
72 +++ linux-2.6.26/arch/x86/kernel/genapic_flat_64.c
74 #include <linux/kernel.h>
75 #include <linux/ctype.h>
76 #include <linux/init.h>
77 +#include <linux/hardirq.h>
80 #include <asm/genapic.h>
81 +#include <mach_apicdef.h>
83 static cpumask_t flat_target_cpus(void)
85 @@ -95,9 +97,17 @@ static void flat_send_IPI_all(int vector
86 __send_IPI_shortcut(APIC_DEST_ALLINC, vector, APIC_DEST_LOGICAL);
89 +static unsigned int read_xapic_id(void)
93 + id = GET_XAPIC_ID(apic_read(APIC_ID));
97 static int flat_apic_id_registered(void)
99 - return physid_isset(GET_APIC_ID(read_apic_id()), phys_cpu_present_map);
100 + return physid_isset(read_xapic_id(), phys_cpu_present_map);
103 static unsigned int flat_cpu_mask_to_apicid(cpumask_t cpumask)
104 @@ -123,6 +133,7 @@ struct genapic apic_flat = {
105 .send_IPI_mask = flat_send_IPI_mask,
106 .cpu_mask_to_apicid = flat_cpu_mask_to_apicid,
107 .phys_pkg_id = phys_pkg_id,
108 + .read_apic_id = read_xapic_id,
112 @@ -187,4 +198,5 @@ struct genapic apic_physflat = {
113 .send_IPI_mask = physflat_send_IPI_mask,
114 .cpu_mask_to_apicid = physflat_cpu_mask_to_apicid,
115 .phys_pkg_id = phys_pkg_id,
116 + .read_apic_id = read_xapic_id,
118 Index: linux-2.6.26/arch/x86/kernel/genx2apic_uv_x.c
119 ===================================================================
120 --- linux-2.6.26.orig/arch/x86/kernel/genx2apic_uv_x.c
121 +++ linux-2.6.26/arch/x86/kernel/genx2apic_uv_x.c
123 #include <linux/sched.h>
124 #include <linux/bootmem.h>
125 #include <linux/module.h>
126 +#include <linux/hardirq.h>
129 #include <asm/genapic.h>
130 @@ -138,9 +139,19 @@ static unsigned int uv_cpu_mask_to_apici
134 +static unsigned int uv_read_apic_id(void)
138 + WARN_ON(preemptible() && num_online_cpus() > 1);
139 + id = apic_read(APIC_ID) | __get_cpu_var(x2apic_extra_bits);
144 static unsigned int phys_pkg_id(int index_msb)
146 - return GET_APIC_ID(read_apic_id()) >> index_msb;
147 + return uv_read_apic_id() >> index_msb;
150 #ifdef ZZZ /* Needs x2apic patch */
151 @@ -163,6 +174,7 @@ struct genapic apic_x2apic_uv_x = {
152 /* ZZZ.send_IPI_self = uv_send_IPI_self, */
153 .cpu_mask_to_apicid = uv_cpu_mask_to_apicid,
154 .phys_pkg_id = phys_pkg_id, /* Fixme ZZZ */
155 + .read_apic_id = uv_read_apic_id,
158 static __cpuinit void set_x2apic_extra_bits(int pnode)
159 Index: linux-2.6.26/include/asm-x86/genapic_64.h
160 ===================================================================
161 --- linux-2.6.26.orig/include/asm-x86/genapic_64.h
162 +++ linux-2.6.26/include/asm-x86/genapic_64.h
163 @@ -27,6 +27,7 @@ struct genapic {
165 unsigned int (*cpu_mask_to_apicid)(cpumask_t cpumask);
166 unsigned int (*phys_pkg_id)(int index_msb);
167 + unsigned int (*read_apic_id)(void);
170 extern struct genapic *genapic;
171 Index: linux-2.6.26/include/asm-x86/mach-default/mach_apic.h
172 ===================================================================
173 --- linux-2.6.26.orig/include/asm-x86/mach-default/mach_apic.h
174 +++ linux-2.6.26/include/asm-x86/mach-default/mach_apic.h
175 @@ -30,6 +30,7 @@ static inline cpumask_t target_cpus(void
176 #define cpu_mask_to_apicid (genapic->cpu_mask_to_apicid)
177 #define phys_pkg_id (genapic->phys_pkg_id)
178 #define vector_allocation_domain (genapic->vector_allocation_domain)
179 +#define read_apic_id (genapic->read_apic_id)
180 extern void setup_apic_routing(void);
182 #define INT_DELIVERY_MODE dest_LowestPrio
183 Index: linux-2.6.26/include/asm-x86/mach-default/mach_apicdef.h
184 ===================================================================
185 --- linux-2.6.26.orig/include/asm-x86/mach-default/mach_apicdef.h
186 +++ linux-2.6.26/include/asm-x86/mach-default/mach_apicdef.h
190 #define APIC_ID_MASK (0xFFu<<24)
191 -#define GET_APIC_ID(x) (((x)>>24)&0xFFu)
192 +#define GET_APIC_ID(x) (x)
193 #define SET_APIC_ID(x) (((x)<<24))
194 +#define GET_XAPIC_ID(x) (((x) >> 24) & 0xFFu)
196 #define APIC_ID_MASK (0xF<<24)
197 static inline unsigned get_apic_id(unsigned long x)
198 Index: linux-2.6.26/include/asm-x86/smp.h
199 ===================================================================
200 --- linux-2.6.26.orig/include/asm-x86/smp.h
201 +++ linux-2.6.26/include/asm-x86/smp.h
202 @@ -176,12 +176,10 @@ static inline unsigned int read_apic_id(
204 return *(u32 *)(APIC_BASE + APIC_ID);
207 -extern unsigned int read_apic_id(void);
211 -# ifdef APIC_DEFINITION
212 +# if defined(APIC_DEFINITION) || defined(CONFIG_X86_64)
213 extern int hard_smp_processor_id(void);
215 # include <mach_apicdef.h>