With all callers of alloc_direct_apic_vector() now being limited to BSP setup, it and its helpers (whose other callers have already been init- only) can become __init. As a result data items can be adjusted, too.
With alloc_direct_apic_vector() now being __init, it's meaningless to use a lock, and the indirection is also pretty pointless. Drop both while at it. Signed-off-by: Jan Beulich <[email protected]> Signed-off-by: Andrew Cooper <[email protected]> Acked-by: Jan Beulich <[email protected]> --- v2: Re-work alloc_direct_apic_vector(). --- a/xen/arch/x86/cpu/mcheck/mce_intel.c +++ b/xen/arch/x86/cpu/mcheck/mce_intel.c @@ -161,7 +161,7 @@ static void intel_init_thermal(const str } if ( bsp ) - alloc_direct_apic_vector(&thermal_apic_vector, intel_thermal_interrupt); + thermal_apic_vector = alloc_direct_apic_vector(intel_thermal_interrupt); /* The temperature transition interrupt handler setup */ val = thermal_apic_vector; /* our delivery vector */ @@ -689,7 +689,7 @@ static void intel_init_cmci(struct cpuin } if ( bsp ) - alloc_direct_apic_vector(&cmci_apic_vector, cmci_interrupt); + cmci_apic_vector = alloc_direct_apic_vector(cmci_interrupt); apic = cmci_apic_vector; apic |= (APIC_DM_FIXED | APIC_LVT_MASKED); --- a/xen/arch/x86/guest/xen/xen.c +++ b/xen/arch/x86/guest/xen/xen.c @@ -293,7 +293,7 @@ static void __init cf_check setup(void) XEN_LEGACY_MAX_VCPUS); } - alloc_direct_apic_vector(&evtchn_upcall_vector, xen_evtchn_upcall); + evtchn_upcall_vector = alloc_direct_apic_vector(xen_evtchn_upcall); BUG_ON(init_evtchn()); } --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -3181,10 +3181,10 @@ const struct hvm_function_table * __init if ( cpu_has_vmx_posted_intr_processing ) { - alloc_direct_apic_vector(&posted_intr_vector, pi_notification_interrupt); + posted_intr_vector = alloc_direct_apic_vector(pi_notification_interrupt); if ( iommu_intpost ) { - alloc_direct_apic_vector(&pi_wakeup_vector, pi_wakeup_interrupt); + pi_wakeup_vector = alloc_direct_apic_vector(pi_wakeup_interrupt); vmx_function_table.pi_update_irte = vmx_pi_update_irte; } --- a/xen/arch/x86/include/asm/irq.h +++ b/xen/arch/x86/include/asm/irq.h @@ -119,7 +119,7 @@ uint8_t alloc_hipriority_vector(void); void free_lopriority_vector(uint8_t vector); void set_direct_apic_vector(uint8_t vector, void (*handler)(void)); -void alloc_direct_apic_vector(uint8_t *vector, void (*handler)(void)); +uint8_t alloc_direct_apic_vector(void (*handler)(void)); void do_IRQ(struct cpu_user_regs *regs); --- a/xen/arch/x86/irq.c +++ b/xen/arch/x86/irq.c @@ -970,31 +970,28 @@ void pirq_set_affinity(struct domain *d, DEFINE_PER_CPU(unsigned int, irq_count); static DEFINE_PER_CPU(bool, check_eoi_deferral); -uint8_t alloc_hipriority_vector(void) +uint8_t __init alloc_hipriority_vector(void) { - static uint8_t next = FIRST_HIPRIORITY_VECTOR; + static uint8_t __initdata next = FIRST_HIPRIORITY_VECTOR; BUG_ON(next < FIRST_HIPRIORITY_VECTOR); BUG_ON(next > LAST_HIPRIORITY_VECTOR); return next++; } -static void (*direct_apic_vector[X86_IDT_VECTORS])(void); -void set_direct_apic_vector(uint8_t vector, void (*handler)(void)) +static void (*__ro_after_init direct_apic_vector[X86_IDT_VECTORS])(void); +void __init set_direct_apic_vector(uint8_t vector, void (*handler)(void)) { BUG_ON(direct_apic_vector[vector] != NULL); direct_apic_vector[vector] = handler; } -void alloc_direct_apic_vector(uint8_t *vector, void (*handler)(void)) +uint8_t __init alloc_direct_apic_vector(void (*handler)(void)) { - static DEFINE_SPINLOCK(lock); + uint8_t vec = alloc_hipriority_vector(); - spin_lock(&lock); - if (*vector == 0) { - *vector = alloc_hipriority_vector(); - set_direct_apic_vector(*vector, handler); - } - spin_unlock(&lock); + set_direct_apic_vector(vec, handler); + + return vec; } /* This could free any vectors, but is needed only for low-prio ones. */
