qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Ogilvie <mmogilvi_qemu@miniinfo.net>
To: qemu-devel@nongnu.org
Cc: Gleb Natapov <gleb@redhat.com>, Jan Kiszka <jan.kiszka@web.de>,
	Matthew Ogilvie <mmogilvi_qemu@miniinfo.net>,
	kvm@vger.kernel.org, "Maciej W. Rozycki" <macro@linux-mips.org>
Subject: [Qemu-devel] [PATCH KVM v2 4/4] KVM: i8259: refactor pic_set_irq level logic
Date: Wed, 26 Dec 2012 22:39:56 -0700	[thread overview]
Message-ID: <1356586796-7631-5-git-send-email-mmogilvi_qemu@miniinfo.net> (raw)
In-Reply-To: <1356586796-7631-1-git-send-email-mmogilvi_qemu@miniinfo.net>

No change in functionality.

Clarify that the only difference between level triggered and
edge triggered interrupts is on the leading edge.

Signed-off-by: Matthew Ogilvie <mmogilvi_qemu@miniinfo.net>
---
 arch/x86/kvm/i8259.c | 28 +++++++++++-----------------
 1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/arch/x86/kvm/i8259.c b/arch/x86/kvm/i8259.c
index 76d8dc1..63f731b 100644
--- a/arch/x86/kvm/i8259.c
+++ b/arch/x86/kvm/i8259.c
@@ -95,26 +95,20 @@ static inline int pic_set_irq1(struct kvm_kpic_state *s, int irq, int level)
 {
 	int mask, ret = 1;
 	mask = 1 << irq;
-	if (s->elcr & mask)	/* level triggered */
-		if (level) {
+	if (level) {
+		if ((s->last_irr & mask) == 0 ||  /* edge for edge-triggered */
+		    (s->elcr & mask)) {           /* or level triggered */
 			ret = !(s->irr & mask);
 			s->irr |= mask;
-			s->last_irr |= mask;
-		} else {
-			s->irr &= ~mask;
-			s->last_irr &= ~mask;
-		}
-	else	/* edge triggered */
-		if (level) {
-			if ((s->last_irr & mask) == 0) {
-				ret = !(s->irr & mask);
-				s->irr |= mask;
-			}
-			s->last_irr |= mask;
-		} else {
-			s->irr &= ~mask;
-			s->last_irr &= ~mask;
 		}
+		s->last_irr |= mask;
+	} else {
+		/* Dropping level clears the interrupt regardless of edge
+		 * trigger vs level trigger.
+		 */
+		s->irr &= ~mask;
+		s->last_irr &= ~mask;
+	}
 
 	return (s->imr & mask) ? -1 : ret;
 }
-- 
1.7.10.2.484.gcd07cc5

  parent reply	other threads:[~2012-12-27  5:41 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-27  5:39 [Qemu-devel] [PATCH KVM v2 0/4] fix KVM i8259 IRQ trailing-edge logic Matthew Ogilvie
2012-12-27  5:39 ` [Qemu-devel] [PATCH KVM v2 1/4] KVM: fix i8254 IRQ0 to be normally high Matthew Ogilvie
2013-01-07  9:39   ` Gleb Natapov
2013-01-07 12:48     ` Gleb Natapov
2013-01-08  0:17     ` mmogilvi
2013-01-08  7:31       ` Gleb Natapov
2013-01-11  6:40         ` Matthew Ogilvie
2013-01-11 15:45           ` Gleb Natapov
2013-01-15  9:49             ` Matthew Ogilvie
2012-12-27  5:39 ` [Qemu-devel] [PATCH KVM v2 2/4] KVM: additional i8254 output fixes Matthew Ogilvie
2013-01-07 12:04   ` Gleb Natapov
2013-01-08  0:35     ` mmogilvi
2013-01-08  7:41       ` Gleb Natapov
2013-01-11  6:33         ` Matthew Ogilvie
2012-12-27  5:39 ` [Qemu-devel] [PATCH KVM v2 3/4] KVM: fix i8259 interrupt high to low transition logic Matthew Ogilvie
2012-12-27  5:39 ` Matthew Ogilvie [this message]
2013-01-06 15:54 ` [Qemu-devel] [PATCH KVM v2 0/4] fix KVM i8259 IRQ trailing-edge logic Gleb Natapov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1356586796-7631-5-git-send-email-mmogilvi_qemu@miniinfo.net \
    --to=mmogilvi_qemu@miniinfo.net \
    --cc=gleb@redhat.com \
    --cc=jan.kiszka@web.de \
    --cc=kvm@vger.kernel.org \
    --cc=macro@linux-mips.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).