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 --- a/arch/x86/kernel/apic_64.c
32 +++ b/arch/x86/kernel/apic_64.c
33 @@ -1122,6 +1122,11 @@ void __cpuinit generic_processor_info(in
34 cpu_set(cpu, cpu_present_map);
37 +int hard_smp_processor_id(void)
39 + return read_apic_id();
45 --- a/arch/x86/kernel/genapic_64.c
46 +++ b/arch/x86/kernel/genapic_64.c
47 @@ -79,17 +79,6 @@ int __init acpi_madt_oem_check(char *oem
51 -unsigned int read_apic_id(void)
55 - WARN_ON(preemptible() && num_online_cpus() > 1);
56 - id = apic_read(APIC_ID);
57 - if (uv_system_type >= UV_X2APIC)
58 - id |= __get_cpu_var(x2apic_extra_bits);
62 enum uv_system_type get_uv_system_type(void)
64 return uv_system_type;
65 --- a/arch/x86/kernel/genapic_flat_64.c
66 +++ b/arch/x86/kernel/genapic_flat_64.c
68 #include <linux/kernel.h>
69 #include <linux/ctype.h>
70 #include <linux/init.h>
71 +#include <linux/hardirq.h>
74 #include <asm/genapic.h>
75 +#include <mach_apicdef.h>
77 static cpumask_t flat_target_cpus(void)
79 @@ -95,9 +97,17 @@ static void flat_send_IPI_all(int vector
80 __send_IPI_shortcut(APIC_DEST_ALLINC, vector, APIC_DEST_LOGICAL);
83 +static unsigned int read_xapic_id(void)
87 + id = GET_XAPIC_ID(apic_read(APIC_ID));
91 static int flat_apic_id_registered(void)
93 - return physid_isset(GET_APIC_ID(read_apic_id()), phys_cpu_present_map);
94 + return physid_isset(read_xapic_id(), phys_cpu_present_map);
97 static unsigned int flat_cpu_mask_to_apicid(cpumask_t cpumask)
98 @@ -123,6 +133,7 @@ struct genapic apic_flat = {
99 .send_IPI_mask = flat_send_IPI_mask,
100 .cpu_mask_to_apicid = flat_cpu_mask_to_apicid,
101 .phys_pkg_id = phys_pkg_id,
102 + .read_apic_id = read_xapic_id,
106 @@ -187,4 +198,5 @@ struct genapic apic_physflat = {
107 .send_IPI_mask = physflat_send_IPI_mask,
108 .cpu_mask_to_apicid = physflat_cpu_mask_to_apicid,
109 .phys_pkg_id = phys_pkg_id,
110 + .read_apic_id = read_xapic_id,
112 --- a/arch/x86/kernel/genx2apic_uv_x.c
113 +++ b/arch/x86/kernel/genx2apic_uv_x.c
115 #include <linux/sched.h>
116 #include <linux/bootmem.h>
117 #include <linux/module.h>
118 +#include <linux/hardirq.h>
121 #include <asm/genapic.h>
122 @@ -138,9 +139,19 @@ static unsigned int uv_cpu_mask_to_apici
126 +static unsigned int uv_read_apic_id(void)
130 + WARN_ON(preemptible() && num_online_cpus() > 1);
131 + id = apic_read(APIC_ID) | __get_cpu_var(x2apic_extra_bits);
136 static unsigned int phys_pkg_id(int index_msb)
138 - return GET_APIC_ID(read_apic_id()) >> index_msb;
139 + return uv_read_apic_id() >> index_msb;
142 #ifdef ZZZ /* Needs x2apic patch */
143 @@ -163,6 +174,7 @@ struct genapic apic_x2apic_uv_x = {
144 /* ZZZ.send_IPI_self = uv_send_IPI_self, */
145 .cpu_mask_to_apicid = uv_cpu_mask_to_apicid,
146 .phys_pkg_id = phys_pkg_id, /* Fixme ZZZ */
147 + .read_apic_id = uv_read_apic_id,
150 static __cpuinit void set_x2apic_extra_bits(int pnode)
151 --- a/include/asm-x86/genapic_64.h
152 +++ b/include/asm-x86/genapic_64.h
153 @@ -27,6 +27,7 @@ struct genapic {
155 unsigned int (*cpu_mask_to_apicid)(cpumask_t cpumask);
156 unsigned int (*phys_pkg_id)(int index_msb);
157 + unsigned int (*read_apic_id)(void);
160 extern struct genapic *genapic;
161 --- a/include/asm-x86/mach-default/mach_apic.h
162 +++ b/include/asm-x86/mach-default/mach_apic.h
163 @@ -30,6 +30,7 @@ static inline cpumask_t target_cpus(void
164 #define cpu_mask_to_apicid (genapic->cpu_mask_to_apicid)
165 #define phys_pkg_id (genapic->phys_pkg_id)
166 #define vector_allocation_domain (genapic->vector_allocation_domain)
167 +#define read_apic_id (genapic->read_apic_id)
168 extern void setup_apic_routing(void);
170 #define INT_DELIVERY_MODE dest_LowestPrio
171 --- a/include/asm-x86/mach-default/mach_apicdef.h
172 +++ b/include/asm-x86/mach-default/mach_apicdef.h
176 #define APIC_ID_MASK (0xFFu<<24)
177 -#define GET_APIC_ID(x) (((x)>>24)&0xFFu)
178 +#define GET_APIC_ID(x) (x)
179 #define SET_APIC_ID(x) (((x)<<24))
180 +#define GET_XAPIC_ID(x) (((x) >> 24) & 0xFFu)
182 #define APIC_ID_MASK (0xF<<24)
183 static inline unsigned get_apic_id(unsigned long x)
184 --- a/include/asm-x86/smp.h
185 +++ b/include/asm-x86/smp.h
186 @@ -176,12 +176,10 @@ static inline unsigned int read_apic_id(
188 return *(u32 *)(APIC_BASE + APIC_ID);
191 -extern unsigned int read_apic_id(void);
195 -# ifdef APIC_DEFINITION
196 +# if defined(APIC_DEFINITION) || defined(CONFIG_X86_64)
197 extern int hard_smp_processor_id(void);
199 # include <mach_apicdef.h>