i8254.c (faa3d77749ad30d2e1c48e2e4363b9c4889aca27) i8254.c (e9d90d472da97e1b1560bffb89578ba082c88a69)
1/*
2 * 8253/8254 interval timer emulation
3 *
4 * Copyright (c) 2003-2004 Fabrice Bellard
5 * Copyright (c) 2006 Intel Corporation
6 * Copyright (c) 2007 Keir Fraser, XenSource Inc
7 * Copyright (c) 2008 Intel Corporation
8 * Copyright 2009 Red Hat, Inc. and/or its affiliates.

--- 258 unchanged lines hidden (view full) ---

267}
268
269static void destroy_pit_timer(struct kvm_pit *pit)
270{
271 hrtimer_cancel(&pit->pit_state.pit_timer.timer);
272 flush_kthread_work(&pit->expired);
273}
274
1/*
2 * 8253/8254 interval timer emulation
3 *
4 * Copyright (c) 2003-2004 Fabrice Bellard
5 * Copyright (c) 2006 Intel Corporation
6 * Copyright (c) 2007 Keir Fraser, XenSource Inc
7 * Copyright (c) 2008 Intel Corporation
8 * Copyright 2009 Red Hat, Inc. and/or its affiliates.

--- 258 unchanged lines hidden (view full) ---

267}
268
269static void destroy_pit_timer(struct kvm_pit *pit)
270{
271 hrtimer_cancel(&pit->pit_state.pit_timer.timer);
272 flush_kthread_work(&pit->expired);
273}
274
275static bool kpit_is_periodic(struct kvm_timer *ktimer)
275static bool kpit_is_periodic(struct kvm_pit_timer *ktimer)
276{
277 struct kvm_kpit_state *ps = container_of(ktimer, struct kvm_kpit_state,
278 pit_timer);
279 return ps->is_periodic;
280}
281
276{
277 struct kvm_kpit_state *ps = container_of(ktimer, struct kvm_kpit_state,
278 pit_timer);
279 return ps->is_periodic;
280}
281
282static struct kvm_timer_ops kpit_ops = {
282static struct kvm_pit_timer_ops kpit_ops = {
283 .is_periodic = kpit_is_periodic,
284};
285
286static void pit_do_work(struct kthread_work *work)
287{
288 struct kvm_pit *pit = container_of(work, struct kvm_pit, expired);
289 struct kvm *kvm = pit->kvm;
290 struct kvm_vcpu *vcpu;

--- 26 unchanged lines hidden (view full) ---

317 if (kvm->arch.vapics_in_nmi_mode > 0)
318 kvm_for_each_vcpu(i, vcpu, kvm)
319 kvm_apic_nmi_wd_deliver(vcpu);
320 }
321}
322
323static enum hrtimer_restart pit_timer_fn(struct hrtimer *data)
324{
283 .is_periodic = kpit_is_periodic,
284};
285
286static void pit_do_work(struct kthread_work *work)
287{
288 struct kvm_pit *pit = container_of(work, struct kvm_pit, expired);
289 struct kvm *kvm = pit->kvm;
290 struct kvm_vcpu *vcpu;

--- 26 unchanged lines hidden (view full) ---

317 if (kvm->arch.vapics_in_nmi_mode > 0)
318 kvm_for_each_vcpu(i, vcpu, kvm)
319 kvm_apic_nmi_wd_deliver(vcpu);
320 }
321}
322
323static enum hrtimer_restart pit_timer_fn(struct hrtimer *data)
324{
325 struct kvm_timer *ktimer = container_of(data, struct kvm_timer, timer);
325 struct kvm_pit_timer *ktimer = container_of(data, struct kvm_pit_timer, timer);
326 struct kvm_pit *pt = ktimer->kvm->arch.vpit;
327
328 if (ktimer->reinject || !atomic_read(&ktimer->pending)) {
329 atomic_inc(&ktimer->pending);
330 queue_kthread_work(&pt->worker, &pt->expired);
331 }
332
333 if (ktimer->t_ops->is_periodic(ktimer)) {
334 hrtimer_add_expires_ns(&ktimer->timer, ktimer->period);
335 return HRTIMER_RESTART;
336 } else
337 return HRTIMER_NORESTART;
338}
339
340static void create_pit_timer(struct kvm *kvm, u32 val, int is_period)
341{
342 struct kvm_kpit_state *ps = &kvm->arch.vpit->pit_state;
326 struct kvm_pit *pt = ktimer->kvm->arch.vpit;
327
328 if (ktimer->reinject || !atomic_read(&ktimer->pending)) {
329 atomic_inc(&ktimer->pending);
330 queue_kthread_work(&pt->worker, &pt->expired);
331 }
332
333 if (ktimer->t_ops->is_periodic(ktimer)) {
334 hrtimer_add_expires_ns(&ktimer->timer, ktimer->period);
335 return HRTIMER_RESTART;
336 } else
337 return HRTIMER_NORESTART;
338}
339
340static void create_pit_timer(struct kvm *kvm, u32 val, int is_period)
341{
342 struct kvm_kpit_state *ps = &kvm->arch.vpit->pit_state;
343 struct kvm_timer *pt = &ps->pit_timer;
343 struct kvm_pit_timer *pt = &ps->pit_timer;
344 s64 interval;
345
346 if (!irqchip_in_kernel(kvm) || ps->flags & KVM_PIT_FLAGS_HPET_LEGACY)
347 return;
348
349 interval = muldiv64(val, NSEC_PER_SEC, KVM_PIT_FREQ);
350
351 pr_debug("create pit timer, interval is %llu nsec\n", interval);

--- 421 unchanged lines hidden ---
344 s64 interval;
345
346 if (!irqchip_in_kernel(kvm) || ps->flags & KVM_PIT_FLAGS_HPET_LEGACY)
347 return;
348
349 interval = muldiv64(val, NSEC_PER_SEC, KVM_PIT_FREQ);
350
351 pr_debug("create pit timer, interval is %llu nsec\n", interval);

--- 421 unchanged lines hidden ---