aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-01-28 09:20:18 -0500
committerIngo Molnar <mingo@elte.hu>2009-01-28 17:20:30 -0500
commitdebccb3e77be52cfc26c5a99e123c114c5c72aeb (patch)
tree27c015b45085b2042737d94a3fbd3c62fe143c37 /arch/x86/kernel
parent94af18755266edf46803564414d74f9621aaded8 (diff)
x86, apic: refactor ->cpu_mask_to_apicid*()
- spread out the namespace on a per driver basis - clean up the functions - get rid of macros Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel')
-rw-r--r--arch/x86/kernel/genapic_flat_64.c4
-rw-r--r--arch/x86/kernel/genx2apic_cluster.c15
-rw-r--r--arch/x86/kernel/genx2apic_phys.c15
-rw-r--r--arch/x86/kernel/genx2apic_uv_x.c14
-rw-r--r--arch/x86/kernel/io_apic.c21
5 files changed, 41 insertions, 28 deletions
diff --git a/arch/x86/kernel/genapic_flat_64.c b/arch/x86/kernel/genapic_flat_64.c
index 78baa55cd0e9..b941b112cafb 100644
--- a/arch/x86/kernel/genapic_flat_64.c
+++ b/arch/x86/kernel/genapic_flat_64.c
@@ -309,11 +309,13 @@ physflat_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
309 * We're using fixed IRQ delivery, can only return one phys APIC ID. 309 * We're using fixed IRQ delivery, can only return one phys APIC ID.
310 * May as well be the first. 310 * May as well be the first.
311 */ 311 */
312 for_each_cpu_and(cpu, cpumask, andmask) 312 for_each_cpu_and(cpu, cpumask, andmask) {
313 if (cpumask_test_cpu(cpu, cpu_online_mask)) 313 if (cpumask_test_cpu(cpu, cpu_online_mask))
314 break; 314 break;
315 }
315 if (cpu < nr_cpu_ids) 316 if (cpu < nr_cpu_ids)
316 return per_cpu(x86_cpu_to_apicid, cpu); 317 return per_cpu(x86_cpu_to_apicid, cpu);
318
317 return BAD_APICID; 319 return BAD_APICID;
318} 320}
319 321
diff --git a/arch/x86/kernel/genx2apic_cluster.c b/arch/x86/kernel/genx2apic_cluster.c
index c7557e051848..62f9fccf01dd 100644
--- a/arch/x86/kernel/genx2apic_cluster.c
+++ b/arch/x86/kernel/genx2apic_cluster.c
@@ -111,21 +111,21 @@ static int x2apic_apic_id_registered(void)
111 111
112static unsigned int x2apic_cpu_mask_to_apicid(const struct cpumask *cpumask) 112static unsigned int x2apic_cpu_mask_to_apicid(const struct cpumask *cpumask)
113{ 113{
114 int cpu;
115
116 /* 114 /*
117 * We're using fixed IRQ delivery, can only return one logical APIC ID. 115 * We're using fixed IRQ delivery, can only return one logical APIC ID.
118 * May as well be the first. 116 * May as well be the first.
119 */ 117 */
120 cpu = cpumask_first(cpumask); 118 int cpu = cpumask_first(cpumask);
119
121 if ((unsigned)cpu < nr_cpu_ids) 120 if ((unsigned)cpu < nr_cpu_ids)
122 return per_cpu(x86_cpu_to_logical_apicid, cpu); 121 return per_cpu(x86_cpu_to_logical_apicid, cpu);
123 else 122 else
124 return BAD_APICID; 123 return BAD_APICID;
125} 124}
126 125
127static unsigned int x2apic_cpu_mask_to_apicid_and(const struct cpumask *cpumask, 126static unsigned int
128 const struct cpumask *andmask) 127x2apic_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
128 const struct cpumask *andmask)
129{ 129{
130 int cpu; 130 int cpu;
131 131
@@ -133,11 +133,14 @@ static unsigned int x2apic_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
133 * We're using fixed IRQ delivery, can only return one logical APIC ID. 133 * We're using fixed IRQ delivery, can only return one logical APIC ID.
134 * May as well be the first. 134 * May as well be the first.
135 */ 135 */
136 for_each_cpu_and(cpu, cpumask, andmask) 136 for_each_cpu_and(cpu, cpumask, andmask) {
137 if (cpumask_test_cpu(cpu, cpu_online_mask)) 137 if (cpumask_test_cpu(cpu, cpu_online_mask))
138 break; 138 break;
139 }
140
139 if (cpu < nr_cpu_ids) 141 if (cpu < nr_cpu_ids)
140 return per_cpu(x86_cpu_to_logical_apicid, cpu); 142 return per_cpu(x86_cpu_to_logical_apicid, cpu);
143
141 return BAD_APICID; 144 return BAD_APICID;
142} 145}
143 146
diff --git a/arch/x86/kernel/genx2apic_phys.c b/arch/x86/kernel/genx2apic_phys.c
index 80cba49cfd89..3da1675b2604 100644
--- a/arch/x86/kernel/genx2apic_phys.c
+++ b/arch/x86/kernel/genx2apic_phys.c
@@ -110,21 +110,21 @@ static int x2apic_apic_id_registered(void)
110 110
111static unsigned int x2apic_cpu_mask_to_apicid(const struct cpumask *cpumask) 111static unsigned int x2apic_cpu_mask_to_apicid(const struct cpumask *cpumask)
112{ 112{
113 int cpu;
114
115 /* 113 /*
116 * We're using fixed IRQ delivery, can only return one phys APIC ID. 114 * We're using fixed IRQ delivery, can only return one phys APIC ID.
117 * May as well be the first. 115 * May as well be the first.
118 */ 116 */
119 cpu = cpumask_first(cpumask); 117 int cpu = cpumask_first(cpumask);
118
120 if ((unsigned)cpu < nr_cpu_ids) 119 if ((unsigned)cpu < nr_cpu_ids)
121 return per_cpu(x86_cpu_to_apicid, cpu); 120 return per_cpu(x86_cpu_to_apicid, cpu);
122 else 121 else
123 return BAD_APICID; 122 return BAD_APICID;
124} 123}
125 124
126static unsigned int x2apic_cpu_mask_to_apicid_and(const struct cpumask *cpumask, 125static unsigned int
127 const struct cpumask *andmask) 126x2apic_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
127 const struct cpumask *andmask)
128{ 128{
129 int cpu; 129 int cpu;
130 130
@@ -132,11 +132,14 @@ static unsigned int x2apic_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
132 * We're using fixed IRQ delivery, can only return one phys APIC ID. 132 * We're using fixed IRQ delivery, can only return one phys APIC ID.
133 * May as well be the first. 133 * May as well be the first.
134 */ 134 */
135 for_each_cpu_and(cpu, cpumask, andmask) 135 for_each_cpu_and(cpu, cpumask, andmask) {
136 if (cpumask_test_cpu(cpu, cpu_online_mask)) 136 if (cpumask_test_cpu(cpu, cpu_online_mask))
137 break; 137 break;
138 }
139
138 if (cpu < nr_cpu_ids) 140 if (cpu < nr_cpu_ids)
139 return per_cpu(x86_cpu_to_apicid, cpu); 141 return per_cpu(x86_cpu_to_apicid, cpu);
142
140 return BAD_APICID; 143 return BAD_APICID;
141} 144}
142 145
diff --git a/arch/x86/kernel/genx2apic_uv_x.c b/arch/x86/kernel/genx2apic_uv_x.c
index 50310b96adc3..f957878c21e9 100644
--- a/arch/x86/kernel/genx2apic_uv_x.c
+++ b/arch/x86/kernel/genx2apic_uv_x.c
@@ -171,21 +171,21 @@ static void uv_init_apic_ldr(void)
171 171
172static unsigned int uv_cpu_mask_to_apicid(const struct cpumask *cpumask) 172static unsigned int uv_cpu_mask_to_apicid(const struct cpumask *cpumask)
173{ 173{
174 int cpu;
175
176 /* 174 /*
177 * We're using fixed IRQ delivery, can only return one phys APIC ID. 175 * We're using fixed IRQ delivery, can only return one phys APIC ID.
178 * May as well be the first. 176 * May as well be the first.
179 */ 177 */
180 cpu = cpumask_first(cpumask); 178 int cpu = cpumask_first(cpumask);
179
181 if ((unsigned)cpu < nr_cpu_ids) 180 if ((unsigned)cpu < nr_cpu_ids)
182 return per_cpu(x86_cpu_to_apicid, cpu); 181 return per_cpu(x86_cpu_to_apicid, cpu);
183 else 182 else
184 return BAD_APICID; 183 return BAD_APICID;
185} 184}
186 185
187static unsigned int uv_cpu_mask_to_apicid_and(const struct cpumask *cpumask, 186static unsigned int
188 const struct cpumask *andmask) 187uv_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
188 const struct cpumask *andmask)
189{ 189{
190 int cpu; 190 int cpu;
191 191
@@ -193,11 +193,13 @@ static unsigned int uv_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
193 * We're using fixed IRQ delivery, can only return one phys APIC ID. 193 * We're using fixed IRQ delivery, can only return one phys APIC ID.
194 * May as well be the first. 194 * May as well be the first.
195 */ 195 */
196 for_each_cpu_and(cpu, cpumask, andmask) 196 for_each_cpu_and(cpu, cpumask, andmask) {
197 if (cpumask_test_cpu(cpu, cpu_online_mask)) 197 if (cpumask_test_cpu(cpu, cpu_online_mask))
198 break; 198 break;
199 }
199 if (cpu < nr_cpu_ids) 200 if (cpu < nr_cpu_ids)
200 return per_cpu(x86_cpu_to_apicid, cpu); 201 return per_cpu(x86_cpu_to_apicid, cpu);
202
201 return BAD_APICID; 203 return BAD_APICID;
202} 204}
203 205
diff --git a/arch/x86/kernel/io_apic.c b/arch/x86/kernel/io_apic.c
index 3d85d3d810b2..01a2505d7275 100644
--- a/arch/x86/kernel/io_apic.c
+++ b/arch/x86/kernel/io_apic.c
@@ -563,8 +563,9 @@ static int
563assign_irq_vector(int irq, struct irq_cfg *cfg, const struct cpumask *mask); 563assign_irq_vector(int irq, struct irq_cfg *cfg, const struct cpumask *mask);
564 564
565/* 565/*
566 * Either sets desc->affinity to a valid value, and returns cpu_mask_to_apicid 566 * Either sets desc->affinity to a valid value, and returns
567 * of that, or returns BAD_APICID and leaves desc->affinity untouched. 567 * ->cpu_mask_to_apicid of that, or returns BAD_APICID and
568 * leaves desc->affinity untouched.
568 */ 569 */
569static unsigned int 570static unsigned int
570set_desc_affinity(struct irq_desc *desc, const struct cpumask *mask) 571set_desc_affinity(struct irq_desc *desc, const struct cpumask *mask)
@@ -582,7 +583,8 @@ set_desc_affinity(struct irq_desc *desc, const struct cpumask *mask)
582 583
583 cpumask_and(desc->affinity, cfg->domain, mask); 584 cpumask_and(desc->affinity, cfg->domain, mask);
584 set_extra_move_desc(desc, mask); 585 set_extra_move_desc(desc, mask);
585 return cpu_mask_to_apicid_and(desc->affinity, cpu_online_mask); 586
587 return apic->cpu_mask_to_apicid_and(desc->affinity, cpu_online_mask);
586} 588}
587 589
588static void 590static void
@@ -1562,7 +1564,7 @@ static void setup_IO_APIC_irq(int apic_id, int pin, unsigned int irq, struct irq
1562 if (assign_irq_vector(irq, cfg, apic->target_cpus())) 1564 if (assign_irq_vector(irq, cfg, apic->target_cpus()))
1563 return; 1565 return;
1564 1566
1565 dest = cpu_mask_to_apicid_and(cfg->domain, apic->target_cpus()); 1567 dest = apic->cpu_mask_to_apicid_and(cfg->domain, apic->target_cpus());
1566 1568
1567 apic_printk(APIC_VERBOSE,KERN_DEBUG 1569 apic_printk(APIC_VERBOSE,KERN_DEBUG
1568 "IOAPIC[%d]: Set routing entry (%d-%d -> 0x%x -> " 1570 "IOAPIC[%d]: Set routing entry (%d-%d -> 0x%x -> "
@@ -1666,7 +1668,7 @@ static void __init setup_timer_IRQ0_pin(unsigned int apic_id, unsigned int pin,
1666 */ 1668 */
1667 entry.dest_mode = apic->irq_dest_mode; 1669 entry.dest_mode = apic->irq_dest_mode;
1668 entry.mask = 1; /* mask IRQ now */ 1670 entry.mask = 1; /* mask IRQ now */
1669 entry.dest = cpu_mask_to_apicid(apic->target_cpus()); 1671 entry.dest = apic->cpu_mask_to_apicid(apic->target_cpus());
1670 entry.delivery_mode = apic->irq_delivery_mode; 1672 entry.delivery_mode = apic->irq_delivery_mode;
1671 entry.polarity = 0; 1673 entry.polarity = 0;
1672 entry.trigger = 0; 1674 entry.trigger = 0;
@@ -2367,7 +2369,7 @@ migrate_ioapic_irq_desc(struct irq_desc *desc, const struct cpumask *mask)
2367 2369
2368 set_extra_move_desc(desc, mask); 2370 set_extra_move_desc(desc, mask);
2369 2371
2370 dest = cpu_mask_to_apicid_and(cfg->domain, mask); 2372 dest = apic->cpu_mask_to_apicid_and(cfg->domain, mask);
2371 2373
2372 modify_ioapic_rte = desc->status & IRQ_LEVEL; 2374 modify_ioapic_rte = desc->status & IRQ_LEVEL;
2373 if (modify_ioapic_rte) { 2375 if (modify_ioapic_rte) {
@@ -3270,7 +3272,7 @@ static int msi_compose_msg(struct pci_dev *pdev, unsigned int irq, struct msi_ms
3270 if (err) 3272 if (err)
3271 return err; 3273 return err;
3272 3274
3273 dest = cpu_mask_to_apicid_and(cfg->domain, apic->target_cpus()); 3275 dest = apic->cpu_mask_to_apicid_and(cfg->domain, apic->target_cpus());
3274 3276
3275#ifdef CONFIG_INTR_REMAP 3277#ifdef CONFIG_INTR_REMAP
3276 if (irq_remapped(irq)) { 3278 if (irq_remapped(irq)) {
@@ -3708,7 +3710,8 @@ int arch_setup_ht_irq(unsigned int irq, struct pci_dev *dev)
3708 struct ht_irq_msg msg; 3710 struct ht_irq_msg msg;
3709 unsigned dest; 3711 unsigned dest;
3710 3712
3711 dest = cpu_mask_to_apicid_and(cfg->domain, apic->target_cpus()); 3713 dest = apic->cpu_mask_to_apicid_and(cfg->domain,
3714 apic->target_cpus());
3712 3715
3713 msg.address_hi = HT_IRQ_HIGH_DEST_ID(dest); 3716 msg.address_hi = HT_IRQ_HIGH_DEST_ID(dest);
3714 3717
@@ -3773,7 +3776,7 @@ int arch_enable_uv_irq(char *irq_name, unsigned int irq, int cpu, int mmr_blade,
3773 entry->polarity = 0; 3776 entry->polarity = 0;
3774 entry->trigger = 0; 3777 entry->trigger = 0;
3775 entry->mask = 0; 3778 entry->mask = 0;
3776 entry->dest = cpu_mask_to_apicid(eligible_cpu); 3779 entry->dest = apic->cpu_mask_to_apicid(eligible_cpu);
3777 3780
3778 mmr_pnode = uv_blade_to_pnode(mmr_blade); 3781 mmr_pnode = uv_blade_to_pnode(mmr_blade);
3779 uv_write_global_mmr64(mmr_pnode, mmr_offset, mmr_value); 3782 uv_write_global_mmr64(mmr_pnode, mmr_offset, mmr_value);