Lines Matching +full:virtual +full:- +full:wire +full:- +full:mode
1 // SPDX-License-Identifier: GPL-2.0-only
13 * Mikael Pettersson : Power Management for UP-APIC.
43 #include <asm/pc-conf-reg.h>
64 #include <asm/intel-family.h>
75 unsigned int boot_cpu_physical_apicid __ro_after_init = -1U;
124 * Handle interrupt mode configuration register (IMCR).
127 * local APIC. Before entering Symmetric I/O Mode, either
129 * PIC Mode by changing the IMCR.
147 * +1=force-enable
237 * so apic->write/read doesn't do anything
266 * get_physical_broadcast - Get number of physical broadcast IDs
275 * lapic_get_maxlvt - get the maximum number of local vector table entries
280 * - we always have APIC integrated on 64bit mode in lapic_get_maxlvt()
281 * - 82489DXs do not report # of LVT entries in lapic_get_maxlvt()
333 * See Intel SDM: TSC-Deadline Mode chapter. In xAPIC mode, in __setup_APIC_LVTT()
425 return -EINVAL; in setup_APIC_eilvt()
433 return -EBUSY; in setup_APIC_eilvt()
470 if (evt->features & CLOCK_EVT_FEAT_DUMMY) in lapic_timer_shutdown()
496 if (evt->features & CLOCK_EVT_FEAT_DUMMY) in lapic_timer_set_periodic_oneshot()
540 .irq = -1,
589 rev = (u32)m->driver_data; in apic_validate_deadline_timer()
615 levt->cpumask = cpumask_of(smp_processor_id()); in setup_APIC_timer()
618 levt->name = "lapic-deadline"; in setup_APIC_timer()
619 levt->features &= ~(CLOCK_EVT_FEAT_PERIODIC | in setup_APIC_timer()
621 levt->set_next_event = lapic_next_deadline; in setup_APIC_timer()
646 * The clockevent device's ->mult and ->shift can both be in lapic_update_tsc_freq()
676 static __initdata int lapic_cal_loops = -1;
722 return -1; in calibrate_by_pmtimer()
725 apic_printk(APIC_VERBOSE, "... PM-Timer delta = %ld\n", deltapm); in calibrate_by_pmtimer()
729 return -1; in calibrate_by_pmtimer()
733 if (deltapm > (pm_100ms - pm_thresh) && in calibrate_by_pmtimer()
735 apic_printk(APIC_VERBOSE, "... PM-Timer result ok\n"); in calibrate_by_pmtimer()
742 "with PM-Timer: %ldms instead of 100ms\n", (long)res); in calibrate_by_pmtimer()
747 pr_info("APIC delta adjusted to PM-Timer: " in calibrate_by_pmtimer()
756 "PM-Timer: %lu (%ld)\n", in calibrate_by_pmtimer()
767 return -1; in lapic_init_clockevent()
796 * If interrupt delivery mode is legacy PIC or virtual wire without in apic_needs_pit()
889 if ((tsc_now - tsc_start) >= tsc_perj) { in calibrate_APIC_clock()
912 /* Build delta t1-t2 as apic timer counts down */ in calibrate_APIC_clock()
913 delta = lapic_cal_t1 - lapic_cal_t2; in calibrate_APIC_clock()
916 deltatsc = (long)(lapic_cal_tsc2 - lapic_cal_tsc1); in calibrate_APIC_clock()
919 pm_referenced = !calibrate_by_pmtimer(lapic_cal_pm2 - lapic_cal_pm1, in calibrate_APIC_clock()
948 return -1; in calibrate_APIC_clock()
951 levt->features &= ~CLOCK_EVT_FEAT_DUMMY; in calibrate_APIC_clock()
964 levt->event_handler = lapic_cal_handler; in calibrate_APIC_clock()
966 lapic_cal_loops = -1; in calibrate_APIC_clock()
979 deltaj = lapic_cal_j2 - lapic_cal_j1; in calibrate_APIC_clock()
983 if (deltaj >= LAPIC_CAL_LOOPS-2 && deltaj <= LAPIC_CAL_LOOPS+2) in calibrate_APIC_clock()
986 levt->features |= CLOCK_EVT_FEAT_DUMMY; in calibrate_APIC_clock()
990 if (levt->features & CLOCK_EVT_FEAT_DUMMY) { in calibrate_APIC_clock()
992 return -1; in calibrate_APIC_clock()
1060 * its possible that when we get here evt->event_handler is NULL. in local_apic_timer_interrupt()
1064 if (!evt->event_handler) { in local_apic_timer_interrupt()
1073 * the NMI deadlock-detector uses this. in local_apic_timer_interrupt()
1077 evt->event_handler(evt); in local_apic_timer_interrupt()
1085 * [ if a single-CPU system runs an SMP kernel then we call the local
1105 * clear_local_APIC - shutdown the local APIC
1125 v = ERROR_APIC_VECTOR; /* any non-zero vector will do */ in clear_local_APIC()
1130 * any level-triggered sources. in clear_local_APIC()
1179 * apic_soft_disable - Clears and software disables the local APIC on hotplug
1182 * MSR_IA32_APICBASE. Clearing that bit on systems based on the 3 wire APIC
1202 * disable_local_APIC - clear and disable the local APIC
1228 * re-entering the BIOS on shutdown. Otherwise the BIOS may get confused and
1229 * not power-off. Additionally clear all LVT entries before disable_local_APIC
1253 * sync_Arb_IDs - synchronize APIC bus arbitration IDs
1258 * Unsupported on P4 - see Intel Dev. Manual Vol. 3, Ch. 8.6.1 And not in sync_Arb_IDs()
1286 /* On 64-bit, the APIC must be integrated, Check local APIC only */ in __apic_intr_mode_select()
1293 /* On 32-bit, the APIC may be integrated APIC or 82489DX */ in __apic_intr_mode_select()
1323 pr_info("APIC: SMP mode deactivated\n"); in __apic_intr_mode_select()
1331 /* Select the interrupt delivery mode for the BSP */
1338 * An initial setup of the virtual wire mode.
1346 * through-I/O-APIC virtual wire mode might be active. in init_bsp_APIC()
1375 * Set up the virtual wire mode. in init_bsp_APIC()
1388 /* Init the interrupt delivery mode for the BSP */
1395 pr_info("APIC: Keep in PIC mode(8259)\n"); in apic_intr_mode_init()
1398 pr_info("APIC: Switch to virtual wire mode setup\n"); in apic_intr_mode_init()
1401 pr_info("APIC: Switch to virtual wire mode setup with no configuration\n"); in apic_intr_mode_init()
1405 pr_info("APIC: Switch to symmetric I/O mode setup\n"); in apic_intr_mode_init()
1408 pr_info("APIC: Switch to symmetric I/O mode setup in no SMP routine\n"); in apic_intr_mode_init()
1431 if (apic->disable_esr) { in lapic_setup_esr()
1435 * ESR disabled - we can't do anything useful with the in lapic_setup_esr()
1436 * errors anyway - mbligh in lapic_setup_esr()
1478 irr->regs[i] = apic_read(APIC_IRR + i * 0x10); in apic_check_and_ack()
1482 isr->regs[i] = apic_read(APIC_ISR + i * 0x10); in apic_check_and_ack()
1489 if (!bitmap_empty(isr->map, APIC_IR_BITS)) { in apic_check_and_ack()
1495 for_each_set_bit(bit, isr->map, APIC_IR_BITS) in apic_check_and_ack()
1500 return !bitmap_empty(irr->map, APIC_IR_BITS); in apic_check_and_ack()
1532 * setup_local_APIC - setup the local APIC
1556 /* Pound the ESR really hard over the head with a big hammer - mbligh */ in setup_local_APIC()
1557 if (lapic_is_integrated() && apic->disable_esr) { in setup_local_APIC()
1565 BUG_ON(apic->apic_id_registered && !apic->apic_id_registered()); in setup_local_APIC()
1569 * an APIC. See e.g. "AP-388 82489DX User's Manual" (Intel in setup_local_APIC()
1572 * Except for APICs which operate in physical destination mode. in setup_local_APIC()
1574 if (apic->init_apic_ldr) in setup_local_APIC()
1575 apic->init_apic_ldr(); in setup_local_APIC()
1578 * Set Task Priority to 'accept all except vectors 0-31'. An APIC in setup_local_APIC()
1579 * vector in the 16-31 range could be delivered if TPR == 0, but we in setup_local_APIC()
1609 * away, oh well :-( in setup_local_APIC()
1611 * [ This bug can be reproduced easily with a level-triggered in setup_local_APIC()
1618 * like LRU than MRU (the short-term load is more even across CPUs). in setup_local_APIC()
1622 * - enable focus processor (bit==0) in setup_local_APIC()
1623 * - 64bit mode always use processor focus in setup_local_APIC()
1640 * set up through-local-APIC on the boot CPU's LINT0. This is not in setup_local_APIC()
1641 * strictly necessary in pure symmetric-IO mode, but sometimes in setup_local_APIC()
1645 * TODO: set up through-local-APIC from through-I/O-APIC? --macro in setup_local_APIC()
1760 /* Disable xapic and x2apic first and then reenable xapic mode */ in __x2apic_disable()
1788 pr_warn("APIC locked in x2apic mode, can't disable\n"); in setup_nox2apic()
1877 pr_info("x2apic: IRQ remapping doesn't support X2APIC mode\n"); in try_to_enable_x2apic()
1885 * used for non-remapped IRQ domains. in try_to_enable_x2apic()
1894 * in physical mode, and CPUs with an APIC ID that cannot in try_to_enable_x2apic()
1942 pr_info("Not enabling interrupt remapping due to skipped IO-APIC setup\n"); in enable_IR_x2apic()
1952 pr_info("Saving IO-APIC state failed: %d\n", ret); in enable_IR_x2apic()
1957 legacy_pic->mask_all(); in enable_IR_x2apic()
1963 /* ir_stat contains the remap mode or an error code */ in enable_IR_x2apic()
1968 legacy_pic->restore_mask(); in enable_IR_x2apic()
1974 * Detect and enable local APICs on non-SMP boards.
1976 * On AMD64 we trust the BIOS - if it says no APIC it is likely
2033 pr_info("Local APIC disabled by BIOS -- reenabling.\n"); in apic_force_enable()
2071 * Over-ride BIOS and try to enable the local APIC only if in detect_init_APIC()
2075 pr_info("Local APIC disabled by BIOS -- " in detect_init_APIC()
2097 * init_apic_mappings - initialize APIC mappings
2180 * spurious_interrupt - Catch all for interrupts raised on unused vectors
2217 /* First tickle the hardware, only then report what went on. -- REW */ in DEFINE_IDTENTRY_SYSVEC()
2241 * connect_bsp_APIC - attach the APIC to the interrupt system
2252 * PIC mode, enable APIC mode in the IMCR, i.e. connect BSP's in connect_bsp_APIC()
2255 apic_printk(APIC_VERBOSE, "leaving PIC mode, " in connect_bsp_APIC()
2256 "enabling APIC mode.\n"); in connect_bsp_APIC()
2263 * disconnect_bsp_APIC - detach the APIC from the interrupt system
2264 * @virt_wire_setup: indicates, whether virtual wire mode is selected
2266 * Virtual wire mode is necessary to deliver legacy interrupts even when the
2276 * Put the board back into PIC mode (has an effect only on in disconnect_bsp_APIC()
2281 apic_printk(APIC_VERBOSE, "disabling APIC mode, " in disconnect_bsp_APIC()
2282 "entering PIC mode.\n"); in disconnect_bsp_APIC()
2288 /* Go back to Virtual Wire compatibility mode */ in disconnect_bsp_APIC()
2341 [0 ... NR_CPUS - 1] = -1,
2353 u32 mask = (1U << (fls(smp_num_siblings) - 1)) - 1; in cpu_mark_primary_thread()
2395 * cpuid <-> apicid mapping is persistent, so when a cpu is up, in allocate_logical_cpuid()
2408 return -EINVAL; in allocate_logical_cpuid()
2454 return -ENODEV; in generic_processor_info()
2464 return -EINVAL; in generic_processor_info()
2470 return -EINVAL; in generic_processor_info()
2483 msg->arch_addr_lo.base_address = X86_MSI_BASE_ADDRESS_LOW; in __irq_msi_compose_msg()
2484 msg->arch_addr_lo.dest_mode_logical = apic->dest_mode_logical; in __irq_msi_compose_msg()
2485 msg->arch_addr_lo.destid_0_7 = cfg->dest_apicid & 0xFF; in __irq_msi_compose_msg()
2487 msg->arch_data.delivery_mode = APIC_DELIVERY_MODE_FIXED; in __irq_msi_compose_msg()
2488 msg->arch_data.vector = cfg->vector; in __irq_msi_compose_msg()
2490 msg->address_hi = X86_MSI_BASE_ADDRESS_HIGH; in __irq_msi_compose_msg()
2495 * address APICs which can't be addressed in the normal 32-bit in __irq_msi_compose_msg()
2498 * 5-11 to be used, giving support for 15 bits of APIC IDs in total. in __irq_msi_compose_msg()
2501 msg->arch_addr_hi.destid_8_31 = cfg->dest_apicid >> 8; in __irq_msi_compose_msg()
2502 else if (virt_ext_dest_id && cfg->dest_apicid < 0x8000) in __irq_msi_compose_msg()
2503 msg->arch_addr_lo.virt_destid_8_14 = cfg->dest_apicid >> 8; in __irq_msi_compose_msg()
2505 WARN_ON_ONCE(cfg->dest_apicid > 0xFF); in __irq_msi_compose_msg()
2510 u32 dest = msg->arch_addr_lo.destid_0_7; in x86_msi_msg_get_destid()
2513 dest |= msg->arch_addr_hi.destid_8_31 << 8; in x86_msi_msg_get_destid()
2521 apic_write(APIC_ID, apic->set_apic_id(boot_cpu_physical_apicid)); in apic_bsp_up_setup()
2527 * apic_bsp_setup - Setup function for local apic and io-apic
2528 * @upmode: Force UP mode (for APIC_init_uniprocessor)
2644 * IO-APIC and PIC have their own resume routines. in lapic_resume()
2647 * and interrupt-remapping. in lapic_resume()
2650 legacy_pic->mask_all(); in lapic_resume()
2703 * This device has no shutdown method - fully functioning local APICs
2744 pr_info("APIC: %s detected, Multi Chassis\n", d->ident); in set_multi()
2771 * apic_is_clustered_box() -- Check if we can expect good TSC
2775 * multi-chassis.
2828 return -EINVAL; in apic_set_verbosity()
2842 return -EINVAL; in apic_set_verbosity()
2853 return -1; in lapic_insert_resource()
2857 lapic_resource.end = lapic_resource.start + PAGE_SIZE - 1; in lapic_insert_resource()
2872 return -EINVAL; in apic_set_disabled_cpu_apicid()
2881 return -EINVAL; in apic_set_extnmi()
2890 pr_warn("Unknown external NMI delivery mode `%s' ignored\n", arg); in apic_set_extnmi()
2891 return -EINVAL; in apic_set_extnmi()