Skip to content

Commit 464d123

Browse files
committed
x86/vector: Switch IOAPIC to global reservation mode
IOAPICs install and allocate vectors for inactive interrupts. This results in problems on CPU offline and wastes vector resources for nothing. Handle inactive IOAPIC interrupts in the same way as inactive MSI interrupts and switch them to the global reservation mode. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Juergen Gross <jgross@suse.com> Tested-by: Yu Chen <yu.c.chen@intel.com> Acked-by: Juergen Gross <jgross@suse.com> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com> Cc: Tony Luck <tony.luck@intel.com> Cc: Marc Zyngier <marc.zyngier@arm.com> Cc: Alok Kataria <akataria@vmware.com> Cc: Joerg Roedel <joro@8bytes.org> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Christoph Hellwig <hch@lst.de> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Rui Zhang <rui.zhang@intel.com> Cc: "K. Y. Srinivasan" <kys@microsoft.com> Cc: Arjan van de Ven <arjan@linux.intel.com> Cc: Dan Williams <dan.j.williams@intel.com> Cc: Len Brown <lenb@kernel.org> Link: https://lkml.kernel.org/r/20170913213156.273454591@linutronix.de
1 parent 4900be8 commit 464d123

File tree

1 file changed

+33
-23
lines changed

1 file changed

+33
-23
lines changed

arch/x86/kernel/apic/vector.c

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -258,28 +258,17 @@ static int assign_irq_vector_any_locked(struct irq_data *irqd)
258258
return assign_vector_locked(irqd, cpu_online_mask);
259259
}
260260

261-
static int assign_irq_vector_any(struct irq_data *irqd)
262-
{
263-
unsigned long flags;
264-
int ret;
265-
266-
raw_spin_lock_irqsave(&vector_lock, flags);
267-
ret = assign_irq_vector_any_locked(irqd);
268-
raw_spin_unlock_irqrestore(&vector_lock, flags);
269-
return ret;
270-
}
271-
272261
static int
273262
assign_irq_vector_policy(struct irq_data *irqd, struct irq_alloc_info *info)
274263
{
275264
if (irqd_affinity_is_managed(irqd))
276265
return reserve_managed_vector(irqd);
277266
if (info->mask)
278267
return assign_irq_vector(irqd, info->mask);
279-
if (info->type != X86_IRQ_ALLOC_TYPE_MSI &&
280-
info->type != X86_IRQ_ALLOC_TYPE_MSIX)
281-
return assign_irq_vector_any(irqd);
282-
/* For MSI(X) make only a global reservation with no guarantee */
268+
/*
269+
* Make only a global reservation with no guarantee. A real vector
270+
* is associated at activation time.
271+
*/
283272
return reserve_irq_vector(irqd);
284273
}
285274

@@ -456,13 +445,39 @@ static void x86_vector_free_irqs(struct irq_domain *domain,
456445
}
457446
}
458447

448+
static bool vector_configure_legacy(unsigned int virq, struct irq_data *irqd,
449+
struct apic_chip_data *apicd)
450+
{
451+
unsigned long flags;
452+
bool realloc = false;
453+
454+
apicd->vector = ISA_IRQ_VECTOR(virq);
455+
apicd->cpu = 0;
456+
457+
raw_spin_lock_irqsave(&vector_lock, flags);
458+
/*
459+
* If the interrupt is activated, then it must stay at this vector
460+
* position. That's usually the timer interrupt (0).
461+
*/
462+
if (irqd_is_activated(irqd)) {
463+
trace_vector_setup(virq, true, 0);
464+
apic_update_irq_cfg(irqd, apicd->vector, apicd->cpu);
465+
} else {
466+
/* Release the vector */
467+
apicd->can_reserve = true;
468+
clear_irq_vector(irqd);
469+
realloc = true;
470+
}
471+
raw_spin_unlock_irqrestore(&vector_lock, flags);
472+
return realloc;
473+
}
474+
459475
static int x86_vector_alloc_irqs(struct irq_domain *domain, unsigned int virq,
460476
unsigned int nr_irqs, void *arg)
461477
{
462478
struct irq_alloc_info *info = arg;
463479
struct apic_chip_data *apicd;
464480
struct irq_data *irqd;
465-
unsigned long flags;
466481
int i, err, node;
467482

468483
if (disable_apic)
@@ -496,13 +511,8 @@ static int x86_vector_alloc_irqs(struct irq_domain *domain, unsigned int virq,
496511
* config.
497512
*/
498513
if (info->flags & X86_IRQ_ALLOC_LEGACY) {
499-
apicd->vector = ISA_IRQ_VECTOR(virq + i);
500-
apicd->cpu = 0;
501-
trace_vector_setup(virq + i, true, 0);
502-
raw_spin_lock_irqsave(&vector_lock, flags);
503-
apic_update_irq_cfg(irqd, apicd->vector, apicd->cpu);
504-
raw_spin_unlock_irqrestore(&vector_lock, flags);
505-
continue;
514+
if (!vector_configure_legacy(virq + i, irqd, apicd))
515+
continue;
506516
}
507517

508518
err = assign_irq_vector_policy(irqd, info);

0 commit comments

Comments
 (0)