[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [RFC PATCH v2 15/22] ARM: vGIC: rework vgic_get_target_vcpu to take a pending_irq
For now vgic_get_target_vcpu takes a VCPU and an IRQ number, because this is what we need for finding the proper rank and the VCPU in there. In the future the VCPU will be looked up in the struct pending_irq. To avoid locking issues, let's pass the pointer to the pending_irq instead. We can read the IRQ number from there, and all but one caller know that pointer already anyway. This simplifies future code changes. Signed-off-by: Andre Przywara <andre.przywara@xxxxxxx> --- xen/arch/arm/gic.c | 2 +- xen/arch/arm/vgic.c | 22 ++++++++++++---------- xen/include/asm-arm/vgic.h | 2 +- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index 84b282b..38e998a 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -559,7 +559,7 @@ void gic_update_one_lr(struct vcpu *v, int i) smp_wmb(); if ( test_bit(GIC_IRQ_GUEST_MIGRATING, &p->status) ) { - struct vcpu *v_target = vgic_get_target_vcpu(v, irq); + struct vcpu *v_target = vgic_get_target_vcpu(v, p); irq_set_affinity(p->desc, cpumask_of(v_target->processor)); clear_bit(GIC_IRQ_GUEST_MIGRATING, &p->status); } diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c index e5a4765..6722924 100644 --- a/xen/arch/arm/vgic.c +++ b/xen/arch/arm/vgic.c @@ -224,10 +224,11 @@ int vcpu_vgic_free(struct vcpu *v) return 0; } -struct vcpu *vgic_get_target_vcpu(struct vcpu *v, unsigned int virq) +struct vcpu *vgic_get_target_vcpu(struct vcpu *v, struct pending_irq *p) { - struct vgic_irq_rank *rank = vgic_rank_irq(v, virq); - int target = read_atomic(&rank->vcpu[virq & INTERRUPT_RANK_MASK]); + struct vgic_irq_rank *rank = vgic_rank_irq(v, p->irq); + int target = read_atomic(&rank->vcpu[p->irq & INTERRUPT_RANK_MASK]); + return v->domain->vcpu[target]; } @@ -391,8 +392,8 @@ void arch_move_irqs(struct vcpu *v) for ( i = 32; i < vgic_num_irqs(d); i++ ) { - v_target = vgic_get_target_vcpu(v, i); - p = irq_to_pending(v_target, i); + p = irq_to_pending(v, i); + v_target = vgic_get_target_vcpu(v, p); if ( v_target == v && !test_bit(GIC_IRQ_GUEST_MIGRATING, &p->status) ) irq_set_affinity(p->desc, cpu_mask); @@ -414,10 +415,10 @@ void vgic_disable_irqs(struct vcpu *v, uint32_t r, int n) while ( (i = find_next_bit(&mask, 32, i)) < 32 ) { irq = i + (32 * n); - v_target = vgic_get_target_vcpu(v, irq); + p = irq_to_pending(v, irq); + v_target = vgic_get_target_vcpu(v, p); spin_lock_irqsave(&v_target->arch.vgic.lock, flags); - p = irq_to_pending(v_target, irq); clear_bit(GIC_IRQ_GUEST_ENABLED, &p->status); gic_remove_from_lr_pending(v_target, p); desc = p->desc; @@ -468,9 +469,9 @@ void vgic_enable_irqs(struct vcpu *v, uint32_t r, int n) while ( (i = find_next_bit(&mask, 32, i)) < 32 ) { irq = i + (32 * n); - v_target = vgic_get_target_vcpu(v, irq); + p = irq_to_pending(v, irq); + v_target = vgic_get_target_vcpu(v, p); spin_lock_irqsave(&v_target->arch.vgic.lock, vcpu_flags); - p = irq_to_pending(v_target, irq); vgic_irq_lock(p, flags); set_bit(GIC_IRQ_GUEST_ENABLED, &p->status); int_type = test_bit(GIC_IRQ_GUEST_LEVEL, &p->status) ? @@ -666,12 +667,13 @@ out: void vgic_vcpu_inject_spi(struct domain *d, unsigned int virq) { + struct pending_irq *p = irq_to_pending(d->vcpu[0], virq); struct vcpu *v; /* the IRQ needs to be an SPI */ ASSERT(virq >= 32 && virq <= vgic_num_irqs(d)); - v = vgic_get_target_vcpu(d->vcpu[0], virq); + v = vgic_get_target_vcpu(d->vcpu[0], p); vgic_vcpu_inject_irq(v, virq); } diff --git a/xen/include/asm-arm/vgic.h b/xen/include/asm-arm/vgic.h index 14c22b2..7c6067d 100644 --- a/xen/include/asm-arm/vgic.h +++ b/xen/include/asm-arm/vgic.h @@ -213,7 +213,7 @@ enum gic_sgi_mode; extern int domain_vgic_init(struct domain *d, unsigned int nr_spis); extern void domain_vgic_free(struct domain *d); extern int vcpu_vgic_init(struct vcpu *v); -extern struct vcpu *vgic_get_target_vcpu(struct vcpu *v, unsigned int virq); +extern struct vcpu *vgic_get_target_vcpu(struct vcpu *v, struct pending_irq *p); extern void vgic_vcpu_inject_irq(struct vcpu *v, unsigned int virq); extern void vgic_vcpu_inject_spi(struct domain *d, unsigned int virq); extern void vgic_clear_pending_irqs(struct vcpu *v); -- 2.9.0 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |