Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86, x2apic: Move the common bits to x2apic.h

To eliminate code duplication.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
Cc: steiner@sgi.com
Cc: yinghai@kernel.org
Link: http://lkml.kernel.org/r/20110519234637.591426753@sbsiddha-MOBL3.sc.intel.com
Signed-off-by: Ingo Molnar <mingo@elte.hu>

authored by

Cyrill Gorcunov and committed by
Ingo Molnar
79deb8e5 9d0fa6c5

+69 -124
+62
arch/x86/include/asm/x2apic.h
··· 1 + /* 2 + * Common bits for X2APIC cluster/physical modes. 3 + */ 4 + 5 + #ifndef _ASM_X86_X2APIC_H 6 + #define _ASM_X86_X2APIC_H 7 + 8 + #include <asm/apic.h> 9 + #include <asm/ipi.h> 10 + #include <linux/cpumask.h> 11 + 12 + /* 13 + * Need to use more than cpu 0, because we need more vectors 14 + * when MSI-X are used. 15 + */ 16 + static const struct cpumask *x2apic_target_cpus(void) 17 + { 18 + return cpu_online_mask; 19 + } 20 + 21 + static int x2apic_apic_id_registered(void) 22 + { 23 + return 1; 24 + } 25 + 26 + /* 27 + * For now each logical cpu is in its own vector allocation domain. 28 + */ 29 + static void x2apic_vector_allocation_domain(int cpu, struct cpumask *retmask) 30 + { 31 + cpumask_clear(retmask); 32 + cpumask_set_cpu(cpu, retmask); 33 + } 34 + 35 + static void 36 + __x2apic_send_IPI_dest(unsigned int apicid, int vector, unsigned int dest) 37 + { 38 + unsigned long cfg = __prepare_ICR(0, vector, dest); 39 + native_x2apic_icr_write(cfg, apicid); 40 + } 41 + 42 + static unsigned int x2apic_get_apic_id(unsigned long id) 43 + { 44 + return id; 45 + } 46 + 47 + static unsigned long x2apic_set_apic_id(unsigned int id) 48 + { 49 + return id; 50 + } 51 + 52 + static int x2apic_phys_pkg_id(int initial_apicid, int index_msb) 53 + { 54 + return initial_apicid >> index_msb; 55 + } 56 + 57 + static void x2apic_send_IPI_self(int vector) 58 + { 59 + apic_write(APIC_SELF_IPI, vector); 60 + } 61 + 62 + #endif /* _ASM_X86_X2APIC_H */
+4 -67
arch/x86/kernel/apic/x2apic_cluster.c
··· 8 8 #include <linux/cpu.h> 9 9 10 10 #include <asm/smp.h> 11 - #include <asm/apic.h> 12 - #include <asm/ipi.h> 11 + #include <asm/x2apic.h> 13 12 14 13 static DEFINE_PER_CPU(u32, x86_cpu_to_logical_apicid); 15 14 static DEFINE_PER_CPU(cpumask_var_t, cpus_in_cluster); ··· 17 18 static int x2apic_acpi_madt_oem_check(char *oem_id, char *oem_table_id) 18 19 { 19 20 return x2apic_enabled(); 20 - } 21 - 22 - /* 23 - * need to use more than cpu 0, because we need more vectors when 24 - * MSI-X are used. 25 - */ 26 - static const struct cpumask *x2apic_target_cpus(void) 27 - { 28 - return cpu_online_mask; 29 - } 30 - 31 - /* 32 - * for now each logical cpu is in its own vector allocation domain. 33 - */ 34 - static void x2apic_vector_allocation_domain(int cpu, struct cpumask *retmask) 35 - { 36 - cpumask_clear(retmask); 37 - cpumask_set_cpu(cpu, retmask); 38 - } 39 - 40 - static void 41 - __x2apic_send_IPI_dest(unsigned int apicid, int vector, unsigned int dest) 42 - { 43 - unsigned long cfg; 44 - 45 - cfg = __prepare_ICR(0, vector, dest); 46 - 47 - /* 48 - * send the IPI. 49 - */ 50 - native_x2apic_icr_write(cfg, apicid); 51 21 } 52 22 53 23 static inline u32 x2apic_cluster(int cpu) ··· 96 128 __x2apic_send_IPI_mask(cpu_online_mask, vector, APIC_DEST_ALLINC); 97 129 } 98 130 99 - static int x2apic_apic_id_registered(void) 100 - { 101 - return 1; 102 - } 103 - 104 131 static unsigned int x2apic_cpu_mask_to_apicid(const struct cpumask *cpumask) 105 132 { 106 133 /* ··· 126 163 } 127 164 128 165 return per_cpu(x86_cpu_to_logical_apicid, cpu); 129 - } 130 - 131 - static unsigned int x2apic_cluster_phys_get_apic_id(unsigned long x) 132 - { 133 - unsigned int id; 134 - 135 - id = x; 136 - return id; 137 - } 138 - 139 - static unsigned long set_apic_id(unsigned int id) 140 - { 141 - unsigned long x; 142 - 143 - x = id; 144 - return x; 145 - } 146 - 147 - static int x2apic_cluster_phys_pkg_id(int initial_apicid, int index_msb) 148 - { 149 - return initial_apicid >> index_msb; 150 - } 151 - 152 - static void x2apic_send_IPI_self(int vector) 153 - { 154 - apic_write(APIC_SELF_IPI, vector); 155 166 } 156 167 157 168 static void init_x2apic_ldr(void) ··· 235 298 .setup_portio_remap = NULL, 236 299 .check_phys_apicid_present = default_check_phys_apicid_present, 237 300 .enable_apic_mode = NULL, 238 - .phys_pkg_id = x2apic_cluster_phys_pkg_id, 301 + .phys_pkg_id = x2apic_phys_pkg_id, 239 302 .mps_oem_check = NULL, 240 303 241 - .get_apic_id = x2apic_cluster_phys_get_apic_id, 242 - .set_apic_id = set_apic_id, 304 + .get_apic_id = x2apic_get_apic_id, 305 + .set_apic_id = x2apic_set_apic_id, 243 306 .apic_id_mask = 0xFFFFFFFFu, 244 307 245 308 .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid,
+3 -57
arch/x86/kernel/apic/x2apic_phys.c
··· 7 7 #include <linux/dmar.h> 8 8 9 9 #include <asm/smp.h> 10 - #include <asm/apic.h> 11 - #include <asm/ipi.h> 10 + #include <asm/x2apic.h> 12 11 13 12 int x2apic_phys; 14 13 ··· 24 25 return x2apic_enabled(); 25 26 else 26 27 return 0; 27 - } 28 - 29 - /* 30 - * need to use more than cpu 0, because we need more vectors when 31 - * MSI-X are used. 32 - */ 33 - static const struct cpumask *x2apic_target_cpus(void) 34 - { 35 - return cpu_online_mask; 36 - } 37 - 38 - static void x2apic_vector_allocation_domain(int cpu, struct cpumask *retmask) 39 - { 40 - cpumask_clear(retmask); 41 - cpumask_set_cpu(cpu, retmask); 42 - } 43 - 44 - static void __x2apic_send_IPI_dest(unsigned int apicid, int vector, 45 - unsigned int dest) 46 - { 47 - unsigned long cfg; 48 - 49 - cfg = __prepare_ICR(0, vector, dest); 50 - 51 - /* 52 - * send the IPI. 53 - */ 54 - native_x2apic_icr_write(cfg, apicid); 55 28 } 56 29 57 30 static void ··· 68 97 __x2apic_send_IPI_mask(cpu_online_mask, vector, APIC_DEST_ALLINC); 69 98 } 70 99 71 - static int x2apic_apic_id_registered(void) 72 - { 73 - return 1; 74 - } 75 - 76 100 static unsigned int x2apic_cpu_mask_to_apicid(const struct cpumask *cpumask) 77 101 { 78 102 /* ··· 98 132 } 99 133 100 134 return per_cpu(x86_cpu_to_apicid, cpu); 101 - } 102 - 103 - static unsigned int x2apic_phys_get_apic_id(unsigned long x) 104 - { 105 - return x; 106 - } 107 - 108 - static unsigned long set_apic_id(unsigned int id) 109 - { 110 - return id; 111 - } 112 - 113 - static int x2apic_phys_pkg_id(int initial_apicid, int index_msb) 114 - { 115 - return initial_apicid >> index_msb; 116 - } 117 - 118 - static void x2apic_send_IPI_self(int vector) 119 - { 120 - apic_write(APIC_SELF_IPI, vector); 121 135 } 122 136 123 137 static void init_x2apic_ldr(void) ··· 142 196 .phys_pkg_id = x2apic_phys_pkg_id, 143 197 .mps_oem_check = NULL, 144 198 145 - .get_apic_id = x2apic_phys_get_apic_id, 146 - .set_apic_id = set_apic_id, 199 + .get_apic_id = x2apic_get_apic_id, 200 + .set_apic_id = x2apic_set_apic_id, 147 201 .apic_id_mask = 0xFFFFFFFFu, 148 202 149 203 .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid,