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>
This commit is contained in:
parent
36c9549460
commit
0b10a1c87a
|
@ -50,7 +50,7 @@
|
||||||
#else
|
#else
|
||||||
#define ioapic_debug(fmt, arg...)
|
#define ioapic_debug(fmt, arg...)
|
||||||
#endif
|
#endif
|
||||||
static int ioapic_deliver(struct kvm_ioapic *vioapic, int irq,
|
static int ioapic_service(struct kvm_ioapic *vioapic, int irq,
|
||||||
bool line_status);
|
bool line_status);
|
||||||
|
|
||||||
static unsigned long ioapic_read_indirect(struct kvm_ioapic *ioapic,
|
static unsigned long ioapic_read_indirect(struct kvm_ioapic *ioapic,
|
||||||
|
@ -163,23 +163,6 @@ static bool rtc_irq_check_coalesced(struct kvm_ioapic *ioapic)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ioapic_service(struct kvm_ioapic *ioapic, unsigned int idx,
|
|
||||||
bool line_status)
|
|
||||||
{
|
|
||||||
union kvm_ioapic_redirect_entry *pent;
|
|
||||||
int injected = -1;
|
|
||||||
|
|
||||||
pent = &ioapic->redirtbl[idx];
|
|
||||||
|
|
||||||
if (!pent->fields.mask) {
|
|
||||||
injected = ioapic_deliver(ioapic, idx, line_status);
|
|
||||||
if (injected && pent->fields.trig_mode == IOAPIC_LEVEL_TRIG)
|
|
||||||
pent->fields.remote_irr = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return injected;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void update_handled_vectors(struct kvm_ioapic *ioapic)
|
static void update_handled_vectors(struct kvm_ioapic *ioapic)
|
||||||
{
|
{
|
||||||
DECLARE_BITMAP(handled_vectors, 256);
|
DECLARE_BITMAP(handled_vectors, 256);
|
||||||
|
@ -282,12 +265,15 @@ static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ioapic_deliver(struct kvm_ioapic *ioapic, int irq, bool line_status)
|
static int ioapic_service(struct kvm_ioapic *ioapic, int irq, bool line_status)
|
||||||
{
|
{
|
||||||
union kvm_ioapic_redirect_entry *entry = &ioapic->redirtbl[irq];
|
union kvm_ioapic_redirect_entry *entry = &ioapic->redirtbl[irq];
|
||||||
struct kvm_lapic_irq irqe;
|
struct kvm_lapic_irq irqe;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (entry->fields.mask)
|
||||||
|
return -1;
|
||||||
|
|
||||||
ioapic_debug("dest=%x dest_mode=%x delivery_mode=%x "
|
ioapic_debug("dest=%x dest_mode=%x delivery_mode=%x "
|
||||||
"vector=%x trig_mode=%x\n",
|
"vector=%x trig_mode=%x\n",
|
||||||
entry->fields.dest_id, entry->fields.dest_mode,
|
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)
|
||||||
} else
|
} else
|
||||||
ret = kvm_irq_delivery_to_apic(ioapic->kvm, NULL, &irqe, NULL);
|
ret = kvm_irq_delivery_to_apic(ioapic->kvm, NULL, &irqe, NULL);
|
||||||
|
|
||||||
|
if (ret && irqe.trig_mode == IOAPIC_LEVEL_TRIG)
|
||||||
|
entry->fields.remote_irr = 1;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,7 +382,7 @@ static void __kvm_ioapic_update_eoi(struct kvm_vcpu *vcpu,
|
||||||
|
|
||||||
ASSERT(ent->fields.trig_mode == IOAPIC_LEVEL_TRIG);
|
ASSERT(ent->fields.trig_mode == IOAPIC_LEVEL_TRIG);
|
||||||
ent->fields.remote_irr = 0;
|
ent->fields.remote_irr = 0;
|
||||||
if (!ent->fields.mask && (ioapic->irr & (1 << i)))
|
if (ioapic->irr & (1 << i))
|
||||||
ioapic_service(ioapic, i, false);
|
ioapic_service(ioapic, i, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue