KVM: i8254: simplify atomics in kvm_pit_ack_irq
We already have a helper that does the same thing. Signed-off-by: Radim Krčmář <rkrcmar@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
7dd0fdff14
commit
f6e0a0c113
|
@ -236,19 +236,9 @@ static void kvm_pit_ack_irq(struct kvm_irq_ack_notifier *kian)
|
||||||
{
|
{
|
||||||
struct kvm_kpit_state *ps = container_of(kian, struct kvm_kpit_state,
|
struct kvm_kpit_state *ps = container_of(kian, struct kvm_kpit_state,
|
||||||
irq_ack_notifier);
|
irq_ack_notifier);
|
||||||
int value;
|
|
||||||
|
|
||||||
spin_lock(&ps->inject_lock);
|
spin_lock(&ps->inject_lock);
|
||||||
value = atomic_dec_return(&ps->pending);
|
if (atomic_dec_if_positive(&ps->pending) > 0 && ps->reinject)
|
||||||
if (value < 0)
|
|
||||||
/* spurious acks can be generated if, for example, the
|
|
||||||
* PIC is being reset. Handle it gracefully here
|
|
||||||
*/
|
|
||||||
atomic_inc(&ps->pending);
|
|
||||||
else if (value > 0 && ps->reinject)
|
|
||||||
/* in this case, we had multiple outstanding pit interrupts
|
|
||||||
* that we needed to inject. Reinject
|
|
||||||
*/
|
|
||||||
queue_kthread_work(&ps->pit->worker, &ps->pit->expired);
|
queue_kthread_work(&ps->pit->worker, &ps->pit->expired);
|
||||||
ps->irq_ack = 1;
|
ps->irq_ack = 1;
|
||||||
spin_unlock(&ps->inject_lock);
|
spin_unlock(&ps->inject_lock);
|
||||||
|
|
Loading…
Reference in New Issue