Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1348503

[PATCH v3 02/16] KVM: x86: simplify atomics in kvm_pit_ack_irq

From Radim Krčmář <radimkrcmar@hpx.cz>
Newsgroups linux.kernel
Subject [PATCH v3 02/16] KVM: x86: simplify atomics in kvm_pit_ack_irq
Date 2016-03-02 23:00 +0100
Message-ID <r8mYj-5A6-25@gated-at.bofh.it> (permalink)
References <r8mYj-5A6-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Radim Krčmář <rkrcmar@redhat.com>

We already have a helper that does the same thing.

Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
---
 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_notifier *kian)
 {
 	struct kvm_kpit_state *ps = container_of(kian, struct kvm_kpit_state,
 						 irq_ack_notifier);
-	int value;
 
 	spin_lock(&ps->inject_lock);
-	value = 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 = 1;
 	spin_unlock(&ps->inject_lock);
-- 
2.7.2

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH v3 02/16] KVM: x86: simplify atomics in kvm_pit_ack_irq Radim Krčmář <radimkrcmar@hpx.cz> - 2016-03-02 23:00 +0100

csiph-web