diff options
Diffstat (limited to 'arch/x86/kernel/apic/io_apic.c')
-rw-r--r-- | arch/x86/kernel/apic/io_apic.c | 258 |
1 files changed, 146 insertions, 112 deletions
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c index 6bdd2c7ead75..14862f11cc4a 100644 --- a/arch/x86/kernel/apic/io_apic.c +++ b/arch/x86/kernel/apic/io_apic.c | |||
@@ -73,8 +73,8 @@ | |||
73 | */ | 73 | */ |
74 | int sis_apic_bug = -1; | 74 | int sis_apic_bug = -1; |
75 | 75 | ||
76 | static DEFINE_SPINLOCK(ioapic_lock); | 76 | static DEFINE_RAW_SPINLOCK(ioapic_lock); |
77 | static DEFINE_SPINLOCK(vector_lock); | 77 | static DEFINE_RAW_SPINLOCK(vector_lock); |
78 | 78 | ||
79 | /* | 79 | /* |
80 | * # of IRQ routing registers | 80 | * # of IRQ routing registers |
@@ -94,8 +94,6 @@ struct mpc_intsrc mp_irqs[MAX_IRQ_SOURCES]; | |||
94 | /* # of MP IRQ source entries */ | 94 | /* # of MP IRQ source entries */ |
95 | int mp_irq_entries; | 95 | int mp_irq_entries; |
96 | 96 | ||
97 | /* Number of legacy interrupts */ | ||
98 | static int nr_legacy_irqs __read_mostly = NR_IRQS_LEGACY; | ||
99 | /* GSI interrupts */ | 97 | /* GSI interrupts */ |
100 | static int nr_irqs_gsi = NR_IRQS_LEGACY; | 98 | static int nr_irqs_gsi = NR_IRQS_LEGACY; |
101 | 99 | ||
@@ -140,27 +138,10 @@ static struct irq_pin_list *get_one_free_irq_2_pin(int node) | |||
140 | 138 | ||
141 | /* irq_cfg is indexed by the sum of all RTEs in all I/O APICs. */ | 139 | /* irq_cfg is indexed by the sum of all RTEs in all I/O APICs. */ |
142 | #ifdef CONFIG_SPARSE_IRQ | 140 | #ifdef CONFIG_SPARSE_IRQ |
143 | static struct irq_cfg irq_cfgx[] = { | 141 | static struct irq_cfg irq_cfgx[NR_IRQS_LEGACY]; |
144 | #else | 142 | #else |
145 | static struct irq_cfg irq_cfgx[NR_IRQS] = { | 143 | static struct irq_cfg irq_cfgx[NR_IRQS]; |
146 | #endif | 144 | #endif |
147 | [0] = { .vector = IRQ0_VECTOR, }, | ||
148 | [1] = { .vector = IRQ1_VECTOR, }, | ||
149 | [2] = { .vector = IRQ2_VECTOR, }, | ||
150 | [3] = { .vector = IRQ3_VECTOR, }, | ||
151 | [4] = { .vector = IRQ4_VECTOR, }, | ||
152 | [5] = { .vector = IRQ5_VECTOR, }, | ||
153 | [6] = { .vector = IRQ6_VECTOR, }, | ||
154 | [7] = { .vector = IRQ7_VECTOR, }, | ||
155 | [8] = { .vector = IRQ8_VECTOR, }, | ||
156 | [9] = { .vector = IRQ9_VECTOR, }, | ||
157 | [10] = { .vector = IRQ10_VECTOR, }, | ||
158 | [11] = { .vector = IRQ11_VECTOR, }, | ||
159 | [12] = { .vector = IRQ12_VECTOR, }, | ||
160 | [13] = { .vector = IRQ13_VECTOR, }, | ||
161 | [14] = { .vector = IRQ14_VECTOR, }, | ||
162 | [15] = { .vector = IRQ15_VECTOR, }, | ||
163 | }; | ||
164 | 145 | ||
165 | void __init io_apic_disable_legacy(void) | 146 | void __init io_apic_disable_legacy(void) |
166 | { | 147 | { |
@@ -185,8 +166,14 @@ int __init arch_early_irq_init(void) | |||
185 | desc->chip_data = &cfg[i]; | 166 | desc->chip_data = &cfg[i]; |
186 | zalloc_cpumask_var_node(&cfg[i].domain, GFP_NOWAIT, node); | 167 | zalloc_cpumask_var_node(&cfg[i].domain, GFP_NOWAIT, node); |
187 | zalloc_cpumask_var_node(&cfg[i].old_domain, GFP_NOWAIT, node); | 168 | zalloc_cpumask_var_node(&cfg[i].old_domain, GFP_NOWAIT, node); |
188 | if (i < nr_legacy_irqs) | 169 | /* |
189 | cpumask_setall(cfg[i].domain); | 170 | * For legacy IRQ's, start with assigning irq0 to irq15 to |
171 | * IRQ0_VECTOR to IRQ15_VECTOR on cpu 0. | ||
172 | */ | ||
173 | if (i < nr_legacy_irqs) { | ||
174 | cfg[i].vector = IRQ0_VECTOR + i; | ||
175 | cpumask_set_cpu(0, cfg[i].domain); | ||
176 | } | ||
190 | } | 177 | } |
191 | 178 | ||
192 | return 0; | 179 | return 0; |
@@ -406,7 +393,7 @@ static bool io_apic_level_ack_pending(struct irq_cfg *cfg) | |||
406 | struct irq_pin_list *entry; | 393 | struct irq_pin_list *entry; |
407 | unsigned long flags; | 394 | unsigned long flags; |
408 | 395 | ||
409 | spin_lock_irqsave(&ioapic_lock, flags); | 396 | raw_spin_lock_irqsave(&ioapic_lock, flags); |
410 | for_each_irq_pin(entry, cfg->irq_2_pin) { | 397 | for_each_irq_pin(entry, cfg->irq_2_pin) { |
411 | unsigned int reg; | 398 | unsigned int reg; |
412 | int pin; | 399 | int pin; |
@@ -415,11 +402,11 @@ static bool io_apic_level_ack_pending(struct irq_cfg *cfg) | |||
415 | reg = io_apic_read(entry->apic, 0x10 + pin*2); | 402 | reg = io_apic_read(entry->apic, 0x10 + pin*2); |
416 | /* Is the remote IRR bit set? */ | 403 | /* Is the remote IRR bit set? */ |
417 | if (reg & IO_APIC_REDIR_REMOTE_IRR) { | 404 | if (reg & IO_APIC_REDIR_REMOTE_IRR) { |
418 | spin_unlock_irqrestore(&ioapic_lock, flags); | 405 | raw_spin_unlock_irqrestore(&ioapic_lock, flags); |
419 | return true; | 406 | return true; |
420 | } | 407 | } |
421 | } | 408 | } |
422 | spin_unlock_irqrestore(&ioapic_lock, flags); | 409 | raw_spin_unlock_irqrestore(&ioapic_lock, flags); |
423 | 410 | ||
424 | return false; | 411 | return false; |
425 | } | 412 | } |
@@ -433,10 +420,10 @@ static struct IO_APIC_route_entry ioapic_read_entry(int apic, int pin) | |||
433 | { | 420 | { |
434 | union entry_union eu; | 421 | union entry_union eu; |
435 | unsigned long flags; | 422 | unsigned long flags; |
436 | spin_lock_irqsave(&ioapic_lock, flags); | 423 | raw_spin_lock_irqsave(&ioapic_lock, flags); |
437 | eu.w1 = io_apic_read(apic, 0x10 + 2 * pin); | 424 | eu.w1 = io_apic_read(apic, 0x10 + 2 * pin); |
438 | eu.w2 = io_apic_read(apic, 0x11 + 2 * pin); | 425 | eu.w2 = io_apic_read(apic, 0x11 + 2 * pin); |
439 | spin_unlock_irqrestore(&ioapic_lock, flags); | 426 | raw_spin_unlock_irqrestore(&ioapic_lock, flags); |
440 | return eu.entry; | 427 | return eu.entry; |
441 | } | 428 | } |
442 | 429 | ||
@@ -459,9 +446,9 @@ __ioapic_write_entry(int apic, int pin, struct IO_APIC_route_entry e) | |||
459 | void ioapic_write_entry(int apic, int pin, struct IO_APIC_route_entry e) | 446 | void ioapic_write_entry(int apic, int pin, struct IO_APIC_route_entry e) |
460 | { | 447 | { |
461 | unsigned long flags; | 448 | unsigned long flags; |
462 | spin_lock_irqsave(&ioapic_lock, flags); | 449 | raw_spin_lock_irqsave(&ioapic_lock, flags); |
463 | __ioapic_write_entry(apic, pin, e); | 450 | __ioapic_write_entry(apic, pin, e); |
464 | spin_unlock_irqrestore(&ioapic_lock, flags); | 451 | raw_spin_unlock_irqrestore(&ioapic_lock, flags); |
465 | } | 452 | } |
466 | 453 | ||
467 | /* | 454 | /* |
@@ -474,10 +461,10 @@ static void ioapic_mask_entry(int apic, int pin) | |||
474 | unsigned long flags; | 461 | unsigned long flags; |
475 | union entry_union eu = { .entry.mask = 1 }; | 462 | union entry_union eu = { .entry.mask = 1 }; |
476 | 463 | ||
477 | spin_lock_irqsave(&ioapic_lock, flags); | 464 | raw_spin_lock_irqsave(&ioapic_lock, flags); |
478 | io_apic_write(apic, 0x10 + 2*pin, eu.w1); | 465 | io_apic_write(apic, 0x10 + 2*pin, eu.w1); |
479 | io_apic_write(apic, 0x11 + 2*pin, eu.w2); | 466 | io_apic_write(apic, 0x11 + 2*pin, eu.w2); |
480 | spin_unlock_irqrestore(&ioapic_lock, flags); | 467 | raw_spin_unlock_irqrestore(&ioapic_lock, flags); |
481 | } | 468 | } |
482 | 469 | ||
483 | /* | 470 | /* |
@@ -604,9 +591,9 @@ static void mask_IO_APIC_irq_desc(struct irq_desc *desc) | |||
604 | 591 | ||
605 | BUG_ON(!cfg); | 592 | BUG_ON(!cfg); |
606 | 593 | ||
607 | spin_lock_irqsave(&ioapic_lock, flags); | 594 | raw_spin_lock_irqsave(&ioapic_lock, flags); |
608 | __mask_IO_APIC_irq(cfg); | 595 | __mask_IO_APIC_irq(cfg); |
609 | spin_unlock_irqrestore(&ioapic_lock, flags); | 596 | raw_spin_unlock_irqrestore(&ioapic_lock, flags); |
610 | } | 597 | } |
611 | 598 | ||
612 | static void unmask_IO_APIC_irq_desc(struct irq_desc *desc) | 599 | static void unmask_IO_APIC_irq_desc(struct irq_desc *desc) |
@@ -614,9 +601,9 @@ static void unmask_IO_APIC_irq_desc(struct irq_desc *desc) | |||
614 | struct irq_cfg *cfg = desc->chip_data; | 601 | struct irq_cfg *cfg = desc->chip_data; |
615 | unsigned long flags; | 602 | unsigned long flags; |
616 | 603 | ||
617 | spin_lock_irqsave(&ioapic_lock, flags); | 604 | raw_spin_lock_irqsave(&ioapic_lock, flags); |
618 | __unmask_IO_APIC_irq(cfg); | 605 | __unmask_IO_APIC_irq(cfg); |
619 | spin_unlock_irqrestore(&ioapic_lock, flags); | 606 | raw_spin_unlock_irqrestore(&ioapic_lock, flags); |
620 | } | 607 | } |
621 | 608 | ||
622 | static void mask_IO_APIC_irq(unsigned int irq) | 609 | static void mask_IO_APIC_irq(unsigned int irq) |
@@ -1140,12 +1127,12 @@ void lock_vector_lock(void) | |||
1140 | /* Used to the online set of cpus does not change | 1127 | /* Used to the online set of cpus does not change |
1141 | * during assign_irq_vector. | 1128 | * during assign_irq_vector. |
1142 | */ | 1129 | */ |
1143 | spin_lock(&vector_lock); | 1130 | raw_spin_lock(&vector_lock); |
1144 | } | 1131 | } |
1145 | 1132 | ||
1146 | void unlock_vector_lock(void) | 1133 | void unlock_vector_lock(void) |
1147 | { | 1134 | { |
1148 | spin_unlock(&vector_lock); | 1135 | raw_spin_unlock(&vector_lock); |
1149 | } | 1136 | } |
1150 | 1137 | ||
1151 | static int | 1138 | static int |
@@ -1162,7 +1149,8 @@ __assign_irq_vector(int irq, struct irq_cfg *cfg, const struct cpumask *mask) | |||
1162 | * Also, we've got to be careful not to trash gate | 1149 | * Also, we've got to be careful not to trash gate |
1163 | * 0x80, because int 0x80 is hm, kind of importantish. ;) | 1150 | * 0x80, because int 0x80 is hm, kind of importantish. ;) |
1164 | */ | 1151 | */ |
1165 | static int current_vector = FIRST_DEVICE_VECTOR, current_offset = 0; | 1152 | static int current_vector = FIRST_EXTERNAL_VECTOR + VECTOR_OFFSET_START; |
1153 | static int current_offset = VECTOR_OFFSET_START % 8; | ||
1166 | unsigned int old_vector; | 1154 | unsigned int old_vector; |
1167 | int cpu, err; | 1155 | int cpu, err; |
1168 | cpumask_var_t tmp_mask; | 1156 | cpumask_var_t tmp_mask; |
@@ -1198,7 +1186,7 @@ next: | |||
1198 | if (vector >= first_system_vector) { | 1186 | if (vector >= first_system_vector) { |
1199 | /* If out of vectors on large boxen, must share them. */ | 1187 | /* If out of vectors on large boxen, must share them. */ |
1200 | offset = (offset + 1) % 8; | 1188 | offset = (offset + 1) % 8; |
1201 | vector = FIRST_DEVICE_VECTOR + offset; | 1189 | vector = FIRST_EXTERNAL_VECTOR + offset; |
1202 | } | 1190 | } |
1203 | if (unlikely(current_vector == vector)) | 1191 | if (unlikely(current_vector == vector)) |
1204 | continue; | 1192 | continue; |
@@ -1232,9 +1220,9 @@ int assign_irq_vector(int irq, struct irq_cfg *cfg, const struct cpumask *mask) | |||
1232 | int err; | 1220 | int err; |
1233 | unsigned long flags; | 1221 | unsigned long flags; |
1234 | 1222 | ||
1235 | spin_lock_irqsave(&vector_lock, flags); | 1223 | raw_spin_lock_irqsave(&vector_lock, flags); |
1236 | err = __assign_irq_vector(irq, cfg, mask); | 1224 | err = __assign_irq_vector(irq, cfg, mask); |
1237 | spin_unlock_irqrestore(&vector_lock, flags); | 1225 | raw_spin_unlock_irqrestore(&vector_lock, flags); |
1238 | return err; | 1226 | return err; |
1239 | } | 1227 | } |
1240 | 1228 | ||
@@ -1268,11 +1256,16 @@ static void __clear_irq_vector(int irq, struct irq_cfg *cfg) | |||
1268 | void __setup_vector_irq(int cpu) | 1256 | void __setup_vector_irq(int cpu) |
1269 | { | 1257 | { |
1270 | /* Initialize vector_irq on a new cpu */ | 1258 | /* Initialize vector_irq on a new cpu */ |
1271 | /* This function must be called with vector_lock held */ | ||
1272 | int irq, vector; | 1259 | int irq, vector; |
1273 | struct irq_cfg *cfg; | 1260 | struct irq_cfg *cfg; |
1274 | struct irq_desc *desc; | 1261 | struct irq_desc *desc; |
1275 | 1262 | ||
1263 | /* | ||
1264 | * vector_lock will make sure that we don't run into irq vector | ||
1265 | * assignments that might be happening on another cpu in parallel, | ||
1266 | * while we setup our initial vector to irq mappings. | ||
1267 | */ | ||
1268 | raw_spin_lock(&vector_lock); | ||
1276 | /* Mark the inuse vectors */ | 1269 | /* Mark the inuse vectors */ |
1277 | for_each_irq_desc(irq, desc) { | 1270 | for_each_irq_desc(irq, desc) { |
1278 | cfg = desc->chip_data; | 1271 | cfg = desc->chip_data; |
@@ -1291,6 +1284,7 @@ void __setup_vector_irq(int cpu) | |||
1291 | if (!cpumask_test_cpu(cpu, cfg->domain)) | 1284 | if (!cpumask_test_cpu(cpu, cfg->domain)) |
1292 | per_cpu(vector_irq, cpu)[vector] = -1; | 1285 | per_cpu(vector_irq, cpu)[vector] = -1; |
1293 | } | 1286 | } |
1287 | raw_spin_unlock(&vector_lock); | ||
1294 | } | 1288 | } |
1295 | 1289 | ||
1296 | static struct irq_chip ioapic_chip; | 1290 | static struct irq_chip ioapic_chip; |
@@ -1440,6 +1434,14 @@ static void setup_IO_APIC_irq(int apic_id, int pin, unsigned int irq, struct irq | |||
1440 | 1434 | ||
1441 | cfg = desc->chip_data; | 1435 | cfg = desc->chip_data; |
1442 | 1436 | ||
1437 | /* | ||
1438 | * For legacy irqs, cfg->domain starts with cpu 0 for legacy | ||
1439 | * controllers like 8259. Now that IO-APIC can handle this irq, update | ||
1440 | * the cfg->domain. | ||
1441 | */ | ||
1442 | if (irq < nr_legacy_irqs && cpumask_test_cpu(0, cfg->domain)) | ||
1443 | apic->vector_allocation_domain(0, cfg->domain); | ||
1444 | |||
1443 | if (assign_irq_vector(irq, cfg, apic->target_cpus())) | 1445 | if (assign_irq_vector(irq, cfg, apic->target_cpus())) |
1444 | return; | 1446 | return; |
1445 | 1447 | ||
@@ -1473,7 +1475,7 @@ static struct { | |||
1473 | 1475 | ||
1474 | static void __init setup_IO_APIC_irqs(void) | 1476 | static void __init setup_IO_APIC_irqs(void) |
1475 | { | 1477 | { |
1476 | int apic_id = 0, pin, idx, irq; | 1478 | int apic_id, pin, idx, irq; |
1477 | int notcon = 0; | 1479 | int notcon = 0; |
1478 | struct irq_desc *desc; | 1480 | struct irq_desc *desc; |
1479 | struct irq_cfg *cfg; | 1481 | struct irq_cfg *cfg; |
@@ -1481,14 +1483,7 @@ static void __init setup_IO_APIC_irqs(void) | |||
1481 | 1483 | ||
1482 | apic_printk(APIC_VERBOSE, KERN_DEBUG "init IO_APIC IRQs\n"); | 1484 | apic_printk(APIC_VERBOSE, KERN_DEBUG "init IO_APIC IRQs\n"); |
1483 | 1485 | ||
1484 | #ifdef CONFIG_ACPI | 1486 | for (apic_id = 0; apic_id < nr_ioapics; apic_id++) |
1485 | if (!acpi_disabled && acpi_ioapic) { | ||
1486 | apic_id = mp_find_ioapic(0); | ||
1487 | if (apic_id < 0) | ||
1488 | apic_id = 0; | ||
1489 | } | ||
1490 | #endif | ||
1491 | |||
1492 | for (pin = 0; pin < nr_ioapic_registers[apic_id]; pin++) { | 1487 | for (pin = 0; pin < nr_ioapic_registers[apic_id]; pin++) { |
1493 | idx = find_irq_entry(apic_id, pin, mp_INT); | 1488 | idx = find_irq_entry(apic_id, pin, mp_INT); |
1494 | if (idx == -1) { | 1489 | if (idx == -1) { |
@@ -1510,6 +1505,9 @@ static void __init setup_IO_APIC_irqs(void) | |||
1510 | 1505 | ||
1511 | irq = pin_2_irq(idx, apic_id, pin); | 1506 | irq = pin_2_irq(idx, apic_id, pin); |
1512 | 1507 | ||
1508 | if ((apic_id > 0) && (irq > 16)) | ||
1509 | continue; | ||
1510 | |||
1513 | /* | 1511 | /* |
1514 | * Skip the timer IRQ if there's a quirk handler | 1512 | * Skip the timer IRQ if there's a quirk handler |
1515 | * installed and if it returns 1: | 1513 | * installed and if it returns 1: |
@@ -1539,6 +1537,56 @@ static void __init setup_IO_APIC_irqs(void) | |||
1539 | } | 1537 | } |
1540 | 1538 | ||
1541 | /* | 1539 | /* |
1540 | * for the gsit that is not in first ioapic | ||
1541 | * but could not use acpi_register_gsi() | ||
1542 | * like some special sci in IBM x3330 | ||
1543 | */ | ||
1544 | void setup_IO_APIC_irq_extra(u32 gsi) | ||
1545 | { | ||
1546 | int apic_id = 0, pin, idx, irq; | ||
1547 | int node = cpu_to_node(boot_cpu_id); | ||
1548 | struct irq_desc *desc; | ||
1549 | struct irq_cfg *cfg; | ||
1550 | |||
1551 | /* | ||
1552 | * Convert 'gsi' to 'ioapic.pin'. | ||
1553 | */ | ||
1554 | apic_id = mp_find_ioapic(gsi); | ||
1555 | if (apic_id < 0) | ||
1556 | return; | ||
1557 | |||
1558 | pin = mp_find_ioapic_pin(apic_id, gsi); | ||
1559 | idx = find_irq_entry(apic_id, pin, mp_INT); | ||
1560 | if (idx == -1) | ||
1561 | return; | ||
1562 | |||
1563 | irq = pin_2_irq(idx, apic_id, pin); | ||
1564 | #ifdef CONFIG_SPARSE_IRQ | ||
1565 | desc = irq_to_desc(irq); | ||
1566 | if (desc) | ||
1567 | return; | ||
1568 | #endif | ||
1569 | desc = irq_to_desc_alloc_node(irq, node); | ||
1570 | if (!desc) { | ||
1571 | printk(KERN_INFO "can not get irq_desc for %d\n", irq); | ||
1572 | return; | ||
1573 | } | ||
1574 | |||
1575 | cfg = desc->chip_data; | ||
1576 | add_pin_to_irq_node(cfg, node, apic_id, pin); | ||
1577 | |||
1578 | if (test_bit(pin, mp_ioapic_routing[apic_id].pin_programmed)) { | ||
1579 | pr_debug("Pin %d-%d already programmed\n", | ||
1580 | mp_ioapics[apic_id].apicid, pin); | ||
1581 | return; | ||
1582 | } | ||
1583 | set_bit(pin, mp_ioapic_routing[apic_id].pin_programmed); | ||
1584 | |||
1585 | setup_IO_APIC_irq(apic_id, pin, irq, desc, | ||
1586 | irq_trigger(idx), irq_polarity(idx)); | ||
1587 | } | ||
1588 | |||
1589 | /* | ||
1542 | * Set up the timer pin, possibly with the 8259A-master behind. | 1590 | * Set up the timer pin, possibly with the 8259A-master behind. |
1543 | */ | 1591 | */ |
1544 | static void __init setup_timer_IRQ0_pin(unsigned int apic_id, unsigned int pin, | 1592 | static void __init setup_timer_IRQ0_pin(unsigned int apic_id, unsigned int pin, |
@@ -1601,14 +1649,14 @@ __apicdebuginit(void) print_IO_APIC(void) | |||
1601 | 1649 | ||
1602 | for (apic = 0; apic < nr_ioapics; apic++) { | 1650 | for (apic = 0; apic < nr_ioapics; apic++) { |
1603 | 1651 | ||
1604 | spin_lock_irqsave(&ioapic_lock, flags); | 1652 | raw_spin_lock_irqsave(&ioapic_lock, flags); |
1605 | reg_00.raw = io_apic_read(apic, 0); | 1653 | reg_00.raw = io_apic_read(apic, 0); |
1606 | reg_01.raw = io_apic_read(apic, 1); | 1654 | reg_01.raw = io_apic_read(apic, 1); |
1607 | if (reg_01.bits.version >= 0x10) | 1655 | if (reg_01.bits.version >= 0x10) |
1608 | reg_02.raw = io_apic_read(apic, 2); | 1656 | reg_02.raw = io_apic_read(apic, 2); |
1609 | if (reg_01.bits.version >= 0x20) | 1657 | if (reg_01.bits.version >= 0x20) |
1610 | reg_03.raw = io_apic_read(apic, 3); | 1658 | reg_03.raw = io_apic_read(apic, 3); |
1611 | spin_unlock_irqrestore(&ioapic_lock, flags); | 1659 | raw_spin_unlock_irqrestore(&ioapic_lock, flags); |
1612 | 1660 | ||
1613 | printk("\n"); | 1661 | printk("\n"); |
1614 | printk(KERN_DEBUG "IO APIC #%d......\n", mp_ioapics[apic].apicid); | 1662 | printk(KERN_DEBUG "IO APIC #%d......\n", mp_ioapics[apic].apicid); |
@@ -1830,7 +1878,7 @@ __apicdebuginit(void) print_PIC(void) | |||
1830 | 1878 | ||
1831 | printk(KERN_DEBUG "\nprinting PIC contents\n"); | 1879 | printk(KERN_DEBUG "\nprinting PIC contents\n"); |
1832 | 1880 | ||
1833 | spin_lock_irqsave(&i8259A_lock, flags); | 1881 | raw_spin_lock_irqsave(&i8259A_lock, flags); |
1834 | 1882 | ||
1835 | v = inb(0xa1) << 8 | inb(0x21); | 1883 | v = inb(0xa1) << 8 | inb(0x21); |
1836 | printk(KERN_DEBUG "... PIC IMR: %04x\n", v); | 1884 | printk(KERN_DEBUG "... PIC IMR: %04x\n", v); |
@@ -1844,7 +1892,7 @@ __apicdebuginit(void) print_PIC(void) | |||
1844 | outb(0x0a,0xa0); | 1892 | outb(0x0a,0xa0); |
1845 | outb(0x0a,0x20); | 1893 | outb(0x0a,0x20); |
1846 | 1894 | ||
1847 | spin_unlock_irqrestore(&i8259A_lock, flags); | 1895 | raw_spin_unlock_irqrestore(&i8259A_lock, flags); |
1848 | 1896 | ||
1849 | printk(KERN_DEBUG "... PIC ISR: %04x\n", v); | 1897 | printk(KERN_DEBUG "... PIC ISR: %04x\n", v); |
1850 | 1898 | ||
@@ -1903,9 +1951,9 @@ void __init enable_IO_APIC(void) | |||
1903 | * The number of IO-APIC IRQ registers (== #pins): | 1951 | * The number of IO-APIC IRQ registers (== #pins): |
1904 | */ | 1952 | */ |
1905 | for (apic = 0; apic < nr_ioapics; apic++) { | 1953 | for (apic = 0; apic < nr_ioapics; apic++) { |
1906 | spin_lock_irqsave(&ioapic_lock, flags); | 1954 | raw_spin_lock_irqsave(&ioapic_lock, flags); |
1907 | reg_01.raw = io_apic_read(apic, 1); | 1955 | reg_01.raw = io_apic_read(apic, 1); |
1908 | spin_unlock_irqrestore(&ioapic_lock, flags); | 1956 | raw_spin_unlock_irqrestore(&ioapic_lock, flags); |
1909 | nr_ioapic_registers[apic] = reg_01.bits.entries+1; | 1957 | nr_ioapic_registers[apic] = reg_01.bits.entries+1; |
1910 | } | 1958 | } |
1911 | 1959 | ||
@@ -2045,9 +2093,9 @@ void __init setup_ioapic_ids_from_mpc(void) | |||
2045 | for (apic_id = 0; apic_id < nr_ioapics; apic_id++) { | 2093 | for (apic_id = 0; apic_id < nr_ioapics; apic_id++) { |
2046 | 2094 | ||
2047 | /* Read the register 0 value */ | 2095 | /* Read the register 0 value */ |
2048 | spin_lock_irqsave(&ioapic_lock, flags); | 2096 | raw_spin_lock_irqsave(&ioapic_lock, flags); |
2049 | reg_00.raw = io_apic_read(apic_id, 0); | 2097 | reg_00.raw = io_apic_read(apic_id, 0); |
2050 | spin_unlock_irqrestore(&ioapic_lock, flags); | 2098 | raw_spin_unlock_irqrestore(&ioapic_lock, flags); |
2051 | 2099 | ||
2052 | old_id = mp_ioapics[apic_id].apicid; | 2100 | old_id = mp_ioapics[apic_id].apicid; |
2053 | 2101 | ||
@@ -2106,16 +2154,16 @@ void __init setup_ioapic_ids_from_mpc(void) | |||
2106 | mp_ioapics[apic_id].apicid); | 2154 | mp_ioapics[apic_id].apicid); |
2107 | 2155 | ||
2108 | reg_00.bits.ID = mp_ioapics[apic_id].apicid; | 2156 | reg_00.bits.ID = mp_ioapics[apic_id].apicid; |
2109 | spin_lock_irqsave(&ioapic_lock, flags); | 2157 | raw_spin_lock_irqsave(&ioapic_lock, flags); |
2110 | io_apic_write(apic_id, 0, reg_00.raw); | 2158 | io_apic_write(apic_id, 0, reg_00.raw); |
2111 | spin_unlock_irqrestore(&ioapic_lock, flags); | 2159 | raw_spin_unlock_irqrestore(&ioapic_lock, flags); |
2112 | 2160 | ||
2113 | /* | 2161 | /* |
2114 | * Sanity check | 2162 | * Sanity check |
2115 | */ | 2163 | */ |
2116 | spin_lock_irqsave(&ioapic_lock, flags); | 2164 | raw_spin_lock_irqsave(&ioapic_lock, flags); |
2117 | reg_00.raw = io_apic_read(apic_id, 0); | 2165 | reg_00.raw = io_apic_read(apic_id, 0); |
2118 | spin_unlock_irqrestore(&ioapic_lock, flags); | 2166 | raw_spin_unlock_irqrestore(&ioapic_lock, flags); |
2119 | if (reg_00.bits.ID != mp_ioapics[apic_id].apicid) | 2167 | if (reg_00.bits.ID != mp_ioapics[apic_id].apicid) |
2120 | printk("could not set ID!\n"); | 2168 | printk("could not set ID!\n"); |
2121 | else | 2169 | else |
@@ -2198,7 +2246,7 @@ static unsigned int startup_ioapic_irq(unsigned int irq) | |||
2198 | unsigned long flags; | 2246 | unsigned long flags; |
2199 | struct irq_cfg *cfg; | 2247 | struct irq_cfg *cfg; |
2200 | 2248 | ||
2201 | spin_lock_irqsave(&ioapic_lock, flags); | 2249 | raw_spin_lock_irqsave(&ioapic_lock, flags); |
2202 | if (irq < nr_legacy_irqs) { | 2250 | if (irq < nr_legacy_irqs) { |
2203 | disable_8259A_irq(irq); | 2251 | disable_8259A_irq(irq); |
2204 | if (i8259A_irq_pending(irq)) | 2252 | if (i8259A_irq_pending(irq)) |
@@ -2206,7 +2254,7 @@ static unsigned int startup_ioapic_irq(unsigned int irq) | |||
2206 | } | 2254 | } |
2207 | cfg = irq_cfg(irq); | 2255 | cfg = irq_cfg(irq); |
2208 | __unmask_IO_APIC_irq(cfg); | 2256 | __unmask_IO_APIC_irq(cfg); |
2209 | spin_unlock_irqrestore(&ioapic_lock, flags); | 2257 | raw_spin_unlock_irqrestore(&ioapic_lock, flags); |
2210 | 2258 | ||
2211 | return was_pending; | 2259 | return was_pending; |
2212 | } | 2260 | } |
@@ -2217,9 +2265,9 @@ static int ioapic_retrigger_irq(unsigned int irq) | |||
2217 | struct irq_cfg *cfg = irq_cfg(irq); | 2265 | struct irq_cfg *cfg = irq_cfg(irq); |
2218 | unsigned long flags; | 2266 | unsigned long flags; |
2219 | 2267 | ||
2220 | spin_lock_irqsave(&vector_lock, flags); | 2268 | raw_spin_lock_irqsave(&vector_lock, flags); |
2221 | apic->send_IPI_mask(cpumask_of(cpumask_first(cfg->domain)), cfg->vector); | 2269 | apic->send_IPI_mask(cpumask_of(cpumask_first(cfg->domain)), cfg->vector); |
2222 | spin_unlock_irqrestore(&vector_lock, flags); | 2270 | raw_spin_unlock_irqrestore(&vector_lock, flags); |
2223 | 2271 | ||
2224 | return 1; | 2272 | return 1; |
2225 | } | 2273 | } |
@@ -2312,14 +2360,14 @@ set_ioapic_affinity_irq_desc(struct irq_desc *desc, const struct cpumask *mask) | |||
2312 | irq = desc->irq; | 2360 | irq = desc->irq; |
2313 | cfg = desc->chip_data; | 2361 | cfg = desc->chip_data; |
2314 | 2362 | ||
2315 | spin_lock_irqsave(&ioapic_lock, flags); | 2363 | raw_spin_lock_irqsave(&ioapic_lock, flags); |
2316 | ret = set_desc_affinity(desc, mask, &dest); | 2364 | ret = set_desc_affinity(desc, mask, &dest); |
2317 | if (!ret) { | 2365 | if (!ret) { |
2318 | /* Only the high 8 bits are valid. */ | 2366 | /* Only the high 8 bits are valid. */ |
2319 | dest = SET_APIC_LOGICAL_ID(dest); | 2367 | dest = SET_APIC_LOGICAL_ID(dest); |
2320 | __target_IO_APIC_irq(irq, dest, cfg); | 2368 | __target_IO_APIC_irq(irq, dest, cfg); |
2321 | } | 2369 | } |
2322 | spin_unlock_irqrestore(&ioapic_lock, flags); | 2370 | raw_spin_unlock_irqrestore(&ioapic_lock, flags); |
2323 | 2371 | ||
2324 | return ret; | 2372 | return ret; |
2325 | } | 2373 | } |
@@ -2554,9 +2602,9 @@ static void eoi_ioapic_irq(struct irq_desc *desc) | |||
2554 | irq = desc->irq; | 2602 | irq = desc->irq; |
2555 | cfg = desc->chip_data; | 2603 | cfg = desc->chip_data; |
2556 | 2604 | ||
2557 | spin_lock_irqsave(&ioapic_lock, flags); | 2605 | raw_spin_lock_irqsave(&ioapic_lock, flags); |
2558 | __eoi_ioapic_irq(irq, cfg); | 2606 | __eoi_ioapic_irq(irq, cfg); |
2559 | spin_unlock_irqrestore(&ioapic_lock, flags); | 2607 | raw_spin_unlock_irqrestore(&ioapic_lock, flags); |
2560 | } | 2608 | } |
2561 | 2609 | ||
2562 | static void ack_apic_level(unsigned int irq) | 2610 | static void ack_apic_level(unsigned int irq) |
@@ -3138,13 +3186,13 @@ static int ioapic_resume(struct sys_device *dev) | |||
3138 | data = container_of(dev, struct sysfs_ioapic_data, dev); | 3186 | data = container_of(dev, struct sysfs_ioapic_data, dev); |
3139 | entry = data->entry; | 3187 | entry = data->entry; |
3140 | 3188 | ||
3141 | spin_lock_irqsave(&ioapic_lock, flags); | 3189 | raw_spin_lock_irqsave(&ioapic_lock, flags); |
3142 | reg_00.raw = io_apic_read(dev->id, 0); | 3190 | reg_00.raw = io_apic_read(dev->id, 0); |
3143 | if (reg_00.bits.ID != mp_ioapics[dev->id].apicid) { | 3191 | if (reg_00.bits.ID != mp_ioapics[dev->id].apicid) { |
3144 | reg_00.bits.ID = mp_ioapics[dev->id].apicid; | 3192 | reg_00.bits.ID = mp_ioapics[dev->id].apicid; |
3145 | io_apic_write(dev->id, 0, reg_00.raw); | 3193 | io_apic_write(dev->id, 0, reg_00.raw); |
3146 | } | 3194 | } |
3147 | spin_unlock_irqrestore(&ioapic_lock, flags); | 3195 | raw_spin_unlock_irqrestore(&ioapic_lock, flags); |
3148 | for (i = 0; i < nr_ioapic_registers[dev->id]; i++) | 3196 | for (i = 0; i < nr_ioapic_registers[dev->id]; i++) |
3149 | ioapic_write_entry(dev->id, i, entry[i]); | 3197 | ioapic_write_entry(dev->id, i, entry[i]); |
3150 | 3198 | ||
@@ -3207,7 +3255,7 @@ unsigned int create_irq_nr(unsigned int irq_want, int node) | |||
3207 | if (irq_want < nr_irqs_gsi) | 3255 | if (irq_want < nr_irqs_gsi) |
3208 | irq_want = nr_irqs_gsi; | 3256 | irq_want = nr_irqs_gsi; |
3209 | 3257 | ||
3210 | spin_lock_irqsave(&vector_lock, flags); | 3258 | raw_spin_lock_irqsave(&vector_lock, flags); |
3211 | for (new = irq_want; new < nr_irqs; new++) { | 3259 | for (new = irq_want; new < nr_irqs; new++) { |
3212 | desc_new = irq_to_desc_alloc_node(new, node); | 3260 | desc_new = irq_to_desc_alloc_node(new, node); |
3213 | if (!desc_new) { | 3261 | if (!desc_new) { |
@@ -3226,14 +3274,11 @@ unsigned int create_irq_nr(unsigned int irq_want, int node) | |||
3226 | irq = new; | 3274 | irq = new; |
3227 | break; | 3275 | break; |
3228 | } | 3276 | } |
3229 | spin_unlock_irqrestore(&vector_lock, flags); | 3277 | raw_spin_unlock_irqrestore(&vector_lock, flags); |
3278 | |||
3279 | if (irq > 0) | ||
3280 | dynamic_irq_init_keep_chip_data(irq); | ||
3230 | 3281 | ||
3231 | if (irq > 0) { | ||
3232 | dynamic_irq_init(irq); | ||
3233 | /* restore it, in case dynamic_irq_init clear it */ | ||
3234 | if (desc_new) | ||
3235 | desc_new->chip_data = cfg_new; | ||
3236 | } | ||
3237 | return irq; | 3282 | return irq; |
3238 | } | 3283 | } |
3239 | 3284 | ||
@@ -3255,20 +3300,13 @@ int create_irq(void) | |||
3255 | void destroy_irq(unsigned int irq) | 3300 | void destroy_irq(unsigned int irq) |
3256 | { | 3301 | { |
3257 | unsigned long flags; | 3302 | unsigned long flags; |
3258 | struct irq_cfg *cfg; | ||
3259 | struct irq_desc *desc; | ||
3260 | 3303 | ||
3261 | /* store it, in case dynamic_irq_cleanup clear it */ | 3304 | dynamic_irq_cleanup_keep_chip_data(irq); |
3262 | desc = irq_to_desc(irq); | ||
3263 | cfg = desc->chip_data; | ||
3264 | dynamic_irq_cleanup(irq); | ||
3265 | /* connect back irq_cfg */ | ||
3266 | desc->chip_data = cfg; | ||
3267 | 3305 | ||
3268 | free_irte(irq); | 3306 | free_irte(irq); |
3269 | spin_lock_irqsave(&vector_lock, flags); | 3307 | raw_spin_lock_irqsave(&vector_lock, flags); |
3270 | __clear_irq_vector(irq, cfg); | 3308 | __clear_irq_vector(irq, get_irq_chip_data(irq)); |
3271 | spin_unlock_irqrestore(&vector_lock, flags); | 3309 | raw_spin_unlock_irqrestore(&vector_lock, flags); |
3272 | } | 3310 | } |
3273 | 3311 | ||
3274 | /* | 3312 | /* |
@@ -3805,9 +3843,9 @@ int __init io_apic_get_redir_entries (int ioapic) | |||
3805 | union IO_APIC_reg_01 reg_01; | 3843 | union IO_APIC_reg_01 reg_01; |
3806 | unsigned long flags; | 3844 | unsigned long flags; |
3807 | 3845 | ||
3808 | spin_lock_irqsave(&ioapic_lock, flags); | 3846 | raw_spin_lock_irqsave(&ioapic_lock, flags); |
3809 | reg_01.raw = io_apic_read(ioapic, 1); | 3847 | reg_01.raw = io_apic_read(ioapic, 1); |
3810 | spin_unlock_irqrestore(&ioapic_lock, flags); | 3848 | raw_spin_unlock_irqrestore(&ioapic_lock, flags); |
3811 | 3849 | ||
3812 | return reg_01.bits.entries; | 3850 | return reg_01.bits.entries; |
3813 | } | 3851 | } |
@@ -3969,9 +4007,9 @@ int __init io_apic_get_unique_id(int ioapic, int apic_id) | |||
3969 | if (physids_empty(apic_id_map)) | 4007 | if (physids_empty(apic_id_map)) |
3970 | apic->ioapic_phys_id_map(&phys_cpu_present_map, &apic_id_map); | 4008 | apic->ioapic_phys_id_map(&phys_cpu_present_map, &apic_id_map); |
3971 | 4009 | ||
3972 | spin_lock_irqsave(&ioapic_lock, flags); | 4010 | raw_spin_lock_irqsave(&ioapic_lock, flags); |
3973 | reg_00.raw = io_apic_read(ioapic, 0); | 4011 | reg_00.raw = io_apic_read(ioapic, 0); |
3974 | spin_unlock_irqrestore(&ioapic_lock, flags); | 4012 | raw_spin_unlock_irqrestore(&ioapic_lock, flags); |
3975 | 4013 | ||
3976 | if (apic_id >= get_physical_broadcast()) { | 4014 | if (apic_id >= get_physical_broadcast()) { |
3977 | printk(KERN_WARNING "IOAPIC[%d]: Invalid apic_id %d, trying " | 4015 | printk(KERN_WARNING "IOAPIC[%d]: Invalid apic_id %d, trying " |
@@ -4005,10 +4043,10 @@ int __init io_apic_get_unique_id(int ioapic, int apic_id) | |||
4005 | if (reg_00.bits.ID != apic_id) { | 4043 | if (reg_00.bits.ID != apic_id) { |
4006 | reg_00.bits.ID = apic_id; | 4044 | reg_00.bits.ID = apic_id; |
4007 | 4045 | ||
4008 | spin_lock_irqsave(&ioapic_lock, flags); | 4046 | raw_spin_lock_irqsave(&ioapic_lock, flags); |
4009 | io_apic_write(ioapic, 0, reg_00.raw); | 4047 | io_apic_write(ioapic, 0, reg_00.raw); |
4010 | reg_00.raw = io_apic_read(ioapic, 0); | 4048 | reg_00.raw = io_apic_read(ioapic, 0); |
4011 | spin_unlock_irqrestore(&ioapic_lock, flags); | 4049 | raw_spin_unlock_irqrestore(&ioapic_lock, flags); |
4012 | 4050 | ||
4013 | /* Sanity check */ | 4051 | /* Sanity check */ |
4014 | if (reg_00.bits.ID != apic_id) { | 4052 | if (reg_00.bits.ID != apic_id) { |
@@ -4029,9 +4067,9 @@ int __init io_apic_get_version(int ioapic) | |||
4029 | union IO_APIC_reg_01 reg_01; | 4067 | union IO_APIC_reg_01 reg_01; |
4030 | unsigned long flags; | 4068 | unsigned long flags; |
4031 | 4069 | ||
4032 | spin_lock_irqsave(&ioapic_lock, flags); | 4070 | raw_spin_lock_irqsave(&ioapic_lock, flags); |
4033 | reg_01.raw = io_apic_read(ioapic, 1); | 4071 | reg_01.raw = io_apic_read(ioapic, 1); |
4034 | spin_unlock_irqrestore(&ioapic_lock, flags); | 4072 | raw_spin_unlock_irqrestore(&ioapic_lock, flags); |
4035 | 4073 | ||
4036 | return reg_01.bits.version; | 4074 | return reg_01.bits.version; |
4037 | } | 4075 | } |
@@ -4063,27 +4101,23 @@ int acpi_get_override_irq(int bus_irq, int *trigger, int *polarity) | |||
4063 | #ifdef CONFIG_SMP | 4101 | #ifdef CONFIG_SMP |
4064 | void __init setup_ioapic_dest(void) | 4102 | void __init setup_ioapic_dest(void) |
4065 | { | 4103 | { |
4066 | int pin, ioapic = 0, irq, irq_entry; | 4104 | int pin, ioapic, irq, irq_entry; |
4067 | struct irq_desc *desc; | 4105 | struct irq_desc *desc; |
4068 | const struct cpumask *mask; | 4106 | const struct cpumask *mask; |
4069 | 4107 | ||
4070 | if (skip_ioapic_setup == 1) | 4108 | if (skip_ioapic_setup == 1) |
4071 | return; | 4109 | return; |
4072 | 4110 | ||
4073 | #ifdef CONFIG_ACPI | 4111 | for (ioapic = 0; ioapic < nr_ioapics; ioapic++) |
4074 | if (!acpi_disabled && acpi_ioapic) { | ||
4075 | ioapic = mp_find_ioapic(0); | ||
4076 | if (ioapic < 0) | ||
4077 | ioapic = 0; | ||
4078 | } | ||
4079 | #endif | ||
4080 | |||
4081 | for (pin = 0; pin < nr_ioapic_registers[ioapic]; pin++) { | 4112 | for (pin = 0; pin < nr_ioapic_registers[ioapic]; pin++) { |
4082 | irq_entry = find_irq_entry(ioapic, pin, mp_INT); | 4113 | irq_entry = find_irq_entry(ioapic, pin, mp_INT); |
4083 | if (irq_entry == -1) | 4114 | if (irq_entry == -1) |
4084 | continue; | 4115 | continue; |
4085 | irq = pin_2_irq(irq_entry, ioapic, pin); | 4116 | irq = pin_2_irq(irq_entry, ioapic, pin); |
4086 | 4117 | ||
4118 | if ((ioapic > 0) && (irq > 16)) | ||
4119 | continue; | ||
4120 | |||
4087 | desc = irq_to_desc(irq); | 4121 | desc = irq_to_desc(irq); |
4088 | 4122 | ||
4089 | /* | 4123 | /* |