aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYinghai Lu <yhlu.kernel@gmail.com>2008-07-12 04:01:20 -0400
committerIngo Molnar <mingo@elte.hu>2008-07-13 02:27:46 -0400
commitf910a9dc7c865896815e2a95fe33363e9522f277 (patch)
treea4d1361f7d38dd358da62a1c14191cdbf6011d98
parent4c9961d56ec20c27ec5d02e49fd7427748312741 (diff)
x86: make 64bit have get_apic_id
generalize the x2apic code some more. let read_apic_id become a macro (later on a function/inline) GET_APIC_ID(apic_read(APIC_ID)) +#define read_apic_id() (GET_APIC_ID(apic_read(APIC_ID))) instead of this weird construct: -#define read_apic_id (genapic->read_apic_id) Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com> Cc: Suresh Siddha <suresh.b.siddha@intel.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--arch/x86/kernel/genapic_flat_64.c26
-rw-r--r--arch/x86/kernel/genx2apic_cluster.c20
-rw-r--r--arch/x86/kernel/genx2apic_phys.c20
-rw-r--r--arch/x86/kernel/genx2apic_uv_x.c23
-rw-r--r--include/asm-x86/genapic_64.h4
-rw-r--r--include/asm-x86/mach-default/mach_apic.h2
-rw-r--r--include/asm-x86/mach-default/mach_apicdef.h6
7 files changed, 88 insertions, 13 deletions
diff --git a/arch/x86/kernel/genapic_flat_64.c b/arch/x86/kernel/genapic_flat_64.c
index 7dac2f275fad..2c973cbf054f 100644
--- a/arch/x86/kernel/genapic_flat_64.c
+++ b/arch/x86/kernel/genapic_flat_64.c
@@ -97,11 +97,27 @@ static void flat_send_IPI_all(int vector)
97 __send_IPI_shortcut(APIC_DEST_ALLINC, vector, APIC_DEST_LOGICAL); 97 __send_IPI_shortcut(APIC_DEST_ALLINC, vector, APIC_DEST_LOGICAL);
98} 98}
99 99
100static unsigned int get_apic_id(unsigned long x)
101{
102 unsigned int id;
103
104 id = (((x)>>24) & 0xFFu);
105 return id;
106}
107
108static unsigned long set_apic_id(unsigned int id)
109{
110 unsigned long x;
111
112 x = ((id & 0xFFu)<<24);
113 return x;
114}
115
100static unsigned int read_xapic_id(void) 116static unsigned int read_xapic_id(void)
101{ 117{
102 unsigned int id; 118 unsigned int id;
103 119
104 id = GET_APIC_ID(apic_read(APIC_ID)); 120 id = get_apic_id(apic_read(APIC_ID));
105 return id; 121 return id;
106} 122}
107 123
@@ -134,7 +150,9 @@ struct genapic apic_flat = {
134 .send_IPI_self = apic_send_IPI_self, 150 .send_IPI_self = apic_send_IPI_self,
135 .cpu_mask_to_apicid = flat_cpu_mask_to_apicid, 151 .cpu_mask_to_apicid = flat_cpu_mask_to_apicid,
136 .phys_pkg_id = phys_pkg_id, 152 .phys_pkg_id = phys_pkg_id,
137 .read_apic_id = read_xapic_id, 153 .get_apic_id = get_apic_id,
154 .set_apic_id = set_apic_id,
155 .apic_id_mask = (0xFFu<<24),
138}; 156};
139 157
140/* 158/*
@@ -200,5 +218,7 @@ struct genapic apic_physflat = {
200 .send_IPI_self = apic_send_IPI_self, 218 .send_IPI_self = apic_send_IPI_self,
201 .cpu_mask_to_apicid = physflat_cpu_mask_to_apicid, 219 .cpu_mask_to_apicid = physflat_cpu_mask_to_apicid,
202 .phys_pkg_id = phys_pkg_id, 220 .phys_pkg_id = phys_pkg_id,
203 .read_apic_id = read_xapic_id, 221 .get_apic_id = get_apic_id,
222 .set_apic_id = set_apic_id,
223 .apic_id_mask = (0xFFu<<24),
204}; 224};
diff --git a/arch/x86/kernel/genx2apic_cluster.c b/arch/x86/kernel/genx2apic_cluster.c
index ed0fdede800a..40bc0140d89f 100644
--- a/arch/x86/kernel/genx2apic_cluster.c
+++ b/arch/x86/kernel/genx2apic_cluster.c
@@ -94,6 +94,22 @@ static unsigned int x2apic_cpu_mask_to_apicid(cpumask_t cpumask)
94 return BAD_APICID; 94 return BAD_APICID;
95} 95}
96 96
97static unsigned int get_apic_id(unsigned long x)
98{
99 unsigned int id;
100
101 id = x;
102 return id;
103}
104
105static unsigned long set_apic_id(unsigned int id)
106{
107 unsigned long x;
108
109 x = id;
110 return x;
111}
112
97static unsigned int x2apic_read_id(void) 113static unsigned int x2apic_read_id(void)
98{ 114{
99 return apic_read(APIC_ID); 115 return apic_read(APIC_ID);
@@ -131,5 +147,7 @@ struct genapic apic_x2apic_cluster = {
131 .send_IPI_self = x2apic_send_IPI_self, 147 .send_IPI_self = x2apic_send_IPI_self,
132 .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid, 148 .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid,
133 .phys_pkg_id = phys_pkg_id, 149 .phys_pkg_id = phys_pkg_id,
134 .read_apic_id = x2apic_read_id, 150 .get_apic_id = get_apic_id,
151 .set_apic_id = set_apic_id,
152 .apic_id_mask = (0xFFFFFFFFu),
135}; 153};
diff --git a/arch/x86/kernel/genx2apic_phys.c b/arch/x86/kernel/genx2apic_phys.c
index 3c70b9d692b2..2f3c6ca19de9 100644
--- a/arch/x86/kernel/genx2apic_phys.c
+++ b/arch/x86/kernel/genx2apic_phys.c
@@ -84,6 +84,22 @@ static unsigned int x2apic_cpu_mask_to_apicid(cpumask_t cpumask)
84 return BAD_APICID; 84 return BAD_APICID;
85} 85}
86 86
87static unsigned int get_apic_id(unsigned long x)
88{
89 unsigned int id;
90
91 id = x;
92 return id;
93}
94
95static unsigned long set_apic_id(unsigned int id)
96{
97 unsigned long x;
98
99 x = id;
100 return x;
101}
102
87static unsigned int x2apic_read_id(void) 103static unsigned int x2apic_read_id(void)
88{ 104{
89 return apic_read(APIC_ID); 105 return apic_read(APIC_ID);
@@ -118,5 +134,7 @@ struct genapic apic_x2apic_phys = {
118 .send_IPI_self = x2apic_send_IPI_self, 134 .send_IPI_self = x2apic_send_IPI_self,
119 .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid, 135 .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid,
120 .phys_pkg_id = phys_pkg_id, 136 .phys_pkg_id = phys_pkg_id,
121 .read_apic_id = x2apic_read_id, 137 .get_apic_id = get_apic_id,
138 .set_apic_id = set_apic_id,
139 .apic_id_mask = (0xFFFFFFFFu),
122}; 140};
diff --git a/arch/x86/kernel/genx2apic_uv_x.c b/arch/x86/kernel/genx2apic_uv_x.c
index c915f750241e..3ca29cd8c23c 100644
--- a/arch/x86/kernel/genx2apic_uv_x.c
+++ b/arch/x86/kernel/genx2apic_uv_x.c
@@ -139,16 +139,31 @@ static unsigned int uv_cpu_mask_to_apicid(cpumask_t cpumask)
139 return BAD_APICID; 139 return BAD_APICID;
140} 140}
141 141
142static unsigned int uv_read_apic_id(void) 142static unsigned int get_apic_id(unsigned long x)
143{ 143{
144 unsigned int id; 144 unsigned int id;
145 145
146 WARN_ON(preemptible() && num_online_cpus() > 1); 146 WARN_ON(preemptible() && num_online_cpus() > 1);
147 id = apic_read(APIC_ID) | __get_cpu_var(x2apic_extra_bits); 147 id = x | __get_cpu_var(x2apic_extra_bits);
148 148
149 return id; 149 return id;
150} 150}
151 151
152static long set_apic_id(unsigned int id)
153{
154 unsigned long x;
155
156 /* maskout x2apic_extra_bits ? */
157 x = id;
158 return x;
159}
160
161static unsigned int uv_read_apic_id(void)
162{
163
164 return get_apic_id(apic_read(APIC_ID));
165}
166
152static unsigned int phys_pkg_id(int index_msb) 167static unsigned int phys_pkg_id(int index_msb)
153{ 168{
154 return uv_read_apic_id() >> index_msb; 169 return uv_read_apic_id() >> index_msb;
@@ -175,7 +190,9 @@ struct genapic apic_x2apic_uv_x = {
175 /* ZZZ.send_IPI_self = uv_send_IPI_self, */ 190 /* ZZZ.send_IPI_self = uv_send_IPI_self, */
176 .cpu_mask_to_apicid = uv_cpu_mask_to_apicid, 191 .cpu_mask_to_apicid = uv_cpu_mask_to_apicid,
177 .phys_pkg_id = phys_pkg_id, /* Fixme ZZZ */ 192 .phys_pkg_id = phys_pkg_id, /* Fixme ZZZ */
178 .read_apic_id = uv_read_apic_id, 193 .get_apic_id = get_apic_id,
194 .set_apic_id = set_apic_id,
195 .apic_id_mask = (0xFFFFFFFFu),
179}; 196};
180 197
181static __cpuinit void set_x2apic_extra_bits(int pnode) 198static __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 122b9242a40f..8ff2589da93b 100644
--- a/include/asm-x86/genapic_64.h
+++ b/include/asm-x86/genapic_64.h
@@ -28,7 +28,9 @@ struct genapic {
28 /* */ 28 /* */
29 unsigned int (*cpu_mask_to_apicid)(cpumask_t cpumask); 29 unsigned int (*cpu_mask_to_apicid)(cpumask_t cpumask);
30 unsigned int (*phys_pkg_id)(int index_msb); 30 unsigned int (*phys_pkg_id)(int index_msb);
31 unsigned int (*read_apic_id)(void); 31 unsigned int (*get_apic_id)(unsigned long x);
32 unsigned long (*set_apic_id)(unsigned int id);
33 unsigned long apic_id_mask;
32}; 34};
33 35
34extern struct genapic *genapic; 36extern struct genapic *genapic;
diff --git a/include/asm-x86/mach-default/mach_apic.h b/include/asm-x86/mach-default/mach_apic.h
index 925b797e2a26..3d2b455581ec 100644
--- a/include/asm-x86/mach-default/mach_apic.h
+++ b/include/asm-x86/mach-default/mach_apic.h
@@ -30,7 +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#define read_apic_id() (GET_APIC_ID(apic_read(APIC_ID)))
34#define send_IPI_self (genapic->send_IPI_self) 34#define send_IPI_self (genapic->send_IPI_self)
35extern void setup_apic_routing(void); 35extern void setup_apic_routing(void);
36#else 36#else
diff --git a/include/asm-x86/mach-default/mach_apicdef.h b/include/asm-x86/mach-default/mach_apicdef.h
index 3e1be6c99b35..a55518aa5a2d 100644
--- a/include/asm-x86/mach-default/mach_apicdef.h
+++ b/include/asm-x86/mach-default/mach_apicdef.h
@@ -4,9 +4,9 @@
4#include <asm/apic.h> 4#include <asm/apic.h>
5 5
6#ifdef CONFIG_X86_64 6#ifdef CONFIG_X86_64
7#define APIC_ID_MASK (0xFFu<<24) 7#define APIC_ID_MASK (genapic->apic_id_mask)
8#define GET_APIC_ID(x) (((x)>>24) & 0xFFu) 8#define GET_APIC_ID(x) (genapic->get_apic_id(x))
9#define SET_APIC_ID(x) (((x)<<24)) 9#define SET_APIC_ID(x) (genapic->set_apic_id(x))
10#else 10#else
11#define APIC_ID_MASK (0xF<<24) 11#define APIC_ID_MASK (0xF<<24)
12static inline unsigned get_apic_id(unsigned long x) 12static inline unsigned get_apic_id(unsigned long x)