Lines Matching refs:pit
33 #define pr_fmt(fmt) "pit: " fmt
235 struct kvm_pit *pit = vcpu->kvm->arch.vpit;
237 if (pit && kvm_vcpu_is_bsp(vcpu) && pit->pit_state.irq_ack)
238 return atomic_read(&pit->pit_state.pit_timer.pending);
256 /* in this case, we had multiple outstanding pit interrupts
259 queue_work(ps->pit->wq, &ps->pit->expired);
266 struct kvm_pit *pit = vcpu->kvm->arch.vpit;
269 if (!kvm_vcpu_is_bsp(vcpu) || !pit)
272 timer = &pit->pit_state.pit_timer.timer;
277 static void destroy_pit_timer(struct kvm_pit *pit)
279 hrtimer_cancel(&pit->pit_state.pit_timer.timer);
280 cancel_work_sync(&pit->expired);
296 struct kvm_pit *pit = container_of(work, struct kvm_pit, expired);
297 struct kvm *kvm = pit->kvm;
300 struct kvm_kpit_state *ps = &pit->pit_state;
355 pr_debug("create pit timer, interval is %llu nsec\n", interval);
359 cancel_work_sync(&ps->pit->expired);
365 pt->kvm = ps->pit->kvm;
450 struct kvm_pit *pit = dev_to_pit(this);
451 struct kvm_kpit_state *pit_state = &pit->pit_state;
452 struct kvm *kvm = pit->kvm;
526 struct kvm_pit *pit = dev_to_pit(this);
527 struct kvm_kpit_state *pit_state = &pit->pit_state;
528 struct kvm *kvm = pit->kvm;
596 struct kvm_pit *pit = speaker_to_pit(this);
597 struct kvm_kpit_state *pit_state = &pit->pit_state;
598 struct kvm *kvm = pit->kvm;
613 struct kvm_pit *pit = speaker_to_pit(this);
614 struct kvm_kpit_state *pit_state = &pit->pit_state;
615 struct kvm *kvm = pit->kvm;
634 void kvm_pit_reset(struct kvm_pit *pit)
639 mutex_lock(&pit->pit_state.lock);
640 pit->pit_state.flags = 0;
642 c = &pit->pit_state.channels[i];
645 pit_load_count(pit->kvm, i, 0);
647 mutex_unlock(&pit->pit_state.lock);
649 atomic_set(&pit->pit_state.pit_timer.pending, 0);
650 pit->pit_state.irq_ack = 1;
655 struct kvm_pit *pit = container_of(kimn, struct kvm_pit, mask_notifier);
658 atomic_set(&pit->pit_state.pit_timer.pending, 0);
659 pit->pit_state.irq_ack = 1;
676 struct kvm_pit *pit;
680 pit = kzalloc(sizeof(struct kvm_pit), GFP_KERNEL);
681 if (!pit)
684 pit->irq_source_id = kvm_request_irq_source_id(kvm);
685 if (pit->irq_source_id < 0) {
686 kfree(pit);
690 mutex_init(&pit->pit_state.lock);
691 mutex_lock(&pit->pit_state.lock);
692 spin_lock_init(&pit->pit_state.inject_lock);
694 pit->wq = create_singlethread_workqueue("kvm-pit-wq");
695 if (!pit->wq) {
696 mutex_unlock(&pit->pit_state.lock);
697 kvm_free_irq_source_id(kvm, pit->irq_source_id);
698 kfree(pit);
701 INIT_WORK(&pit->expired, pit_do_work);
703 kvm->arch.vpit = pit;
704 pit->kvm = kvm;
706 pit_state = &pit->pit_state;
707 pit_state->pit = pit;
714 mutex_unlock(&pit->pit_state.lock);
716 kvm_pit_reset(pit);
718 pit->mask_notifier.func = pit_mask_notifer;
719 kvm_register_irq_mask_notifier(kvm, 0, &pit->mask_notifier);
721 kvm_iodevice_init(&pit->dev, &pit_dev_ops);
722 ret = kvm_io_bus_register_dev(kvm, KVM_PIO_BUS, &pit->dev);
727 kvm_iodevice_init(&pit->speaker_dev, &speaker_dev_ops);
729 &pit->speaker_dev);
734 return pit;
737 kvm_io_bus_unregister_dev(kvm, KVM_PIO_BUS, &pit->dev);
740 kvm_unregister_irq_mask_notifier(kvm, 0, &pit->mask_notifier);
742 kvm_free_irq_source_id(kvm, pit->irq_source_id);
743 destroy_workqueue(pit->wq);
744 kfree(pit);