aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel
diff options
context:
space:
mode:
authorSuresh Siddha <suresh.b.siddha@intel.com>2011-05-19 19:45:47 -0400
committerIngo Molnar <mingo@elte.hu>2011-05-20 07:41:06 -0400
commita27d0b5e7d913b38880678ac05690f1dc737c4fd (patch)
tree56957d475688c61171b505200b3144c213b77c6e /arch/x86/kernel
parent9ebd680bd029a9fc47399ca61c950f8b6730ac40 (diff)
x86, x2apic: Remove duplicate code for IPI mask routines
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com> Acked-by: Cyrill Gorcunov <gorcunov@openvz.org> Cc: steiner@sgi.com Cc: yinghai@kernel.org Link: http://lkml.kernel.org/r/20110519234637.337024125@sbsiddha-MOBL3.sc.intel.com Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel')
-rw-r--r--arch/x86/kernel/apic/x2apic_cluster.c48
-rw-r--r--arch/x86/kernel/apic/x2apic_phys.c45
2 files changed, 31 insertions, 62 deletions
diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
index 2967bab775e5..b2617993de19 100644
--- a/arch/x86/kernel/apic/x2apic_cluster.c
+++ b/arch/x86/kernel/apic/x2apic_cluster.c
@@ -54,64 +54,48 @@ static void
54 * at once. We have 16 cpu's in a cluster. This will minimize IPI register 54 * at once. We have 16 cpu's in a cluster. This will minimize IPI register
55 * writes. 55 * writes.
56 */ 56 */
57static void x2apic_send_IPI_mask(const struct cpumask *mask, int vector) 57static void
58__x2apic_send_IPI_mask(const struct cpumask *mask, int vector, int apic_dest)
58{ 59{
59 unsigned long query_cpu; 60 unsigned long query_cpu;
61 unsigned long this_cpu;
60 unsigned long flags; 62 unsigned long flags;
61 63
62 x2apic_wrmsr_fence(); 64 x2apic_wrmsr_fence();
63 65
64 local_irq_save(flags); 66 local_irq_save(flags);
67
68 this_cpu = smp_processor_id();
65 for_each_cpu(query_cpu, mask) { 69 for_each_cpu(query_cpu, mask) {
70 if (apic_dest == APIC_DEST_ALLBUT && query_cpu == this_cpu)
71 continue;
66 __x2apic_send_IPI_dest( 72 __x2apic_send_IPI_dest(
67 per_cpu(x86_cpu_to_logical_apicid, query_cpu), 73 per_cpu(x86_cpu_to_logical_apicid, query_cpu),
68 vector, apic->dest_logical); 74 vector, apic->dest_logical);
69 } 75 }
76
70 local_irq_restore(flags); 77 local_irq_restore(flags);
71} 78}
72 79
80static void x2apic_send_IPI_mask(const struct cpumask *mask, int vector)
81{
82 __x2apic_send_IPI_mask(mask, vector, APIC_DEST_ALLINC);
83}
84
73static void 85static void
74 x2apic_send_IPI_mask_allbutself(const struct cpumask *mask, int vector) 86 x2apic_send_IPI_mask_allbutself(const struct cpumask *mask, int vector)
75{ 87{
76 unsigned long this_cpu = smp_processor_id(); 88 __x2apic_send_IPI_mask(mask, vector, APIC_DEST_ALLBUT);
77 unsigned long query_cpu;
78 unsigned long flags;
79
80 x2apic_wrmsr_fence();
81
82 local_irq_save(flags);
83 for_each_cpu(query_cpu, mask) {
84 if (query_cpu == this_cpu)
85 continue;
86 __x2apic_send_IPI_dest(
87 per_cpu(x86_cpu_to_logical_apicid, query_cpu),
88 vector, apic->dest_logical);
89 }
90 local_irq_restore(flags);
91} 89}
92 90
93static void x2apic_send_IPI_allbutself(int vector) 91static void x2apic_send_IPI_allbutself(int vector)
94{ 92{
95 unsigned long this_cpu = smp_processor_id(); 93 __x2apic_send_IPI_mask(cpu_online_mask, vector, APIC_DEST_ALLBUT);
96 unsigned long query_cpu;
97 unsigned long flags;
98
99 x2apic_wrmsr_fence();
100
101 local_irq_save(flags);
102 for_each_online_cpu(query_cpu) {
103 if (query_cpu == this_cpu)
104 continue;
105 __x2apic_send_IPI_dest(
106 per_cpu(x86_cpu_to_logical_apicid, query_cpu),
107 vector, apic->dest_logical);
108 }
109 local_irq_restore(flags);
110} 94}
111 95
112static void x2apic_send_IPI_all(int vector) 96static void x2apic_send_IPI_all(int vector)
113{ 97{
114 x2apic_send_IPI_mask(cpu_online_mask, vector); 98 __x2apic_send_IPI_mask(cpu_online_mask, vector, APIC_DEST_ALLINC);
115} 99}
116 100
117static int x2apic_apic_id_registered(void) 101static int x2apic_apic_id_registered(void)
diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
index 8f21771249f6..6ef49e338a73 100644
--- a/arch/x86/kernel/apic/x2apic_phys.c
+++ b/arch/x86/kernel/apic/x2apic_phys.c
@@ -55,61 +55,46 @@ static void __x2apic_send_IPI_dest(unsigned int apicid, int vector,
55 native_x2apic_icr_write(cfg, apicid); 55 native_x2apic_icr_write(cfg, apicid);
56} 56}
57 57
58static void x2apic_send_IPI_mask(const struct cpumask *mask, int vector) 58static void
59__x2apic_send_IPI_mask(const struct cpumask *mask, int vector, int apic_dest)
59{ 60{
60 unsigned long query_cpu; 61 unsigned long query_cpu;
62 unsigned long this_cpu;
61 unsigned long flags; 63 unsigned long flags;
62 64
63 x2apic_wrmsr_fence(); 65 x2apic_wrmsr_fence();
64 66
65 local_irq_save(flags); 67 local_irq_save(flags);
68
69 this_cpu = smp_processor_id();
66 for_each_cpu(query_cpu, mask) { 70 for_each_cpu(query_cpu, mask) {
71 if (apic_dest == APIC_DEST_ALLBUT && this_cpu == query_cpu)
72 continue;
67 __x2apic_send_IPI_dest(per_cpu(x86_cpu_to_apicid, query_cpu), 73 __x2apic_send_IPI_dest(per_cpu(x86_cpu_to_apicid, query_cpu),
68 vector, APIC_DEST_PHYSICAL); 74 vector, APIC_DEST_PHYSICAL);
69 } 75 }
70 local_irq_restore(flags); 76 local_irq_restore(flags);
71} 77}
72 78
79static void x2apic_send_IPI_mask(const struct cpumask *mask, int vector)
80{
81 __x2apic_send_IPI_mask(mask, vector, APIC_DEST_ALLINC);
82}
83
73static void 84static void
74 x2apic_send_IPI_mask_allbutself(const struct cpumask *mask, int vector) 85 x2apic_send_IPI_mask_allbutself(const struct cpumask *mask, int vector)
75{ 86{
76 unsigned long this_cpu = smp_processor_id(); 87 __x2apic_send_IPI_mask(mask, vector, APIC_DEST_ALLBUT);
77 unsigned long query_cpu;
78 unsigned long flags;
79
80 x2apic_wrmsr_fence();
81
82 local_irq_save(flags);
83 for_each_cpu(query_cpu, mask) {
84 if (query_cpu != this_cpu)
85 __x2apic_send_IPI_dest(
86 per_cpu(x86_cpu_to_apicid, query_cpu),
87 vector, APIC_DEST_PHYSICAL);
88 }
89 local_irq_restore(flags);
90} 88}
91 89
92static void x2apic_send_IPI_allbutself(int vector) 90static void x2apic_send_IPI_allbutself(int vector)
93{ 91{
94 unsigned long this_cpu = smp_processor_id(); 92 __x2apic_send_IPI_mask(cpu_online_mask, vector, APIC_DEST_ALLBUT);
95 unsigned long query_cpu;
96 unsigned long flags;
97
98 x2apic_wrmsr_fence();
99
100 local_irq_save(flags);
101 for_each_online_cpu(query_cpu) {
102 if (query_cpu == this_cpu)
103 continue;
104 __x2apic_send_IPI_dest(per_cpu(x86_cpu_to_apicid, query_cpu),
105 vector, APIC_DEST_PHYSICAL);
106 }
107 local_irq_restore(flags);
108} 93}
109 94
110static void x2apic_send_IPI_all(int vector) 95static void x2apic_send_IPI_all(int vector)
111{ 96{
112 x2apic_send_IPI_mask(cpu_online_mask, vector); 97 __x2apic_send_IPI_mask(cpu_online_mask, vector, APIC_DEST_ALLINC);
113} 98}
114 99
115static int x2apic_apic_id_registered(void) 100static int x2apic_apic_id_registered(void)