From 63dd5f3cfa81b090b906da952e2c43de5e9cc19f Mon Sep 17 00:00:00 2001
From: Marcelo Tosatti <mtosatti@redhat.com>
Date: Tue, 11 May 2010 00:20:15 -0300
Subject: [PATCH 5/8] UHCI spurious interrupt fix

RH-Author: Marcelo Tosatti <mtosatti@redhat.com>
Message-id: <20100511002138.008344832@amt.cnet>
Patchwork-id: 9143
O-Subject: [RHEL6 qemu-kvm patch 06/16] UHCI spurious interrupt fix
Bugzilla:
RH-Acked-by: Glauber Costa <glommer@redhat.com>
RH-Acked-by: Amit Shah <amit.shah@redhat.com>
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Bugzilla-related: 590922

commit 804b6ab08d82adcab05d64362be91c48a7467fd4
From: Paul Brook <paul@codesourcery.com>

UHCI spurious interrupt fix

Only raise an interrupt if the TD has actually completed.

Signed-off-by: Paul Brook <paul@codesourcery.com>
Bugzilla: 590922
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 hw/usb-uhci.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/hw/usb-uhci.c b/hw/usb-uhci.c
index dc52737..cfd77eb 100644
--- a/hw/usb-uhci.c
+++ b/hw/usb-uhci.c
@@ -677,9 +677,6 @@ static int uhci_complete_td(UHCIState *s, UHCI_TD *td, UHCIAsync *async, uint32_
 
     ret = async->packet.len;
 
-    if (td->ctrl & TD_CTRL_IOC)
-        *int_mask |= 0x01;
-
     if (td->ctrl & TD_CTRL_IOS)
         td->ctrl &= ~TD_CTRL_ACTIVE;
 
@@ -693,6 +690,8 @@ static int uhci_complete_td(UHCIState *s, UHCI_TD *td, UHCIAsync *async, uint32_
        here.  The docs are somewhat unclear, but win2k relies on this
        behavior.  */
     td->ctrl &= ~(TD_CTRL_ACTIVE | TD_CTRL_NAK);
+    if (td->ctrl & TD_CTRL_IOC)
+        *int_mask |= 0x01;
 
     if (pid == USB_TOKEN_IN) {
         if (len > max_len) {
@@ -750,6 +749,8 @@ out:
         if (err == 0) {
             td->ctrl &= ~TD_CTRL_ACTIVE;
             s->status |= UHCI_STS_USBERR;
+            if (td->ctrl & TD_CTRL_IOC)
+                *int_mask |= 0x01;
             uhci_update_irq(s);
         }
     }
-- 
1.7.0.3

