From patchwork Sun Feb 26 15:14:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 143094 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 82AB2B6F98 for ; Mon, 27 Feb 2012 02:14:06 +1100 (EST) Received: from localhost ([::1]:52864 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S1fnW-0001rg-Hs for incoming@patchwork.ozlabs.org; Sun, 26 Feb 2012 10:14:02 -0500 Received: from eggs.gnu.org ([208.118.235.92]:33831) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S1fmk-00082y-OI for qemu-devel@nongnu.org; Sun, 26 Feb 2012 10:13:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S1fmj-0001s1-Gq for qemu-devel@nongnu.org; Sun, 26 Feb 2012 10:13:14 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52378) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S1fmj-0001rt-9k for qemu-devel@nongnu.org; Sun, 26 Feb 2012 10:13:13 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q1QFDCTv022200 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 26 Feb 2012 10:13:12 -0500 Received: from shalem.localdomain.com (vpn1-7-62.ams2.redhat.com [10.36.7.62]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q1QFD4Gf005987; Sun, 26 Feb 2012 10:13:11 -0500 From: Hans de Goede To: Gerd Hoffmann Date: Sun, 26 Feb 2012 16:14:48 +0100 Message-Id: <1330269288-5578-6-git-send-email-hdegoede@redhat.com> In-Reply-To: <1330269288-5578-1-git-send-email-hdegoede@redhat.com> References: <1330269288-5578-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Hans de Goede , qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 6/6] usb-ehci: Handle ISO packets failing with an error other then NAK X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Before this patch the ehci code was not checking for any other errors other then USB_RET_NAK. This causes 2 problems: 1) Other errors are not reported to the guest. 2) When transactions with the ITD_XACT_IOC bit set completing with another error would not result in USBSTS_INT getting set. I hit this problem when unplugging devices while iso data was streaming from the device to the guest. When this happens it takes a while for the guest to process the unplugging and remove ISO transactions from the ehci schedule, in the mean time these transactions would complete with a result of USB_RET_NODEV, which was not handled. This lead to the Linux guest's usb subsystem "hanging", that is it would no longer see new usb devices getting plugged in and running for example lsusb would lead to a stuck (D state) lsusb process. This patch fixes this. Signed-off-by: Hans de Goede --- hw/usb-ehci.c | 22 +++++++++++++++++++--- 1 files changed, 19 insertions(+), 3 deletions(-) diff --git a/hw/usb-ehci.c b/hw/usb-ehci.c index 69bcc4b..a6b6ae5 100644 --- a/hw/usb-ehci.c +++ b/hw/usb-ehci.c @@ -1512,11 +1512,27 @@ static int ehci_process_itd(EHCIState *ehci, /* IN */ set_field(&itd->transact[i], ret, ITD_XACT_LENGTH); } - - if (itd->transact[i] & ITD_XACT_IOC) { - ehci_record_interrupt(ehci, USBSTS_INT); + } else { + switch (ret) { + default: + fprintf(stderr, "Unexpected iso usb result: %d\n", ret); + /* Fall through */ + case USB_RET_NODEV: + /* 3.3.2: XACTERR is only allowed on IN transactions */ + if (dir) { + itd->transact[i] |= ITD_XACT_XACTERR; + ehci_record_interrupt(ehci, USBSTS_ERRINT); + } + break; + case USB_RET_BABBLE: + itd->transact[i] |= ITD_XACT_BABBLE; + ehci_record_interrupt(ehci, USBSTS_ERRINT); + break; } } + if (itd->transact[i] & ITD_XACT_IOC) { + ehci_record_interrupt(ehci, USBSTS_INT); + } itd->transact[i] &= ~ITD_XACT_ACTIVE; } }