Commit 71760950 authored by Alex Bennée's avatar Alex Bennée Committed by Christoffer Dall

arm/arm64: KVM: add a common vgic_queue_irq_to_lr fn

This helps re-factor away some of the repetitive code and makes the code
flow more nicely.
Signed-off-by: default avatarAlex Bennée <alex.bennee@linaro.org>
Signed-off-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
parent ecccf0cc
...@@ -950,6 +950,20 @@ static void vgic_retire_disabled_irqs(struct kvm_vcpu *vcpu) ...@@ -950,6 +950,20 @@ static void vgic_retire_disabled_irqs(struct kvm_vcpu *vcpu)
} }
} }
static void vgic_queue_irq_to_lr(struct kvm_vcpu *vcpu, int irq,
int lr_nr, struct vgic_lr vlr)
{
if (vgic_dist_irq_is_pending(vcpu, irq)) {
vlr.state |= LR_STATE_PENDING;
kvm_debug("Set pending: 0x%x\n", vlr.state);
}
if (!vgic_irq_is_edge(vcpu, irq))
vlr.state |= LR_EOI_INT;
vgic_set_lr(vcpu, lr_nr, vlr);
}
/* /*
* Queue an interrupt to a CPU virtual interface. Return true on success, * Queue an interrupt to a CPU virtual interface. Return true on success,
* or false if it wasn't possible to queue it. * or false if it wasn't possible to queue it.
...@@ -977,8 +991,7 @@ bool vgic_queue_irq(struct kvm_vcpu *vcpu, u8 sgi_source_id, int irq) ...@@ -977,8 +991,7 @@ bool vgic_queue_irq(struct kvm_vcpu *vcpu, u8 sgi_source_id, int irq)
if (vlr.source == sgi_source_id) { if (vlr.source == sgi_source_id) {
kvm_debug("LR%d piggyback for IRQ%d\n", lr, vlr.irq); kvm_debug("LR%d piggyback for IRQ%d\n", lr, vlr.irq);
BUG_ON(!test_bit(lr, vgic_cpu->lr_used)); BUG_ON(!test_bit(lr, vgic_cpu->lr_used));
vlr.state |= LR_STATE_PENDING; vgic_queue_irq_to_lr(vcpu, irq, lr, vlr);
vgic_set_lr(vcpu, lr, vlr);
return true; return true;
} }
} }
...@@ -995,11 +1008,8 @@ bool vgic_queue_irq(struct kvm_vcpu *vcpu, u8 sgi_source_id, int irq) ...@@ -995,11 +1008,8 @@ bool vgic_queue_irq(struct kvm_vcpu *vcpu, u8 sgi_source_id, int irq)
vlr.irq = irq; vlr.irq = irq;
vlr.source = sgi_source_id; vlr.source = sgi_source_id;
vlr.state = LR_STATE_PENDING; vlr.state = 0;
if (!vgic_irq_is_edge(vcpu, irq)) vgic_queue_irq_to_lr(vcpu, irq, lr, vlr);
vlr.state |= LR_EOI_INT;
vgic_set_lr(vcpu, lr, vlr);
return true; return true;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment