diff options
Diffstat (limited to 'virt/kvm/eventfd.c')
-rw-r--r-- | virt/kvm/eventfd.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c index a9d3fc6c681c..7016319b1ec0 100644 --- a/virt/kvm/eventfd.c +++ b/virt/kvm/eventfd.c | |||
@@ -47,7 +47,6 @@ struct _irqfd { | |||
47 | int gsi; | 47 | int gsi; |
48 | struct list_head list; | 48 | struct list_head list; |
49 | poll_table pt; | 49 | poll_table pt; |
50 | wait_queue_head_t *wqh; | ||
51 | wait_queue_t wait; | 50 | wait_queue_t wait; |
52 | struct work_struct inject; | 51 | struct work_struct inject; |
53 | struct work_struct shutdown; | 52 | struct work_struct shutdown; |
@@ -159,8 +158,6 @@ irqfd_ptable_queue_proc(struct file *file, wait_queue_head_t *wqh, | |||
159 | poll_table *pt) | 158 | poll_table *pt) |
160 | { | 159 | { |
161 | struct _irqfd *irqfd = container_of(pt, struct _irqfd, pt); | 160 | struct _irqfd *irqfd = container_of(pt, struct _irqfd, pt); |
162 | |||
163 | irqfd->wqh = wqh; | ||
164 | add_wait_queue(wqh, &irqfd->wait); | 161 | add_wait_queue(wqh, &irqfd->wait); |
165 | } | 162 | } |
166 | 163 | ||
@@ -463,7 +460,7 @@ static int | |||
463 | kvm_assign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args) | 460 | kvm_assign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args) |
464 | { | 461 | { |
465 | int pio = args->flags & KVM_IOEVENTFD_FLAG_PIO; | 462 | int pio = args->flags & KVM_IOEVENTFD_FLAG_PIO; |
466 | struct kvm_io_bus *bus = pio ? &kvm->pio_bus : &kvm->mmio_bus; | 463 | enum kvm_bus bus_idx = pio ? KVM_PIO_BUS : KVM_MMIO_BUS; |
467 | struct _ioeventfd *p; | 464 | struct _ioeventfd *p; |
468 | struct eventfd_ctx *eventfd; | 465 | struct eventfd_ctx *eventfd; |
469 | int ret; | 466 | int ret; |
@@ -508,7 +505,7 @@ kvm_assign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args) | |||
508 | else | 505 | else |
509 | p->wildcard = true; | 506 | p->wildcard = true; |
510 | 507 | ||
511 | down_write(&kvm->slots_lock); | 508 | mutex_lock(&kvm->slots_lock); |
512 | 509 | ||
513 | /* Verify that there isnt a match already */ | 510 | /* Verify that there isnt a match already */ |
514 | if (ioeventfd_check_collision(kvm, p)) { | 511 | if (ioeventfd_check_collision(kvm, p)) { |
@@ -518,18 +515,18 @@ kvm_assign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args) | |||
518 | 515 | ||
519 | kvm_iodevice_init(&p->dev, &ioeventfd_ops); | 516 | kvm_iodevice_init(&p->dev, &ioeventfd_ops); |
520 | 517 | ||
521 | ret = __kvm_io_bus_register_dev(bus, &p->dev); | 518 | ret = kvm_io_bus_register_dev(kvm, bus_idx, &p->dev); |
522 | if (ret < 0) | 519 | if (ret < 0) |
523 | goto unlock_fail; | 520 | goto unlock_fail; |
524 | 521 | ||
525 | list_add_tail(&p->list, &kvm->ioeventfds); | 522 | list_add_tail(&p->list, &kvm->ioeventfds); |
526 | 523 | ||
527 | up_write(&kvm->slots_lock); | 524 | mutex_unlock(&kvm->slots_lock); |
528 | 525 | ||
529 | return 0; | 526 | return 0; |
530 | 527 | ||
531 | unlock_fail: | 528 | unlock_fail: |
532 | up_write(&kvm->slots_lock); | 529 | mutex_unlock(&kvm->slots_lock); |
533 | 530 | ||
534 | fail: | 531 | fail: |
535 | kfree(p); | 532 | kfree(p); |
@@ -542,7 +539,7 @@ static int | |||
542 | kvm_deassign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args) | 539 | kvm_deassign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args) |
543 | { | 540 | { |
544 | int pio = args->flags & KVM_IOEVENTFD_FLAG_PIO; | 541 | int pio = args->flags & KVM_IOEVENTFD_FLAG_PIO; |
545 | struct kvm_io_bus *bus = pio ? &kvm->pio_bus : &kvm->mmio_bus; | 542 | enum kvm_bus bus_idx = pio ? KVM_PIO_BUS : KVM_MMIO_BUS; |
546 | struct _ioeventfd *p, *tmp; | 543 | struct _ioeventfd *p, *tmp; |
547 | struct eventfd_ctx *eventfd; | 544 | struct eventfd_ctx *eventfd; |
548 | int ret = -ENOENT; | 545 | int ret = -ENOENT; |
@@ -551,7 +548,7 @@ kvm_deassign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args) | |||
551 | if (IS_ERR(eventfd)) | 548 | if (IS_ERR(eventfd)) |
552 | return PTR_ERR(eventfd); | 549 | return PTR_ERR(eventfd); |
553 | 550 | ||
554 | down_write(&kvm->slots_lock); | 551 | mutex_lock(&kvm->slots_lock); |
555 | 552 | ||
556 | list_for_each_entry_safe(p, tmp, &kvm->ioeventfds, list) { | 553 | list_for_each_entry_safe(p, tmp, &kvm->ioeventfds, list) { |
557 | bool wildcard = !(args->flags & KVM_IOEVENTFD_FLAG_DATAMATCH); | 554 | bool wildcard = !(args->flags & KVM_IOEVENTFD_FLAG_DATAMATCH); |
@@ -565,13 +562,13 @@ kvm_deassign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args) | |||
565 | if (!p->wildcard && p->datamatch != args->datamatch) | 562 | if (!p->wildcard && p->datamatch != args->datamatch) |
566 | continue; | 563 | continue; |
567 | 564 | ||
568 | __kvm_io_bus_unregister_dev(bus, &p->dev); | 565 | kvm_io_bus_unregister_dev(kvm, bus_idx, &p->dev); |
569 | ioeventfd_release(p); | 566 | ioeventfd_release(p); |
570 | ret = 0; | 567 | ret = 0; |
571 | break; | 568 | break; |
572 | } | 569 | } |
573 | 570 | ||
574 | up_write(&kvm->slots_lock); | 571 | mutex_unlock(&kvm->slots_lock); |
575 | 572 | ||
576 | eventfd_ctx_put(eventfd); | 573 | eventfd_ctx_put(eventfd); |
577 | 574 | ||