Commit fd700a00 authored by Radim Krčmář's avatar Radim Krčmář Committed by Paolo Bonzini

KVM: i8254: add kvm_pit_reset_reinject

pit_state.pending and pit_state.irq_ack are always reset at the same
time.  Create a function for them.
Signed-off-by: default avatarRadim Krčmář <rkrcmar@redhat.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent f6e0a0c1
...@@ -321,6 +321,12 @@ static enum hrtimer_restart pit_timer_fn(struct hrtimer *data) ...@@ -321,6 +321,12 @@ static enum hrtimer_restart pit_timer_fn(struct hrtimer *data)
return HRTIMER_NORESTART; return HRTIMER_NORESTART;
} }
static inline void kvm_pit_reset_reinject(struct kvm_pit *pit)
{
atomic_set(&pit->pit_state.pending, 0);
pit->pit_state.irq_ack = 1;
}
static void create_pit_timer(struct kvm *kvm, u32 val, int is_period) static void create_pit_timer(struct kvm *kvm, u32 val, int is_period)
{ {
struct kvm_kpit_state *ps = &kvm->arch.vpit->pit_state; struct kvm_kpit_state *ps = &kvm->arch.vpit->pit_state;
...@@ -343,8 +349,7 @@ static void create_pit_timer(struct kvm *kvm, u32 val, int is_period) ...@@ -343,8 +349,7 @@ static void create_pit_timer(struct kvm *kvm, u32 val, int is_period)
ps->timer.function = pit_timer_fn; ps->timer.function = pit_timer_fn;
ps->kvm = ps->pit->kvm; ps->kvm = ps->pit->kvm;
atomic_set(&ps->pending, 0); kvm_pit_reset_reinject(ps->pit);
ps->irq_ack = 1;
/* /*
* Do not allow the guest to program periodic timers with small * Do not allow the guest to program periodic timers with small
...@@ -644,18 +649,15 @@ void kvm_pit_reset(struct kvm_pit *pit) ...@@ -644,18 +649,15 @@ void kvm_pit_reset(struct kvm_pit *pit)
} }
mutex_unlock(&pit->pit_state.lock); mutex_unlock(&pit->pit_state.lock);
atomic_set(&pit->pit_state.pending, 0); kvm_pit_reset_reinject(pit);
pit->pit_state.irq_ack = 1;
} }
static void pit_mask_notifer(struct kvm_irq_mask_notifier *kimn, bool mask) static void pit_mask_notifer(struct kvm_irq_mask_notifier *kimn, bool mask)
{ {
struct kvm_pit *pit = container_of(kimn, struct kvm_pit, mask_notifier); struct kvm_pit *pit = container_of(kimn, struct kvm_pit, mask_notifier);
if (!mask) { if (!mask)
atomic_set(&pit->pit_state.pending, 0); kvm_pit_reset_reinject(pit);
pit->pit_state.irq_ack = 1;
}
} }
static const struct kvm_io_device_ops pit_dev_ops = { static const struct kvm_io_device_ops pit_dev_ops = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment