ia64/xen-unstable
changeset 9791:c76daba31026
In both i386 and x86-64 Linux, using a static variable (and thus
having the potential of missing synchronization there,
as I suspect exists in native Linux) is not needed with the hypercall
approach. In the hypervisor, the patch adds the
needed synchronization.
Signed-off-by: Jan Beulich <jbeulich@novell.com>
having the potential of missing synchronization there,
as I suspect exists in native Linux) is not needed with the hypercall
approach. In the hypervisor, the patch adds the
needed synchronization.
Signed-off-by: Jan Beulich <jbeulich@novell.com>
author | kaf24@firebug.cl.cam.ac.uk |
---|---|
date | Thu Apr 20 14:10:35 2006 +0100 (2006-04-20) |
parents | f80709ba0e79 |
children | 75f8e9c4e483 |
files | linux-2.6-xen-sparse/arch/i386/kernel/io_apic-xen.c linux-2.6-xen-sparse/arch/x86_64/kernel/io_apic-xen.c xen/arch/x86/io_apic.c |
line diff
1.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/io_apic-xen.c Thu Apr 20 10:38:07 2006 +0100 1.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/io_apic-xen.c Thu Apr 20 14:10:35 2006 +0100 1.3 @@ -1205,7 +1205,6 @@ u8 irq_vector[NR_IRQ_VECTORS] __read_mos 1.4 1.5 int assign_irq_vector(int irq) 1.6 { 1.7 - static int current_vector = FIRST_DEVICE_VECTOR; 1.8 physdev_op_t op; 1.9 1.10 BUG_ON(irq >= NR_IRQ_VECTORS); 1.11 @@ -1216,13 +1215,12 @@ int assign_irq_vector(int irq) 1.12 op.u.irq_op.irq = irq; 1.13 if (HYPERVISOR_physdev_op(&op)) 1.14 return -ENOSPC; 1.15 - current_vector = op.u.irq_op.vector; 1.16 - 1.17 - vector_irq[current_vector] = irq; 1.18 + 1.19 + vector_irq[op.u.irq_op.vector] = irq; 1.20 if (irq != AUTO_ASSIGN) 1.21 - IO_APIC_VECTOR(irq) = current_vector; 1.22 - 1.23 - return current_vector; 1.24 + IO_APIC_VECTOR(irq) = op.u.irq_op.vector; 1.25 + 1.26 + return op.u.irq_op.vector; 1.27 } 1.28 1.29 #ifndef CONFIG_XEN
2.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/io_apic-xen.c Thu Apr 20 10:38:07 2006 +0100 2.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/io_apic-xen.c Thu Apr 20 14:10:35 2006 +0100 2.3 @@ -869,7 +869,6 @@ u8 irq_vector[NR_IRQ_VECTORS] __read_mos 2.4 2.5 int assign_irq_vector(int irq) 2.6 { 2.7 - static int current_vector = FIRST_DEVICE_VECTOR; 2.8 physdev_op_t op; 2.9 2.10 BUG_ON(irq != AUTO_ASSIGN && (unsigned)irq >= NR_IRQ_VECTORS); 2.11 @@ -880,13 +879,12 @@ int assign_irq_vector(int irq) 2.12 op.u.irq_op.irq = irq; 2.13 if (HYPERVISOR_physdev_op(&op)) 2.14 return -ENOSPC; 2.15 - current_vector = op.u.irq_op.vector; 2.16 2.17 - vector_irq[current_vector] = irq; 2.18 + vector_irq[op.u.irq_op.vector] = irq; 2.19 if (irq != AUTO_ASSIGN) 2.20 - IO_APIC_VECTOR(irq) = current_vector; 2.21 + IO_APIC_VECTOR(irq) = op.u.irq_op.vector; 2.22 2.23 - return current_vector; 2.24 + return op.u.irq_op.vector; 2.25 } 2.26 2.27 extern void (*interrupt[NR_IRQS])(void);
3.1 --- a/xen/arch/x86/io_apic.c Thu Apr 20 10:38:07 2006 +0100 3.2 +++ b/xen/arch/x86/io_apic.c Thu Apr 20 14:10:35 2006 +0100 3.3 @@ -48,6 +48,7 @@ atomic_t irq_mis_count; 3.4 static struct { int pin, apic; } ioapic_i8259 = { -1, -1 }; 3.5 3.6 static DEFINE_SPINLOCK(ioapic_lock); 3.7 +static DEFINE_SPINLOCK(vector_lock); 3.8 3.9 int skip_ioapic_setup; 3.10 3.11 @@ -661,11 +662,17 @@ u8 irq_vector[NR_IRQ_VECTORS] __read_mos 3.12 3.13 int assign_irq_vector(int irq) 3.14 { 3.15 - static int current_vector = FIRST_DYNAMIC_VECTOR, offset = 0; 3.16 + static unsigned current_vector = FIRST_DYNAMIC_VECTOR, offset = 0; 3.17 + unsigned vector; 3.18 3.19 BUG_ON(irq >= NR_IRQ_VECTORS); 3.20 - if (irq != AUTO_ASSIGN && IO_APIC_VECTOR(irq) > 0) 3.21 + spin_lock(&vector_lock); 3.22 + 3.23 + if (irq != AUTO_ASSIGN && IO_APIC_VECTOR(irq) > 0) { 3.24 + spin_unlock(&vector_lock); 3.25 return IO_APIC_VECTOR(irq); 3.26 + } 3.27 + 3.28 next: 3.29 current_vector += 8; 3.30 3.31 @@ -679,16 +686,21 @@ next: 3.32 3.33 if (current_vector > LAST_DYNAMIC_VECTOR) { 3.34 offset++; 3.35 - if (!(offset%8)) 3.36 + if (!(offset%8)) { 3.37 + spin_unlock(&vector_lock); 3.38 return -ENOSPC; 3.39 + } 3.40 current_vector = FIRST_DYNAMIC_VECTOR + offset; 3.41 } 3.42 3.43 - vector_irq[current_vector] = irq; 3.44 + vector = current_vector; 3.45 + vector_irq[vector] = irq; 3.46 if (irq != AUTO_ASSIGN) 3.47 - IO_APIC_VECTOR(irq) = current_vector; 3.48 + IO_APIC_VECTOR(irq) = vector; 3.49 3.50 - return current_vector; 3.51 + spin_unlock(&vector_lock); 3.52 + 3.53 + return vector; 3.54 } 3.55 3.56 static struct hw_interrupt_type ioapic_level_type;