提交 f910a9dc 编写于 作者: Y Yinghai Lu 提交者: Ingo Molnar

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: NYinghai Lu <yhlu.kernel@gmail.com>
Cc: Suresh Siddha <suresh.b.siddha@intel.com>
Signed-off-by: NIngo Molnar <mingo@elte.hu>
上级 4c9961d5
...@@ -97,11 +97,27 @@ static void flat_send_IPI_all(int vector) ...@@ -97,11 +97,27 @@ static void flat_send_IPI_all(int vector)
__send_IPI_shortcut(APIC_DEST_ALLINC, vector, APIC_DEST_LOGICAL); __send_IPI_shortcut(APIC_DEST_ALLINC, vector, APIC_DEST_LOGICAL);
} }
static unsigned int get_apic_id(unsigned long x)
{
unsigned int id;
id = (((x)>>24) & 0xFFu);
return id;
}
static unsigned long set_apic_id(unsigned int id)
{
unsigned long x;
x = ((id & 0xFFu)<<24);
return x;
}
static unsigned int read_xapic_id(void) static unsigned int read_xapic_id(void)
{ {
unsigned int id; unsigned int id;
id = GET_APIC_ID(apic_read(APIC_ID)); id = get_apic_id(apic_read(APIC_ID));
return id; return id;
} }
...@@ -134,7 +150,9 @@ struct genapic apic_flat = { ...@@ -134,7 +150,9 @@ struct genapic apic_flat = {
.send_IPI_self = apic_send_IPI_self, .send_IPI_self = apic_send_IPI_self,
.cpu_mask_to_apicid = flat_cpu_mask_to_apicid, .cpu_mask_to_apicid = flat_cpu_mask_to_apicid,
.phys_pkg_id = phys_pkg_id, .phys_pkg_id = phys_pkg_id,
.read_apic_id = read_xapic_id, .get_apic_id = get_apic_id,
.set_apic_id = set_apic_id,
.apic_id_mask = (0xFFu<<24),
}; };
/* /*
...@@ -200,5 +218,7 @@ struct genapic apic_physflat = { ...@@ -200,5 +218,7 @@ struct genapic apic_physflat = {
.send_IPI_self = apic_send_IPI_self, .send_IPI_self = apic_send_IPI_self,
.cpu_mask_to_apicid = physflat_cpu_mask_to_apicid, .cpu_mask_to_apicid = physflat_cpu_mask_to_apicid,
.phys_pkg_id = phys_pkg_id, .phys_pkg_id = phys_pkg_id,
.read_apic_id = read_xapic_id, .get_apic_id = get_apic_id,
.set_apic_id = set_apic_id,
.apic_id_mask = (0xFFu<<24),
}; };
...@@ -94,6 +94,22 @@ static unsigned int x2apic_cpu_mask_to_apicid(cpumask_t cpumask) ...@@ -94,6 +94,22 @@ static unsigned int x2apic_cpu_mask_to_apicid(cpumask_t cpumask)
return BAD_APICID; return BAD_APICID;
} }
static unsigned int get_apic_id(unsigned long x)
{
unsigned int id;
id = x;
return id;
}
static unsigned long set_apic_id(unsigned int id)
{
unsigned long x;
x = id;
return x;
}
static unsigned int x2apic_read_id(void) static unsigned int x2apic_read_id(void)
{ {
return apic_read(APIC_ID); return apic_read(APIC_ID);
...@@ -131,5 +147,7 @@ struct genapic apic_x2apic_cluster = { ...@@ -131,5 +147,7 @@ struct genapic apic_x2apic_cluster = {
.send_IPI_self = x2apic_send_IPI_self, .send_IPI_self = x2apic_send_IPI_self,
.cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid, .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid,
.phys_pkg_id = phys_pkg_id, .phys_pkg_id = phys_pkg_id,
.read_apic_id = x2apic_read_id, .get_apic_id = get_apic_id,
.set_apic_id = set_apic_id,
.apic_id_mask = (0xFFFFFFFFu),
}; };
...@@ -84,6 +84,22 @@ static unsigned int x2apic_cpu_mask_to_apicid(cpumask_t cpumask) ...@@ -84,6 +84,22 @@ static unsigned int x2apic_cpu_mask_to_apicid(cpumask_t cpumask)
return BAD_APICID; return BAD_APICID;
} }
static unsigned int get_apic_id(unsigned long x)
{
unsigned int id;
id = x;
return id;
}
static unsigned long set_apic_id(unsigned int id)
{
unsigned long x;
x = id;
return x;
}
static unsigned int x2apic_read_id(void) static unsigned int x2apic_read_id(void)
{ {
return apic_read(APIC_ID); return apic_read(APIC_ID);
...@@ -118,5 +134,7 @@ struct genapic apic_x2apic_phys = { ...@@ -118,5 +134,7 @@ struct genapic apic_x2apic_phys = {
.send_IPI_self = x2apic_send_IPI_self, .send_IPI_self = x2apic_send_IPI_self,
.cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid, .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid,
.phys_pkg_id = phys_pkg_id, .phys_pkg_id = phys_pkg_id,
.read_apic_id = x2apic_read_id, .get_apic_id = get_apic_id,
.set_apic_id = set_apic_id,
.apic_id_mask = (0xFFFFFFFFu),
}; };
...@@ -139,16 +139,31 @@ static unsigned int uv_cpu_mask_to_apicid(cpumask_t cpumask) ...@@ -139,16 +139,31 @@ static unsigned int uv_cpu_mask_to_apicid(cpumask_t cpumask)
return BAD_APICID; return BAD_APICID;
} }
static unsigned int uv_read_apic_id(void) static unsigned int get_apic_id(unsigned long x)
{ {
unsigned int id; unsigned int id;
WARN_ON(preemptible() && num_online_cpus() > 1); WARN_ON(preemptible() && num_online_cpus() > 1);
id = apic_read(APIC_ID) | __get_cpu_var(x2apic_extra_bits); id = x | __get_cpu_var(x2apic_extra_bits);
return id; return id;
} }
static long set_apic_id(unsigned int id)
{
unsigned long x;
/* maskout x2apic_extra_bits ? */
x = id;
return x;
}
static unsigned int uv_read_apic_id(void)
{
return get_apic_id(apic_read(APIC_ID));
}
static unsigned int phys_pkg_id(int index_msb) static unsigned int phys_pkg_id(int index_msb)
{ {
return uv_read_apic_id() >> index_msb; return uv_read_apic_id() >> index_msb;
...@@ -175,7 +190,9 @@ struct genapic apic_x2apic_uv_x = { ...@@ -175,7 +190,9 @@ struct genapic apic_x2apic_uv_x = {
/* ZZZ.send_IPI_self = uv_send_IPI_self, */ /* ZZZ.send_IPI_self = uv_send_IPI_self, */
.cpu_mask_to_apicid = uv_cpu_mask_to_apicid, .cpu_mask_to_apicid = uv_cpu_mask_to_apicid,
.phys_pkg_id = phys_pkg_id, /* Fixme ZZZ */ .phys_pkg_id = phys_pkg_id, /* Fixme ZZZ */
.read_apic_id = uv_read_apic_id, .get_apic_id = get_apic_id,
.set_apic_id = set_apic_id,
.apic_id_mask = (0xFFFFFFFFu),
}; };
static __cpuinit void set_x2apic_extra_bits(int pnode) static __cpuinit void set_x2apic_extra_bits(int pnode)
......
...@@ -28,7 +28,9 @@ struct genapic { ...@@ -28,7 +28,9 @@ struct genapic {
/* */ /* */
unsigned int (*cpu_mask_to_apicid)(cpumask_t cpumask); unsigned int (*cpu_mask_to_apicid)(cpumask_t cpumask);
unsigned int (*phys_pkg_id)(int index_msb); unsigned int (*phys_pkg_id)(int index_msb);
unsigned int (*read_apic_id)(void); unsigned int (*get_apic_id)(unsigned long x);
unsigned long (*set_apic_id)(unsigned int id);
unsigned long apic_id_mask;
}; };
extern struct genapic *genapic; extern struct genapic *genapic;
......
...@@ -30,7 +30,7 @@ static inline cpumask_t target_cpus(void) ...@@ -30,7 +30,7 @@ static inline cpumask_t target_cpus(void)
#define cpu_mask_to_apicid (genapic->cpu_mask_to_apicid) #define cpu_mask_to_apicid (genapic->cpu_mask_to_apicid)
#define phys_pkg_id (genapic->phys_pkg_id) #define phys_pkg_id (genapic->phys_pkg_id)
#define vector_allocation_domain (genapic->vector_allocation_domain) #define vector_allocation_domain (genapic->vector_allocation_domain)
#define read_apic_id (genapic->read_apic_id) #define read_apic_id() (GET_APIC_ID(apic_read(APIC_ID)))
#define send_IPI_self (genapic->send_IPI_self) #define send_IPI_self (genapic->send_IPI_self)
extern void setup_apic_routing(void); extern void setup_apic_routing(void);
#else #else
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
#include <asm/apic.h> #include <asm/apic.h>
#ifdef CONFIG_X86_64 #ifdef CONFIG_X86_64
#define APIC_ID_MASK (0xFFu<<24) #define APIC_ID_MASK (genapic->apic_id_mask)
#define GET_APIC_ID(x) (((x)>>24) & 0xFFu) #define GET_APIC_ID(x) (genapic->get_apic_id(x))
#define SET_APIC_ID(x) (((x)<<24)) #define SET_APIC_ID(x) (genapic->set_apic_id(x))
#else #else
#define APIC_ID_MASK (0xF<<24) #define APIC_ID_MASK (0xF<<24)
static inline unsigned get_apic_id(unsigned long x) static inline unsigned get_apic_id(unsigned long x)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册