diff options
author | Alex Bennée <alex.bennee@linaro.org> | 2015-03-13 13:02:53 -0400 |
---|---|---|
committer | Christoffer Dall <christoffer.dall@linaro.org> | 2015-03-14 08:44:52 -0400 |
commit | 71760950bf3dc796e5e53ea3300dec724a09f593 (patch) | |
tree | 974d409ca994d82f66da7d66e618e5f2d9ba86d2 /virt | |
parent | ecccf0cc722f40e0dcc97872e7a960765119a256 (diff) |
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: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Diffstat (limited to 'virt')
-rw-r--r-- | virt/kvm/arm/vgic.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c index c000e978c1fb..697ce17538f5 100644 --- a/virt/kvm/arm/vgic.c +++ b/virt/kvm/arm/vgic.c | |||
@@ -950,6 +950,20 @@ static void vgic_retire_disabled_irqs(struct kvm_vcpu *vcpu) | |||
950 | } | 950 | } |
951 | } | 951 | } |
952 | 952 | ||
953 | static void vgic_queue_irq_to_lr(struct kvm_vcpu *vcpu, int irq, | ||
954 | int lr_nr, struct vgic_lr vlr) | ||
955 | { | ||
956 | if (vgic_dist_irq_is_pending(vcpu, irq)) { | ||
957 | vlr.state |= LR_STATE_PENDING; | ||
958 | kvm_debug("Set pending: 0x%x\n", vlr.state); | ||
959 | } | ||
960 | |||
961 | if (!vgic_irq_is_edge(vcpu, irq)) | ||
962 | vlr.state |= LR_EOI_INT; | ||
963 | |||
964 | vgic_set_lr(vcpu, lr_nr, vlr); | ||
965 | } | ||
966 | |||
953 | /* | 967 | /* |
954 | * Queue an interrupt to a CPU virtual interface. Return true on success, | 968 | * Queue an interrupt to a CPU virtual interface. Return true on success, |
955 | * or false if it wasn't possible to queue it. | 969 | * 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 | if (vlr.source == sgi_source_id) { | 991 | if (vlr.source == sgi_source_id) { |
978 | kvm_debug("LR%d piggyback for IRQ%d\n", lr, vlr.irq); | 992 | kvm_debug("LR%d piggyback for IRQ%d\n", lr, vlr.irq); |
979 | BUG_ON(!test_bit(lr, vgic_cpu->lr_used)); | 993 | BUG_ON(!test_bit(lr, vgic_cpu->lr_used)); |
980 | vlr.state |= LR_STATE_PENDING; | 994 | vgic_queue_irq_to_lr(vcpu, irq, lr, vlr); |
981 | vgic_set_lr(vcpu, lr, vlr); | ||
982 | return true; | 995 | return true; |
983 | } | 996 | } |
984 | } | 997 | } |
@@ -995,11 +1008,8 @@ bool vgic_queue_irq(struct kvm_vcpu *vcpu, u8 sgi_source_id, int irq) | |||
995 | 1008 | ||
996 | vlr.irq = irq; | 1009 | vlr.irq = irq; |
997 | vlr.source = sgi_source_id; | 1010 | vlr.source = sgi_source_id; |
998 | vlr.state = LR_STATE_PENDING; | 1011 | vlr.state = 0; |
999 | if (!vgic_irq_is_edge(vcpu, irq)) | 1012 | vgic_queue_irq_to_lr(vcpu, irq, lr, vlr); |
1000 | vlr.state |= LR_EOI_INT; | ||
1001 | |||
1002 | vgic_set_lr(vcpu, lr, vlr); | ||
1003 | 1013 | ||
1004 | return true; | 1014 | return true; |
1005 | } | 1015 | } |