Lines Matching full:ioapic

107 static struct ioapic {  struct
138 static inline int mp_ioapic_pin_count(int ioapic) in mp_ioapic_pin_count() argument
140 struct mp_ioapic_gsi *gsi_cfg = mp_ioapic_gsi_routing(ioapic); in mp_ioapic_pin_count()
145 static inline u32 mp_pin_to_gsi(int ioapic, int pin) in mp_pin_to_gsi() argument
147 return mp_ioapic_gsi_routing(ioapic)->gsi_base + pin; in mp_pin_to_gsi()
155 static inline struct irq_domain *mp_ioapic_irqdomain(int ioapic) in mp_ioapic_irqdomain() argument
157 return ioapics[ioapic].irqdomain; in mp_ioapic_irqdomain()
180 * disable_ioapic_support() - disables ioapic support at runtime
228 pr_err("IOAPIC %d: suspend/resume impossible!\n", idx); in alloc_ioapic_saved_registers()
598 * Restore IO APIC entries which was saved in the ioapic structure.
690 pr_warn("IOAPIC: Invalid polarity: 2, defaulting to low\n"); in irq_active_low()
727 pr_warn("IOAPIC: Invalid srcbus: %d defaulting to level\n", bus); in eisa_irq_is_level()
757 pr_warn("IOAPIC: Invalid trigger mode 2 defaulting to level\n"); in irq_is_level()
767 int ioapic, pin, idx; in __acpi_get_override_irq() local
772 ioapic = mp_find_ioapic(gsi); in __acpi_get_override_irq()
773 if (ioapic < 0) in __acpi_get_override_irq()
776 pin = mp_find_ioapic_pin(ioapic, gsi); in __acpi_get_override_irq()
780 idx = find_irq_entry(ioapic, pin, mp_INT); in __acpi_get_override_irq()
803 info->ioapic.node = node; in ioapic_set_alloc_attr()
804 info->ioapic.is_level = trigger; in ioapic_set_alloc_attr()
805 info->ioapic.active_low = polarity; in ioapic_set_alloc_attr()
806 info->ioapic.valid = 1; in ioapic_set_alloc_attr()
818 dst->ioapic.pin = pin; in ioapic_copy_alloc_attr()
819 dst->ioapic.valid = 1; in ioapic_copy_alloc_attr()
820 if (src && src->ioapic.valid) { in ioapic_copy_alloc_attr()
821 dst->ioapic.node = src->ioapic.node; in ioapic_copy_alloc_attr()
822 dst->ioapic.is_level = src->ioapic.is_level; in ioapic_copy_alloc_attr()
823 dst->ioapic.active_low = src->ioapic.active_low; in ioapic_copy_alloc_attr()
825 dst->ioapic.node = NUMA_NO_NODE; in ioapic_copy_alloc_attr()
827 dst->ioapic.is_level = level; in ioapic_copy_alloc_attr()
828 dst->ioapic.active_low = pol_low; in ioapic_copy_alloc_attr()
834 dst->ioapic.is_level = true; in ioapic_copy_alloc_attr()
835 dst->ioapic.active_low = true; in ioapic_copy_alloc_attr()
842 return (info && info->ioapic.valid) ? info->ioapic.node : NUMA_NO_NODE; in ioapic_alloc_attr_node()
872 if (info->ioapic.is_level != data->is_level) in mp_check_pin_attr()
873 mp_register_handler(irq, info->ioapic.is_level); in mp_check_pin_attr()
874 data->entry.is_level = data->is_level = info->ioapic.is_level; in mp_check_pin_attr()
875 data->entry.active_low = data->active_low = info->ioapic.active_low; in mp_check_pin_attr()
878 return data->is_level == info->ioapic.is_level && in mp_check_pin_attr()
879 data->active_low == info->ioapic.active_low; in mp_check_pin_attr()
882 static int alloc_irq_from_domain(struct irq_domain *domain, int ioapic, u32 gsi, in alloc_irq_from_domain() argument
885 int type = ioapics[ioapic].irqdomain_cfg.type; in alloc_irq_from_domain()
905 WARN(1, "ioapic: unknown irqdomain type %d\n", type); in alloc_irq_from_domain()
914 * Need special handling for ISA IRQs because there may be multiple IOAPIC pins
916 * between IOAPIC pin and IRQ number. A typical IOAPIC has 24 pins, pin 0-15 are
923 static int alloc_isa_irq_from_domain(struct irq_domain *domain, int irq, int ioapic, int pin, in alloc_isa_irq_from_domain() argument
932 * the pin list associated with this IRQ and program the IOAPIC in alloc_isa_irq_from_domain()
938 if (!add_pin_to_irq_node(irq_data->chip_data, node, ioapic, info->ioapic.pin)) in alloc_isa_irq_from_domain()
953 static int mp_map_pin_to_irq(u32 gsi, int idx, int ioapic, int pin, in mp_map_pin_to_irq() argument
956 struct irq_domain *domain = mp_ioapic_irqdomain(ioapic); in mp_map_pin_to_irq()
988 ioapic_copy_alloc_attr(&tmp, info, gsi, ioapic, pin); in mp_map_pin_to_irq()
991 ioapic, pin, &tmp); in mp_map_pin_to_irq()
993 irq = alloc_irq_from_domain(domain, ioapic, gsi, &tmp); in mp_map_pin_to_irq()
1004 static int pin_2_irq(int idx, int ioapic, int pin, unsigned int flags) in pin_2_irq() argument
1006 u32 gsi = mp_pin_to_gsi(ioapic, pin); in pin_2_irq()
1028 return mp_map_pin_to_irq(gsi, idx, ioapic, pin, flags, NULL); in pin_2_irq()
1033 int ioapic, pin, idx; in mp_map_gsi_to_irq() local
1035 ioapic = mp_find_ioapic(gsi); in mp_map_gsi_to_irq()
1036 if (ioapic < 0) in mp_map_gsi_to_irq()
1039 pin = mp_find_ioapic_pin(ioapic, gsi); in mp_map_gsi_to_irq()
1040 idx = find_irq_entry(ioapic, pin, mp_INT); in mp_map_gsi_to_irq()
1044 return mp_map_pin_to_irq(gsi, idx, ioapic, pin, flags, info); in mp_map_gsi_to_irq()
1128 unsigned int ioapic, pin; in setup_IO_APIC_irqs() local
1133 for_each_ioapic_pin(ioapic, pin) { in setup_IO_APIC_irqs()
1134 idx = find_irq_entry(ioapic, pin, mp_INT); in setup_IO_APIC_irqs()
1137 mpc_ioapic_id(ioapic), pin); in setup_IO_APIC_irqs()
1139 pin_2_irq(idx, ioapic, pin, ioapic ? 0 : IOAPIC_MAP_ALLOC); in setup_IO_APIC_irqs()
1155 apic_dbg("IOAPIC %d:\n", apic); in io_apic_print_entries()
1300 * If we could not find the appropriate pin by looking at the ioapic in enable_IO_APIC()
1301 * the i8259 probably is not connected the ioapic but give the in enable_IO_APIC()
1324 * If the i8259 is routed through an IOAPIC Put that IOAPIC in in native_restore_boot_irq_mode()
1378 * Set the IOAPIC ID to the value stored in the MPC table. in setup_ioapic_ids_from_mpc_nocheck()
1547 * In the SMP+IOAPIC case it might happen that there are an unspecified
1622 * of the ioapic. This has two effects. in ioapic_finish_move()
1623 * - On any sane system the read of the ioapic will in ioapic_finish_move()
1624 * flush writes (and acks) going to the ioapic from in ioapic_finish_move()
1629 * ioapic entry from outside of irq context starting in ioapic_finish_move()
1630 * with masking the ioapic entry and then polling until in ioapic_finish_move()
1632 * ioapic I don't trust the Remote IRR bit to be in ioapic_finish_move()
1763 * - DMAR/IR: 8bit subhandle (ioapic.pin) in ioapic_setup_msg_from_msi()
1812 * Interrupt shutdown masks the ioapic pin, but the interrupt might already
2009 static int __init mp_alloc_timer_irq(int ioapic, int pin) in mp_alloc_timer_irq() argument
2011 struct irq_domain *domain = mp_ioapic_irqdomain(ioapic); in mp_alloc_timer_irq()
2018 info.devid = mpc_ioapic_id(ioapic); in mp_alloc_timer_irq()
2019 info.ioapic.pin = pin; in mp_alloc_timer_irq()
2021 irq = alloc_isa_irq_from_domain(domain, 0, ioapic, pin, &info); in mp_alloc_timer_irq()
2108 /* Ok, does IRQ0 through the IOAPIC work? */ in check_timer()
2213 static int mp_irqdomain_create(int ioapic) in mp_irqdomain_create() argument
2215 struct mp_ioapic_gsi *gsi_cfg = mp_ioapic_gsi_routing(ioapic); in mp_irqdomain_create()
2216 int hwirqs = mp_ioapic_pin_count(ioapic); in mp_irqdomain_create()
2217 struct ioapic *ip = &ioapics[ioapic]; in mp_irqdomain_create()
2230 fn = irq_domain_alloc_named_id_fwnode("IO-APIC", mpc_ioapic_id(ioapic)); in mp_irqdomain_create()
2237 fwspec.param[0] = mpc_ioapic_id(ioapic); in mp_irqdomain_create()
2247 (void *)(long)ioapic); in mp_irqdomain_create()
2276 int ioapic; in setup_IO_APIC() local
2284 for_each_ioapic(ioapic) in setup_IO_APIC()
2285 BUG_ON(mp_irqdomain_create(ioapic)); in setup_IO_APIC()
2335 static int io_apic_get_redir_entries(int ioapic) in io_apic_get_redir_entries() argument
2340 reg_01.raw = io_apic_read(ioapic, 1); in io_apic_get_redir_entries()
2369 static int io_apic_get_unique_id(int ioapic, int apic_id) in io_apic_get_unique_id() argument
2381 reg_00.raw = io_apic_read(ioapic, 0); in io_apic_get_unique_id()
2384 pr_warn("IOAPIC[%d]: Invalid apic_id %d, trying %d\n", in io_apic_get_unique_id()
2385 ioapic, apic_id, reg_00.bits.ID); in io_apic_get_unique_id()
2399 pr_warn("IOAPIC[%d]: apic_id %d already used, trying %d\n", ioapic, apic_id, i); in io_apic_get_unique_id()
2409 io_apic_write(ioapic, 0, reg_00.raw); in io_apic_get_unique_id()
2410 reg_00.raw = io_apic_read(ioapic, 0); in io_apic_get_unique_id()
2415 pr_err("IOAPIC[%d]: Unable to change apic_id!\n", ioapic); in io_apic_get_unique_id()
2420 apic_pr_verbose("IOAPIC[%d]: Assigned apic_id %d\n", ioapic, apic_id); in io_apic_get_unique_id()
2448 * Read the current id from the ioapic and keep it if in io_apic_unique_id()
2456 apic_pr_verbose("IOAPIC[%d]: Using reg apic_id %d instead of %d\n", in io_apic_unique_id()
2461 /* Get the next free id and write it to the ioapic. */ in io_apic_unique_id()
2475 static int io_apic_get_version(int ioapic) in io_apic_get_version() argument
2480 reg_01.raw = io_apic_read(ioapic, 1); in io_apic_get_version()
2486 * This function updates target affinity of IOAPIC interrupts to include
2514 snprintf(mem, IOAPIC_RESOURCE_NAME_SIZE, "IOAPIC %u", i); in ioapic_setup_resources()
2570 apic_pr_verbose("mapped IOAPIC to %08lx (%08lx)\n", in io_apic_init_mappings()
2604 /* Find the IOAPIC that manages this GSI. */ in mp_find_ioapic()
2612 pr_err("ERROR: Unable to locate IOAPIC for GSI %d\n", gsi); in mp_find_ioapic()
2616 int mp_find_ioapic_pin(int ioapic, u32 gsi) in mp_find_ioapic_pin() argument
2620 if (WARN_ON(ioapic < 0)) in mp_find_ioapic_pin()
2623 gsi_cfg = mp_ioapic_gsi_routing(ioapic); in mp_find_ioapic_pin()
2659 * mp_register_ioapic - Register an IOAPIC device
2660 * @id: hardware IOAPIC ID
2661 * @address: physical address of IOAPIC register area
2662 * @gsi_base: base of GSI associated with the IOAPIC
2663 * @cfg: configuration information for the IOAPIC
2669 int idx, ioapic, entries; in mp_register_ioapic() local
2677 for_each_ioapic(ioapic) { in mp_register_ioapic()
2678 if (ioapics[ioapic].mp_config.apicaddr == address) { in mp_register_ioapic()
2679 pr_warn("address 0x%x conflicts with IOAPIC%d\n", address, ioapic); in mp_register_ioapic()
2706 * and to prevent reprogramming of IOAPIC pins (PCI GSIs). in mp_register_ioapic()
2710 for_each_ioapic(ioapic) { in mp_register_ioapic()
2711 gsi_cfg = mp_ioapic_gsi_routing(ioapic); in mp_register_ioapic()
2716 pr_warn("GSI range [%u-%u] for new IOAPIC conflicts with GSI[%u-%u]\n", in mp_register_ioapic()
2750 pr_info("IOAPIC[%d]: apic_id %d, version %d, address 0x%x, GSI %d-%d\n", in mp_register_ioapic()
2759 int ioapic, pin; in mp_unregister_ioapic() local
2762 for_each_ioapic(ioapic) { in mp_unregister_ioapic()
2763 if (ioapics[ioapic].gsi_config.gsi_base == gsi_base) { in mp_unregister_ioapic()
2770 pr_warn("can't find IOAPIC for GSI %d\n", gsi_base); in mp_unregister_ioapic()
2774 for_each_pin(ioapic, pin) { in mp_unregister_ioapic()
2775 u32 gsi = mp_pin_to_gsi(ioapic, pin); in mp_unregister_ioapic()
2782 pr_warn("pin%d on IOAPIC%d is still in use.\n", pin, ioapic); in mp_unregister_ioapic()
2789 ioapics[ioapic].nr_registers = 0; in mp_unregister_ioapic()
2790 ioapic_destroy_irqdomain(ioapic); in mp_unregister_ioapic()
2791 free_ioapic_saved_registers(ioapic); in mp_unregister_ioapic()
2792 if (ioapics[ioapic].iomem_res) in mp_unregister_ioapic()
2793 release_resource(ioapics[ioapic].iomem_res); in mp_unregister_ioapic()
2794 clear_fixmap(FIX_IO_APIC_BASE_0 + ioapic); in mp_unregister_ioapic()
2795 memset(&ioapics[ioapic], 0, sizeof(ioapics[ioapic])); in mp_unregister_ioapic()
2802 int ioapic; in mp_ioapic_registered() local
2804 for_each_ioapic(ioapic) in mp_ioapic_registered()
2805 if (ioapics[ioapic].gsi_config.gsi_base == gsi_base) in mp_ioapic_registered()
2814 if (info && info->ioapic.valid) { in mp_irqdomain_get_attr()
2815 data->is_level = info->ioapic.is_level; in mp_irqdomain_get_attr()
2816 data->active_low = info->ioapic.active_low; in mp_irqdomain_get_attr()
2856 int ret, ioapic, pin; in mp_irqdomain_alloc() local
2865 ioapic = mp_irqdomain_ioapic_idx(domain); in mp_irqdomain_alloc()
2866 pin = info->ioapic.pin; in mp_irqdomain_alloc()
2879 irq_data->hwirq = info->ioapic.pin; in mp_irqdomain_alloc()
2883 mp_irqdomain_get_attr(mp_pin_to_gsi(ioapic, pin), data, info); in mp_irqdomain_alloc()
2885 if (!add_pin_to_irq_node(data, ioapic_alloc_attr_node(info), ioapic, pin)) { in mp_irqdomain_alloc()
2898 …apic_pr_verbose("IOAPIC[%d]: Preconfigured routing entry (%d-%d -> IRQ %d Level:%i ActiveLow:%i)\n… in mp_irqdomain_alloc()
2899 ioapic, mpc_ioapic_id(ioapic), pin, virq, data->is_level, data->active_low); in mp_irqdomain_alloc()
2936 /* It won't be called for IRQ with multiple IOAPIC pins associated */ in mp_irqdomain_deactivate()