From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Subject: [PATCH v2 02/14] KVM: x86: simplify atomics in kvm_pit_ack_irq Date: Wed, 17 Feb 2016 20:14:44 +0100 Message-ID: <1455736496-374-3-git-send-email-rkrcmar@redhat.com> References: <1455736496-374-1-git-send-email-rkrcmar@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: kvm@vger.kernel.org, Paolo Bonzini , Yuki Shibuya To: linux-kernel@vger.kernel.org Return-path: In-Reply-To: <1455736496-374-1-git-send-email-rkrcmar@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org We already have a helper that does the same thing. Signed-off-by: Radim Kr=C4=8Dm=C3=A1=C5=99 --- v2: The pending =3D=3D 1 means there's only us =3D> don't reinject. arch/x86/kvm/i8254.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c index ab5318727579..7d694ac7f4a4 100644 --- a/arch/x86/kvm/i8254.c +++ b/arch/x86/kvm/i8254.c @@ -236,19 +236,9 @@ static void kvm_pit_ack_irq(struct kvm_irq_ack_not= ifier *kian) { struct kvm_kpit_state *ps =3D container_of(kian, struct kvm_kpit_stat= e, irq_ack_notifier); - int value; =20 spin_lock(&ps->inject_lock); - value =3D atomic_dec_return(&ps->pending); - 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 - */ + if (atomic_dec_if_positive(&ps->pending) > 0 && ps->reinject) queue_kthread_work(&ps->pit->worker, &ps->pit->expired); ps->irq_ack =3D 1; spin_unlock(&ps->inject_lock); --=20 2.7.1