aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-x86
diff options
context:
space:
mode:
authorSuresh Siddha <suresh.b.siddha@intel.com>2008-07-10 14:16:49 -0400
committerIngo Molnar <mingo@elte.hu>2008-07-12 02:44:59 -0400
commit1b374e4d6f8b3eb2fcd034fcc24ea8ba1dfde7aa (patch)
treefaf5aa00e344e473957206bc82ffbb746e438d0b /include/asm-x86
parent2d7a66d02e11af9ab8e16c76d22767e622b4e3d7 (diff)
x64, x2apic/intr-remap: basic apic ops support
Introduce basic apic operations which handle the apic programming. This will be used later to introduce another specific operations for x2apic. For the perfomance critial accesses like IPI's, EOI etc, we use the native operations as they are already referenced by different indirections like genapic, irq_chip etc. 64bit Paravirt ops can also define their apic operations accordingly. 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>
Diffstat (limited to 'include/asm-x86')
-rw-r--r--include/asm-x86/apic.h43
-rw-r--r--include/asm-x86/ipi.h16
-rw-r--r--include/asm-x86/paravirt.h2
-rw-r--r--include/asm-x86/smp.h2
4 files changed, 51 insertions, 12 deletions
diff --git a/include/asm-x86/apic.h b/include/asm-x86/apic.h
index 4e2c1e517f06..6fda195337c5 100644
--- a/include/asm-x86/apic.h
+++ b/include/asm-x86/apic.h
@@ -47,32 +47,59 @@ extern int disable_apic;
47#ifdef CONFIG_PARAVIRT 47#ifdef CONFIG_PARAVIRT
48#include <asm/paravirt.h> 48#include <asm/paravirt.h>
49#else 49#else
50#define apic_write native_apic_write 50#ifndef CONFIG_X86_64
51#define apic_write_atomic native_apic_write_atomic 51#define apic_write native_apic_mem_write
52#define apic_read native_apic_read 52#define apic_write_atomic native_apic_mem_write_atomic
53#define apic_read native_apic_mem_read
54#endif
53#define setup_boot_clock setup_boot_APIC_clock 55#define setup_boot_clock setup_boot_APIC_clock
54#define setup_secondary_clock setup_secondary_APIC_clock 56#define setup_secondary_clock setup_secondary_APIC_clock
55#endif 57#endif
56 58
57extern int is_vsmp_box(void); 59extern int is_vsmp_box(void);
58 60
59static inline void native_apic_write(unsigned long reg, u32 v) 61static inline void native_apic_mem_write(u32 reg, u32 v)
60{ 62{
61 *((volatile u32 *)(APIC_BASE + reg)) = v; 63 *((volatile u32 *)(APIC_BASE + reg)) = v;
62} 64}
63 65
64static inline void native_apic_write_atomic(unsigned long reg, u32 v) 66static inline void native_apic_mem_write_atomic(u32 reg, u32 v)
65{ 67{
66 (void)xchg((u32 *)(APIC_BASE + reg), v); 68 (void)xchg((u32 *)(APIC_BASE + reg), v);
67} 69}
68 70
69static inline u32 native_apic_read(unsigned long reg) 71static inline u32 native_apic_mem_read(u32 reg)
70{ 72{
71 return *((volatile u32 *)(APIC_BASE + reg)); 73 return *((volatile u32 *)(APIC_BASE + reg));
72} 74}
73 75
76#ifdef CONFIG_X86_32
74extern void apic_wait_icr_idle(void); 77extern void apic_wait_icr_idle(void);
75extern u32 safe_apic_wait_icr_idle(void); 78extern u32 safe_apic_wait_icr_idle(void);
79extern void apic_icr_write(u32 low, u32 id);
80#else
81
82struct apic_ops {
83 u32 (*read)(u32 reg);
84 void (*write)(u32 reg, u32 v);
85 void (*write_atomic)(u32 reg, u32 v);
86 u64 (*icr_read)(void);
87 void (*icr_write)(u32 low, u32 high);
88 void (*wait_icr_idle)(void);
89 u32 (*safe_wait_icr_idle)(void);
90};
91
92extern struct apic_ops *apic_ops;
93
94#define apic_read (apic_ops->read)
95#define apic_write (apic_ops->write)
96#define apic_write_atomic (apic_ops->write_atomic)
97#define apic_icr_read (apic_ops->icr_read)
98#define apic_icr_write (apic_ops->icr_write)
99#define apic_wait_icr_idle (apic_ops->wait_icr_idle)
100#define safe_apic_wait_icr_idle (apic_ops->safe_wait_icr_idle)
101#endif
102
76extern int get_physical_broadcast(void); 103extern int get_physical_broadcast(void);
77 104
78#ifdef CONFIG_X86_GOOD_APIC 105#ifdef CONFIG_X86_GOOD_APIC
@@ -95,7 +122,11 @@ static inline void ack_APIC_irq(void)
95 */ 122 */
96 123
97 /* Docs say use 0 for future compatibility */ 124 /* Docs say use 0 for future compatibility */
125#ifdef CONFIG_X86_32
98 apic_write_around(APIC_EOI, 0); 126 apic_write_around(APIC_EOI, 0);
127#else
128 native_apic_mem_write(APIC_EOI, 0);
129#endif
99} 130}
100 131
101extern int lapic_get_maxlvt(void); 132extern int lapic_get_maxlvt(void);
diff --git a/include/asm-x86/ipi.h b/include/asm-x86/ipi.h
index 196d63c28aa4..3d8d6a6c1f8e 100644
--- a/include/asm-x86/ipi.h
+++ b/include/asm-x86/ipi.h
@@ -49,6 +49,12 @@ static inline int __prepare_ICR2(unsigned int mask)
49 return SET_APIC_DEST_FIELD(mask); 49 return SET_APIC_DEST_FIELD(mask);
50} 50}
51 51
52static inline void __xapic_wait_icr_idle(void)
53{
54 while (native_apic_mem_read(APIC_ICR) & APIC_ICR_BUSY)
55 cpu_relax();
56}
57
52static inline void __send_IPI_shortcut(unsigned int shortcut, int vector, 58static inline void __send_IPI_shortcut(unsigned int shortcut, int vector,
53 unsigned int dest) 59 unsigned int dest)
54{ 60{
@@ -64,7 +70,7 @@ static inline void __send_IPI_shortcut(unsigned int shortcut, int vector,
64 /* 70 /*
65 * Wait for idle. 71 * Wait for idle.
66 */ 72 */
67 apic_wait_icr_idle(); 73 __xapic_wait_icr_idle();
68 74
69 /* 75 /*
70 * No need to touch the target chip field 76 * No need to touch the target chip field
@@ -74,7 +80,7 @@ static inline void __send_IPI_shortcut(unsigned int shortcut, int vector,
74 /* 80 /*
75 * Send the IPI. The write to APIC_ICR fires this off. 81 * Send the IPI. The write to APIC_ICR fires this off.
76 */ 82 */
77 apic_write(APIC_ICR, cfg); 83 native_apic_mem_write(APIC_ICR, cfg);
78} 84}
79 85
80/* 86/*
@@ -92,13 +98,13 @@ static inline void __send_IPI_dest_field(unsigned int mask, int vector,
92 if (unlikely(vector == NMI_VECTOR)) 98 if (unlikely(vector == NMI_VECTOR))
93 safe_apic_wait_icr_idle(); 99 safe_apic_wait_icr_idle();
94 else 100 else
95 apic_wait_icr_idle(); 101 __xapic_wait_icr_idle();
96 102
97 /* 103 /*
98 * prepare target chip field 104 * prepare target chip field
99 */ 105 */
100 cfg = __prepare_ICR2(mask); 106 cfg = __prepare_ICR2(mask);
101 apic_write(APIC_ICR2, cfg); 107 native_apic_mem_write(APIC_ICR2, cfg);
102 108
103 /* 109 /*
104 * program the ICR 110 * program the ICR
@@ -108,7 +114,7 @@ static inline void __send_IPI_dest_field(unsigned int mask, int vector,
108 /* 114 /*
109 * Send the IPI. The write to APIC_ICR fires this off. 115 * Send the IPI. The write to APIC_ICR fires this off.
110 */ 116 */
111 apic_write(APIC_ICR, cfg); 117 native_apic_mem_write(APIC_ICR, cfg);
112} 118}
113 119
114static inline void send_IPI_mask_sequence(cpumask_t mask, int vector) 120static inline void send_IPI_mask_sequence(cpumask_t mask, int vector)
diff --git a/include/asm-x86/paravirt.h b/include/asm-x86/paravirt.h
index ef5e8ec6a6ab..10adac02e6db 100644
--- a/include/asm-x86/paravirt.h
+++ b/include/asm-x86/paravirt.h
@@ -891,6 +891,7 @@ static inline void slow_down_io(void)
891/* 891/*
892 * Basic functions accessing APICs. 892 * Basic functions accessing APICs.
893 */ 893 */
894#ifndef CONFIG_X86_64
894static inline void apic_write(unsigned long reg, u32 v) 895static inline void apic_write(unsigned long reg, u32 v)
895{ 896{
896 PVOP_VCALL2(pv_apic_ops.apic_write, reg, v); 897 PVOP_VCALL2(pv_apic_ops.apic_write, reg, v);
@@ -905,6 +906,7 @@ static inline u32 apic_read(unsigned long reg)
905{ 906{
906 return PVOP_CALL1(unsigned long, pv_apic_ops.apic_read, reg); 907 return PVOP_CALL1(unsigned long, pv_apic_ops.apic_read, reg);
907} 908}
909#endif
908 910
909static inline void setup_boot_clock(void) 911static inline void setup_boot_clock(void)
910{ 912{
diff --git a/include/asm-x86/smp.h b/include/asm-x86/smp.h
index 9848715fbd9e..d9d007d22785 100644
--- a/include/asm-x86/smp.h
+++ b/include/asm-x86/smp.h
@@ -158,13 +158,13 @@ extern int safe_smp_processor_id(void);
158 158
159#ifdef CONFIG_X86_LOCAL_APIC 159#ifdef CONFIG_X86_LOCAL_APIC
160 160
161#ifndef CONFIG_X86_64
161static inline int logical_smp_processor_id(void) 162static inline int logical_smp_processor_id(void)
162{ 163{
163 /* we don't want to mark this access volatile - bad code generation */ 164 /* we don't want to mark this access volatile - bad code generation */
164 return GET_APIC_LOGICAL_ID(*(u32 *)(APIC_BASE + APIC_LDR)); 165 return GET_APIC_LOGICAL_ID(*(u32 *)(APIC_BASE + APIC_LDR));
165} 166}
166 167
167#ifndef CONFIG_X86_64
168static inline unsigned int read_apic_id(void) 168static inline unsigned int read_apic_id(void)
169{ 169{
170 return *(u32 *)(APIC_BASE + APIC_ID); 170 return *(u32 *)(APIC_BASE + APIC_ID);