diff options
| author | Paolo Bonzini <pbonzini@redhat.com> | 2014-03-18 06:51:29 -0400 |
|---|---|---|
| committer | Paolo Bonzini <pbonzini@redhat.com> | 2014-03-21 05:19:48 -0400 |
| commit | 0b10a1c87a2b0fb459baaefba9cb163dbb8d3344 (patch) | |
| tree | 04ad989ba4d94f0c86e971f8262c62027f718a8e /virt | |
| parent | 36c95494609cd6d2541c08e806b4d6bc401bc53f (diff) | |
KVM: ioapic: merge ioapic_deliver into ioapic_service
Commonize the handling of masking, which was absent for kvm_ioapic_set_irq.
Setting remote_irr does not need a separate function either, and merging
the two functions avoids confusion.
Reviewed-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'virt')
| -rw-r--r-- | virt/kvm/ioapic.c | 29 |
1 files changed, 9 insertions, 20 deletions
diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c index 1539d3757a04..0b4914147b9d 100644 --- a/virt/kvm/ioapic.c +++ b/virt/kvm/ioapic.c | |||
| @@ -50,7 +50,7 @@ | |||
| 50 | #else | 50 | #else |
| 51 | #define ioapic_debug(fmt, arg...) | 51 | #define ioapic_debug(fmt, arg...) |
| 52 | #endif | 52 | #endif |
| 53 | static int ioapic_deliver(struct kvm_ioapic *vioapic, int irq, | 53 | static int ioapic_service(struct kvm_ioapic *vioapic, int irq, |
| 54 | bool line_status); | 54 | bool line_status); |
| 55 | 55 | ||
| 56 | static unsigned long ioapic_read_indirect(struct kvm_ioapic *ioapic, | 56 | static unsigned long ioapic_read_indirect(struct kvm_ioapic *ioapic, |
| @@ -163,23 +163,6 @@ static bool rtc_irq_check_coalesced(struct kvm_ioapic *ioapic) | |||
| 163 | return false; | 163 | return false; |
| 164 | } | 164 | } |
| 165 | 165 | ||
| 166 | static int ioapic_service(struct kvm_ioapic *ioapic, unsigned int idx, | ||
| 167 | bool line_status) | ||
| 168 | { | ||
| 169 | union kvm_ioapic_redirect_entry *pent; | ||
| 170 | int injected = -1; | ||
| 171 | |||
| 172 | pent = &ioapic->redirtbl[idx]; | ||
| 173 | |||
| 174 | if (!pent->fields.mask) { | ||
| 175 | injected = ioapic_deliver(ioapic, idx, line_status); | ||
| 176 | if (injected && pent->fields.trig_mode == IOAPIC_LEVEL_TRIG) | ||
| 177 | pent->fields.remote_irr = 1; | ||
| 178 | } | ||
| 179 | |||
| 180 | return injected; | ||
| 181 | } | ||
| 182 | |||
| 183 | static void update_handled_vectors(struct kvm_ioapic *ioapic) | 166 | static void update_handled_vectors(struct kvm_ioapic *ioapic) |
| 184 | { | 167 | { |
| 185 | DECLARE_BITMAP(handled_vectors, 256); | 168 | DECLARE_BITMAP(handled_vectors, 256); |
| @@ -282,12 +265,15 @@ static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val) | |||
| 282 | } | 265 | } |
| 283 | } | 266 | } |
| 284 | 267 | ||
| 285 | static int ioapic_deliver(struct kvm_ioapic *ioapic, int irq, bool line_status) | 268 | static int ioapic_service(struct kvm_ioapic *ioapic, int irq, bool line_status) |
| 286 | { | 269 | { |
| 287 | union kvm_ioapic_redirect_entry *entry = &ioapic->redirtbl[irq]; | 270 | union kvm_ioapic_redirect_entry *entry = &ioapic->redirtbl[irq]; |
| 288 | struct kvm_lapic_irq irqe; | 271 | struct kvm_lapic_irq irqe; |
| 289 | int ret; | 272 | int ret; |
| 290 | 273 | ||
| 274 | if (entry->fields.mask) | ||
| 275 | return -1; | ||
| 276 | |||
| 291 | ioapic_debug("dest=%x dest_mode=%x delivery_mode=%x " | 277 | ioapic_debug("dest=%x dest_mode=%x delivery_mode=%x " |
| 292 | "vector=%x trig_mode=%x\n", | 278 | "vector=%x trig_mode=%x\n", |
| 293 | entry->fields.dest_id, entry->fields.dest_mode, | 279 | entry->fields.dest_id, entry->fields.dest_mode, |
| @@ -310,6 +296,9 @@ static int ioapic_deliver(struct kvm_ioapic *ioapic, int irq, bool line_status) | |||
| 310 | } else | 296 | } else |
| 311 | ret = kvm_irq_delivery_to_apic(ioapic->kvm, NULL, &irqe, NULL); | 297 | ret = kvm_irq_delivery_to_apic(ioapic->kvm, NULL, &irqe, NULL); |
| 312 | 298 | ||
| 299 | if (ret && irqe.trig_mode == IOAPIC_LEVEL_TRIG) | ||
| 300 | entry->fields.remote_irr = 1; | ||
| 301 | |||
| 313 | return ret; | 302 | return ret; |
| 314 | } | 303 | } |
| 315 | 304 | ||
| @@ -393,7 +382,7 @@ static void __kvm_ioapic_update_eoi(struct kvm_vcpu *vcpu, | |||
| 393 | 382 | ||
| 394 | ASSERT(ent->fields.trig_mode == IOAPIC_LEVEL_TRIG); | 383 | ASSERT(ent->fields.trig_mode == IOAPIC_LEVEL_TRIG); |
| 395 | ent->fields.remote_irr = 0; | 384 | ent->fields.remote_irr = 0; |
| 396 | if (!ent->fields.mask && (ioapic->irr & (1 << i))) | 385 | if (ioapic->irr & (1 << i)) |
| 397 | ioapic_service(ioapic, i, false); | 386 | ioapic_service(ioapic, i, false); |
| 398 | } | 387 | } |
| 399 | } | 388 | } |
