KVM: Avoid needless registrations of IRQ ack notifier for assigned devices

We only perform work in kvm_assigned_dev_ack_irq if the guest IRQ is of
INTx type. This completely avoids the callback invocation in non-INTx
cases by registering the IRQ ack notifier only for INTx.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
This commit is contained in:
Jan Kiszka 2011-09-11 10:16:20 +02:00 committed by Avi Kivity
parent 9f9f6b7877
commit c61fa9d63b

View File

@ -86,13 +86,9 @@ static irqreturn_t kvm_assigned_dev_thread(int irq, void *dev_id)
/* Ack the irq line for an assigned device */ /* Ack the irq line for an assigned device */
static void kvm_assigned_dev_ack_irq(struct kvm_irq_ack_notifier *kian) static void kvm_assigned_dev_ack_irq(struct kvm_irq_ack_notifier *kian)
{ {
struct kvm_assigned_dev_kernel *dev; struct kvm_assigned_dev_kernel *dev =
container_of(kian, struct kvm_assigned_dev_kernel,
if (kian->gsi == -1) ack_notifier);
return;
dev = container_of(kian, struct kvm_assigned_dev_kernel,
ack_notifier);
kvm_set_irq(dev->kvm, dev->irq_source_id, dev->guest_irq, 0); kvm_set_irq(dev->kvm, dev->irq_source_id, dev->guest_irq, 0);
@ -110,8 +106,9 @@ static void kvm_assigned_dev_ack_irq(struct kvm_irq_ack_notifier *kian)
static void deassign_guest_irq(struct kvm *kvm, static void deassign_guest_irq(struct kvm *kvm,
struct kvm_assigned_dev_kernel *assigned_dev) struct kvm_assigned_dev_kernel *assigned_dev)
{ {
kvm_unregister_irq_ack_notifier(kvm, &assigned_dev->ack_notifier); if (assigned_dev->ack_notifier.gsi != -1)
assigned_dev->ack_notifier.gsi = -1; kvm_unregister_irq_ack_notifier(kvm,
&assigned_dev->ack_notifier);
kvm_set_irq(assigned_dev->kvm, assigned_dev->irq_source_id, kvm_set_irq(assigned_dev->kvm, assigned_dev->irq_source_id,
assigned_dev->guest_irq, 0); assigned_dev->guest_irq, 0);
@ -404,7 +401,8 @@ static int assign_guest_irq(struct kvm *kvm,
if (!r) { if (!r) {
dev->irq_requested_type |= guest_irq_type; dev->irq_requested_type |= guest_irq_type;
kvm_register_irq_ack_notifier(kvm, &dev->ack_notifier); if (dev->ack_notifier.gsi != -1)
kvm_register_irq_ack_notifier(kvm, &dev->ack_notifier);
} else } else
kvm_free_irq_source_id(kvm, dev->irq_source_id); kvm_free_irq_source_id(kvm, dev->irq_source_id);