Lines Matching full:apic

3  *	Intel IO-APIC support for multi-Pentium hosts.
10 * (c) 1999, Multiple IO-APIC support, developed by
25 * - SiS APIC rmw bug:
67 #include <asm/apic.h>
90 int apic, pin; member
116 /* I/O APIC config */
118 /* IO APIC gsi routing info */
197 /* disable IO-APIC */ in parse_noapic()
209 " IRQ %02x, APIC ID %x, APIC INT %02x\n", in mp_save_irq()
269 static inline void io_apic_eoi(unsigned int apic, unsigned int vector) in io_apic_eoi() argument
271 struct io_apic __iomem *io_apic = io_apic_base(apic); in io_apic_eoi()
275 unsigned int native_io_apic_read(unsigned int apic, unsigned int reg) in native_io_apic_read() argument
277 struct io_apic __iomem *io_apic = io_apic_base(apic); in native_io_apic_read()
282 static void io_apic_write(unsigned int apic, unsigned int reg, in io_apic_write() argument
285 struct io_apic __iomem *io_apic = io_apic_base(apic); in io_apic_write()
291 static struct IO_APIC_route_entry __ioapic_read_entry(int apic, int pin) in __ioapic_read_entry() argument
295 entry.w1 = io_apic_read(apic, 0x10 + 2 * pin); in __ioapic_read_entry()
296 entry.w2 = io_apic_read(apic, 0x11 + 2 * pin); in __ioapic_read_entry()
301 static struct IO_APIC_route_entry ioapic_read_entry(int apic, int pin) in ioapic_read_entry() argument
307 entry = __ioapic_read_entry(apic, pin); in ioapic_read_entry()
314 * When we write a new IO APIC routing entry, we need to write the high
319 static void __ioapic_write_entry(int apic, int pin, struct IO_APIC_route_entry e) in __ioapic_write_entry() argument
321 io_apic_write(apic, 0x11 + 2*pin, e.w2); in __ioapic_write_entry()
322 io_apic_write(apic, 0x10 + 2*pin, e.w1); in __ioapic_write_entry()
325 static void ioapic_write_entry(int apic, int pin, struct IO_APIC_route_entry e) in ioapic_write_entry() argument
330 __ioapic_write_entry(apic, pin, e); in ioapic_write_entry()
335 * When we mask an IO APIC routing entry, we need to write the low
339 static void ioapic_mask_entry(int apic, int pin) in ioapic_mask_entry() argument
345 io_apic_write(apic, 0x10 + 2*pin, e.w1); in ioapic_mask_entry()
346 io_apic_write(apic, 0x11 + 2*pin, e.w2); in ioapic_mask_entry()
356 int node, int apic, int pin) in __add_pin_to_irq_node() argument
362 if (entry->apic == apic && entry->pin == pin) in __add_pin_to_irq_node()
368 node, apic, pin); in __add_pin_to_irq_node()
371 entry->apic = apic; in __add_pin_to_irq_node()
378 static void __remove_pin_from_irq(struct mp_chip_data *data, int apic, int pin) in __remove_pin_from_irq() argument
383 if (entry->apic == apic && entry->pin == pin) { in __remove_pin_from_irq()
391 int node, int apic, int pin) in add_pin_to_irq_node() argument
393 if (__add_pin_to_irq_node(data, node, apic, pin)) in add_pin_to_irq_node()
394 panic("IO-APIC: failed to add irq-pin. Can not proceed\n"); in add_pin_to_irq_node()
407 if (entry->apic == oldapic && entry->pin == oldpin) { in replace_pin_at_irq_node()
408 entry->apic = newapic; in replace_pin_at_irq_node()
415 /* old apic/pin didn't exist, so just add new ones */ in replace_pin_at_irq_node()
427 io_apic_write(entry->apic, 0x10 + 2 * entry->pin, data->entry.w1); in io_apic_modify_irq()
436 * Synchronize the IO-APIC and the CPU by doing in io_apic_sync()
437 * a dummy read from the IO-APIC in io_apic_sync()
441 io_apic = io_apic_base(entry->apic); in io_apic_sync()
471 * IO-APIC versions below 0x20 don't support EOI register.
474 * 1Xh I/OAPIC or I/O(x)APIC which are not PCI 2.2 Compliant
475 * 2Xh I/O(x)APIC which is PCI 2.2 Compliant
478 * Some of the Intel ICH Specs (ICH2 to ICH5) documents the io-apic
480 * use io-apic's of version 0x20.
482 * For IO-APIC's with EOI register, we use that to do an explicit EOI.
486 static void __eoi_ioapic_pin(int apic, int pin, int vector) in __eoi_ioapic_pin() argument
488 if (mpc_ioapic_ver(apic) >= 0x20) { in __eoi_ioapic_pin()
489 io_apic_eoi(apic, vector); in __eoi_ioapic_pin()
493 entry = entry1 = __ioapic_read_entry(apic, pin); in __eoi_ioapic_pin()
501 __ioapic_write_entry(apic, pin, entry1); in __eoi_ioapic_pin()
506 __ioapic_write_entry(apic, pin, entry); in __eoi_ioapic_pin()
517 __eoi_ioapic_pin(entry->apic, entry->pin, vector); in eoi_ioapic_pin()
521 static void clear_IO_APIC_pin(unsigned int apic, unsigned int pin) in clear_IO_APIC_pin() argument
526 entry = ioapic_read_entry(apic, pin); in clear_IO_APIC_pin()
536 ioapic_write_entry(apic, pin, entry); in clear_IO_APIC_pin()
537 entry = ioapic_read_entry(apic, pin); in clear_IO_APIC_pin()
550 ioapic_write_entry(apic, pin, entry); in clear_IO_APIC_pin()
553 __eoi_ioapic_pin(apic, pin, entry.vector); in clear_IO_APIC_pin()
558 * Clear the rest of the bits in the IO-APIC RTE except for the mask in clear_IO_APIC_pin()
561 ioapic_mask_entry(apic, pin); in clear_IO_APIC_pin()
562 entry = ioapic_read_entry(apic, pin); in clear_IO_APIC_pin()
564 pr_err("Unable to reset IRR for apic: %d, pin :%d\n", in clear_IO_APIC_pin()
565 mpc_ioapic_id(apic), pin); in clear_IO_APIC_pin()
570 int apic, pin; in clear_IO_APIC() local
572 for_each_ioapic_pin(apic, pin) in clear_IO_APIC()
573 clear_IO_APIC_pin(apic, pin); in clear_IO_APIC()
615 * Saves all the IO-APIC RTE's
619 int apic, pin; in save_ioapic_entries() local
622 for_each_ioapic(apic) { in save_ioapic_entries()
623 if (!ioapics[apic].saved_registers) { in save_ioapic_entries()
628 for_each_pin(apic, pin) in save_ioapic_entries()
629 ioapics[apic].saved_registers[pin] = in save_ioapic_entries()
630 ioapic_read_entry(apic, pin); in save_ioapic_entries()
637 * Mask all IO APIC entries.
641 int apic, pin; in mask_ioapic_entries() local
643 for_each_ioapic(apic) { in mask_ioapic_entries()
644 if (!ioapics[apic].saved_registers) in mask_ioapic_entries()
647 for_each_pin(apic, pin) { in mask_ioapic_entries()
650 entry = ioapics[apic].saved_registers[pin]; in mask_ioapic_entries()
653 ioapic_write_entry(apic, pin, entry); in mask_ioapic_entries()
660 * Restore IO APIC entries which was saved in the ioapic structure.
664 int apic, pin; in restore_ioapic_entries() local
666 for_each_ioapic(apic) { in restore_ioapic_entries()
667 if (!ioapics[apic].saved_registers) in restore_ioapic_entries()
670 for_each_pin(apic, pin) in restore_ioapic_entries()
671 ioapic_write_entry(apic, pin, in restore_ioapic_entries()
672 ioapics[apic].saved_registers[pin]); in restore_ioapic_entries()
1218 KERN_DEBUG " apic %d pin %d not connected\n", in setup_IO_APIC_irqs()
1231 static void io_apic_print_entries(unsigned int apic, unsigned int nr_entries) in io_apic_print_entries() argument
1237 printk(KERN_DEBUG "IOAPIC %d:\n", apic); in io_apic_print_entries()
1239 entry = ioapic_read_entry(apic, i); in io_apic_print_entries()
1278 printk(KERN_DEBUG "IO APIC #%d......\n", mpc_ioapic_id(ioapic_idx)); in print_IO_APIC()
1280 printk(KERN_DEBUG "....... : physical APIC id: %02X\n", reg_00.bits.ID); in print_IO_APIC()
1289 printk(KERN_DEBUG "....... : IO APIC version: %02X\n", in print_IO_APIC()
1293 * Some Intel chipsets with IO APIC VERSION of 0x1? don't have reg_02, in print_IO_APIC()
1303 * Some Intel chipsets with IO APIC VERSION of 0x2? don't have reg_02 in print_IO_APIC()
1324 printk(KERN_DEBUG "number of IO-APIC #%d registers: %d.\n", in print_IO_APICs()
1332 printk(KERN_INFO "testing the IO APIC.......................\n"); in print_IO_APICs()
1354 pr_cont("-> %d:%d", entry->apic, entry->pin); in print_IO_APICs()
1362 static struct { int pin, apic; } ioapic_i8259 = { -1, -1 }; member
1367 int apic, pin; in enable_IO_APIC() local
1375 for_each_ioapic_pin(apic, pin) { in enable_IO_APIC()
1377 struct IO_APIC_route_entry entry = ioapic_read_entry(apic, pin); in enable_IO_APIC()
1384 ioapic_i8259.apic = apic; in enable_IO_APIC()
1401 ioapic_i8259.apic = i8259_apic; in enable_IO_APIC()
1404 if (((ioapic_i8259.apic != i8259_apic) || (ioapic_i8259.pin != i8259_pin)) && in enable_IO_APIC()
1411 * Do not trust the IO-APIC being empty at bootup in enable_IO_APIC()
1437 * Add it to the IO-APIC irq-routing table: in native_restore_boot_irq_mode()
1439 ioapic_write_entry(ioapic_i8259.apic, ioapic_i8259.pin, entry); in native_restore_boot_irq_mode()
1456 * function to set the IO-APIC physical IDs based on the
1474 apic->ioapic_phys_id_map(&phys_cpu_present_map, &phys_id_present_map); in setup_ioapic_ids_from_mpc_nocheck()
1488 printk(KERN_ERR "BIOS bug, IO-APIC#%d ID is %d in the MPC table!...\n", in setup_ioapic_ids_from_mpc_nocheck()
1496 * Sanity check, is the ID really free? Every APIC in a in setup_ioapic_ids_from_mpc_nocheck()
1500 if (apic->check_apicid_used(&phys_id_present_map, in setup_ioapic_ids_from_mpc_nocheck()
1502 printk(KERN_ERR "BIOS bug, IO-APIC#%d ID %d is already used!...\n", in setup_ioapic_ids_from_mpc_nocheck()
1508 panic("Max APIC ID exceeded!\n"); in setup_ioapic_ids_from_mpc_nocheck()
1537 "...changing IO-APIC physical APIC ID to %d ...", in setup_ioapic_ids_from_mpc_nocheck()
1564 * Don't check I/O APIC IDs for xAPIC systems. They have in setup_ioapic_ids_from_mpc()
1565 * no meaning without the serial APIC bus. in setup_ioapic_ids_from_mpc()
1624 * - timer IRQ defaults to IO-APIC IRQ
1644 * ticks in a non-ExtINT mode. Also the local APIC in timer_irq_works()
1669 * Starting up a edge-triggered IO-APIC interrupt is
1708 e.w1 = io_apic_read(entry->apic, 0x10 + pin*2); in io_apic_level_ack_pending()
1789 * of I/O APIC (that's the 82093AA and cores integrated into various in ioapic_ack_level()
1801 * trigger mode gets detected in the TMR of a local APIC for a in ioapic_ack_level()
1810 * level-triggered io-apic interrupt will be seen as an edge in ioapic_ack_level()
1812 * to be broadcasted to the IO-APIC's which will clear the remoteIRR in ioapic_ack_level()
1813 * corresponding to the level-triggered interrupt. Hence on IO-APIC's in ioapic_ack_level()
1815 * remote IRR and on IO-APIC's which don't have an EOI register, in ioapic_ack_level()
1830 * message via io-apic EOI register write or simulating it using in ioapic_ack_level()
1850 * intr-remapping table entry. Hence for the io-apic in ioapic_ir_ack_level()
1914 __ioapic_write_entry(entry->apic, entry->pin, mpd->entry); in ioapic_configure_entry()
1961 rentry = __ioapic_read_entry(p->apic, p->pin); in ioapic_irq_get_chip_state()
1965 * irrelevant because the IO-APIC treats them as fire and in ioapic_irq_get_chip_state()
1978 .name = "IO-APIC",
1992 .name = "IR-IO-APIC",
2028 * The local APIC irq-chip implementation:
2053 .name = "local-APIC",
2075 int apic, pin, i; in unlock_ExtINT_logic() local
2085 apic = find_isa_irq_apic(8, mp_INT); in unlock_ExtINT_logic()
2086 if (apic == -1) { in unlock_ExtINT_logic()
2091 entry0 = ioapic_read_entry(apic, pin); in unlock_ExtINT_logic()
2092 clear_IO_APIC_pin(apic, pin); in unlock_ExtINT_logic()
2106 ioapic_write_entry(apic, pin, entry1); in unlock_ExtINT_logic()
2123 clear_IO_APIC_pin(apic, pin); in unlock_ExtINT_logic()
2125 ioapic_write_entry(apic, pin, entry0); in unlock_ExtINT_logic()
2185 * wire has to be disabled in the local APIC. Also in check_timer()
2188 * watchdog as that APIC treats NMIs as level-triggered. in check_timer()
2198 apic2 = ioapic_i8259.apic; in check_timer()
2206 * I/O APIC input from the cascaded 8259A as the timer in check_timer()
2212 panic_if_irq_remap("BIOS bug: timer not connected to IO-APIC"); in check_timer()
2243 panic_if_irq_remap("timer doesn't work through Interrupt-remapped IO-APIC"); in check_timer()
2247 "8254 timer not connected to IO-APIC\n"); in check_timer()
2252 "..... (found apic %d pin %d) ...\n", apic2, pin2); in check_timer()
2254 * legacy devices should be connected to IO APIC #0 in check_timer()
2306 panic("IO-APIC + timer doesn't work! Boot with apic=debug and send a " in check_timer()
2314 * to devices. However there may be an I/O APIC pin available for
2320 * of an override it would be treated as an ordinary ISA I/O APIC
2324 * the same ExtINT cascade interrupt to drive the local APIC of the
2326 * the I/O APIC in all cases now. No actual device should request
2348 fn = irq_domain_alloc_named_id_fwnode("IO-APIC", mpc_ioapic_id(ioapic)); in mp_irqdomain_create()
2403 apic_printk(APIC_VERBOSE, "ENABLING IO-APIC IRQs\n"); in setup_IO_APIC()
2408 * Set up IO-APIC IRQ routing. in setup_IO_APIC()
2487 * always 0. gsi_top can be 0 if there is no IO/APIC registered. in arch_dynirq_lower_bound()
2504 * The P4 platform supports up to 256 APIC IDs on two separate APIC in io_apic_get_unique_id()
2506 * supports up to 16 on one shared APIC bus. in io_apic_get_unique_id()
2509 * advantage of new APIC bus architecture. in io_apic_get_unique_id()
2513 apic->ioapic_phys_id_map(&phys_cpu_present_map, &apic_id_map); in io_apic_get_unique_id()
2526 * Every APIC in a system must have a unique ID or we get lots of nice in io_apic_get_unique_id()
2529 if (apic->check_apicid_used(&apic_id_map, apic_id)) { in io_apic_get_unique_id()
2532 if (!apic->check_apicid_used(&apic_id_map, i)) in io_apic_get_unique_id()
2684 * Ensure fixmaps for IO-APIC MMIO respect memory encryption pgprot in io_apic_set_fixmap()
2710 "WARNING: bogus zero IO-APIC " in io_apic_init_mappings()
2712 "disabling IO/APIC support!\n"); in io_apic_init_mappings()
2749 "IO APIC resources couldn't be allocated.\n"); in ioapic_insert_resources()
2802 pr_warn("I/O APIC 0x%x registers return all ones, skipping!\n", in bad_ioapic_register()
2837 pr_warn("Bogus (zero) I/O APIC address found, skipping!\n"); in mp_register_ioapic()
2990 * Configure the I/O-APIC specific fields in the routing entry.
2992 * This is important to setup the I/O-APIC specific bits (is_level,
2994 * provide the routing information and is oblivious of the I/O-APIC