From patchwork Thu May 26 10:44:12 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 97529 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 190DAB6F97 for ; Thu, 26 May 2011 20:46:49 +1000 (EST) Received: from localhost ([::1]:57960 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QPY5W-0005F5-6o for incoming@patchwork.ozlabs.org; Thu, 26 May 2011 06:46:46 -0400 Received: from eggs.gnu.org ([140.186.70.92]:53240) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QPY3q-00028u-FE for qemu-devel@nongnu.org; Thu, 26 May 2011 06:45:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QPY3p-0000sy-Jd for qemu-devel@nongnu.org; Thu, 26 May 2011 06:45:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38475) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QPY3p-0000se-Al for qemu-devel@nongnu.org; Thu, 26 May 2011 06:45:01 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p4QAj0p6000848 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 26 May 2011 06:45:00 -0400 Received: from rincewind.home.kraxel.org (vpn1-4-50.ams2.redhat.com [10.36.4.50]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p4QAicKD031300; Thu, 26 May 2011 06:44:56 -0400 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id F0BD0441C3; Thu, 26 May 2011 12:44:15 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 26 May 2011 12:44:12 +0200 Message-Id: <1306406654-19351-11-git-send-email-kraxel@redhat.com> In-Reply-To: <1306406654-19351-1-git-send-email-kraxel@redhat.com> References: <1306406654-19351-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 10/12] usb-ehci: fix error handling. 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 Set the correct bits for nodev, stall and babble errors. Raise errint irq. Fix state transition from WRITEBACK to the next state. Signed-off-by: Gerd Hoffmann --- hw/usb-ehci.c | 25 +++++++++++++++---------- 1 files changed, 15 insertions(+), 10 deletions(-) diff --git a/hw/usb-ehci.c b/hw/usb-ehci.c index cf10dfc..2bbb5e4 100644 --- a/hw/usb-ehci.c +++ b/hw/usb-ehci.c @@ -1114,10 +1114,10 @@ err: switch(q->usb_status) { case USB_RET_NODEV: - fprintf(stderr, "USB no device\n"); + q->qh.token |= (QTD_TOKEN_HALT | QTD_TOKEN_XACTERR); + ehci_record_interrupt(q->ehci, USBSTS_ERRINT); break; case USB_RET_STALL: - fprintf(stderr, "USB stall\n"); q->qh.token |= QTD_TOKEN_HALT; ehci_record_interrupt(q->ehci, USBSTS_ERRINT); break; @@ -1133,8 +1133,7 @@ err: } break; case USB_RET_BABBLE: - fprintf(stderr, "USB babble TODO\n"); - q->qh.token |= QTD_TOKEN_BABBLE; + q->qh.token |= (QTD_TOKEN_HALT | QTD_TOKEN_BABBLE); ehci_record_interrupt(q->ehci, USBSTS_ERRINT); break; default: @@ -1792,15 +1791,21 @@ static int ehci_state_writeback(EHCIQueue *q, int async) put_dwords(NLPTR_GET(q->qtdaddr),(uint32_t *) &q->qh.next_qtd, sizeof(EHCIqtd) >> 2); - /* TODO confirm next state. For now, keep going if async - * but stop after one qtd if periodic + /* + * EHCI specs say go horizontal here. + * + * We can also advance the queue here for performance reasons. We + * need to take care to only take that shortcut in case we've + * processed the qtd just written back without errors, i.e. halt + * bit is clear. */ - //if (async) { + if (q->qh.token & QTD_TOKEN_HALT) { + ehci_set_state(q->ehci, async, EST_HORIZONTALQH); + again = 1; + } else { ehci_set_state(q->ehci, async, EST_ADVANCEQUEUE); again = 1; - //} else { - // ehci_set_state(ehci, async, EST_ACTIVE); - //} + } return again; }