Skip to content

Commit

Permalink
kvm/eventfd: factor out kvm_notify_acked_gsi()
Browse files Browse the repository at this point in the history
Factor out kvm_notify_acked_gsi() helper to iterate over EOI listeners
and notify those matching the given gsi.

It will be reused in the upcoming Hyper-V SynIC implementation.

Signed-off-by: Andrey Smetanin <[email protected]>
Reviewed-by: Roman Kagan <[email protected]>
Signed-off-by: Denis V. Lunev <[email protected]>
CC: Vitaly Kuznetsov <[email protected]>
CC: "K. Y. Srinivasan" <[email protected]>
CC: Gleb Natapov <[email protected]>
CC: Paolo Bonzini <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
Andrey Smetanin authored and bonzini committed Oct 16, 2015
1 parent 351dc64 commit ba1aefc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions include/linux/kvm_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,7 @@ int kvm_set_irq_inatomic(struct kvm *kvm, int irq_source_id, u32 irq, int level)
int kvm_set_msi(struct kvm_kernel_irq_routing_entry *irq_entry, struct kvm *kvm,
int irq_source_id, int level, bool line_status);
bool kvm_irq_has_notifier(struct kvm *kvm, unsigned irqchip, unsigned pin);
void kvm_notify_acked_gsi(struct kvm *kvm, int gsi);
void kvm_notify_acked_irq(struct kvm *kvm, unsigned irqchip, unsigned pin);
void kvm_register_irq_ack_notifier(struct kvm *kvm,
struct kvm_irq_ack_notifier *kian);
Expand Down
16 changes: 11 additions & 5 deletions virt/kvm/eventfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,20 +451,26 @@ bool kvm_irq_has_notifier(struct kvm *kvm, unsigned irqchip, unsigned pin)
}
EXPORT_SYMBOL_GPL(kvm_irq_has_notifier);

void kvm_notify_acked_irq(struct kvm *kvm, unsigned irqchip, unsigned pin)
void kvm_notify_acked_gsi(struct kvm *kvm, int gsi)
{
struct kvm_irq_ack_notifier *kian;

hlist_for_each_entry_rcu(kian, &kvm->irq_ack_notifier_list,
link)
if (kian->gsi == gsi)
kian->irq_acked(kian);
}

void kvm_notify_acked_irq(struct kvm *kvm, unsigned irqchip, unsigned pin)
{
int gsi, idx;

trace_kvm_ack_irq(irqchip, pin);

idx = srcu_read_lock(&kvm->irq_srcu);
gsi = kvm_irq_map_chip_pin(kvm, irqchip, pin);
if (gsi != -1)
hlist_for_each_entry_rcu(kian, &kvm->irq_ack_notifier_list,
link)
if (kian->gsi == gsi)
kian->irq_acked(kian);
kvm_notify_acked_gsi(kvm, gsi);
srcu_read_unlock(&kvm->irq_srcu, idx);
}

Expand Down

0 comments on commit ba1aefc

Please sign in to comment.