From patchwork Mon Oct 15 10:38:16 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: 191523 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2C1832C00A8 for ; Mon, 15 Oct 2012 22:07:10 +1100 (EST) Received: from localhost ([::1]:58388 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TNi4Z-000715-9s for incoming@patchwork.ozlabs.org; Mon, 15 Oct 2012 06:38:59 -0400 Received: from eggs.gnu.org ([208.118.235.92]:43980) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TNi3r-0005PH-CO for qemu-devel@nongnu.org; Mon, 15 Oct 2012 06:38:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TNi3n-0003re-80 for qemu-devel@nongnu.org; Mon, 15 Oct 2012 06:38:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:22759) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TNi3m-0003rT-W8 for qemu-devel@nongnu.org; Mon, 15 Oct 2012 06:38:11 -0400 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 q9FAcAj5020587 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 15 Oct 2012 06:38:10 -0400 Received: from localhost.localdomain.com (vpn1-5-26.ams2.redhat.com [10.36.5.26]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q9FAc0EV008943; Mon, 15 Oct 2012 06:38:09 -0400 From: Hans de Goede To: qemu-devel@nongnu.org Date: Mon, 15 Oct 2012 12:38:16 +0200 Message-Id: <1350297511-25437-8-git-send-email-hdegoede@redhat.com> In-Reply-To: <1350297511-25437-1-git-send-email-hdegoede@redhat.com> References: <1350297511-25437-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 , Gerd Hoffmann Subject: [Qemu-devel] [PATCH 07/22] ehci: Detect going in circles when filling the queue 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 For ctrl endpoints Windows (atleast Win7) creates circular td lists, so far these were not a problem because we would stop filling the queue if altnext was set. Since further patches in this patchset remove the altnext check this does become a problem and we need detection for going in circles. Signed-off-by: Hans de Goede --- hw/usb/hcd-ehci.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c index 58e788b..79a9ad5 100644 --- a/hw/usb/hcd-ehci.c +++ b/hw/usb/hcd-ehci.c @@ -2072,7 +2072,7 @@ static int ehci_fill_queue(EHCIPacket *p) { EHCIQueue *q = p->queue; EHCIqtd qtd = p->qtd; - uint32_t qtdaddr; + uint32_t qtdaddr, start_addr = p->qtdaddr; for (;;) { if (NLPTR_TBIT(qtd.altnext) == 0) { @@ -2082,6 +2082,13 @@ static int ehci_fill_queue(EHCIPacket *p) break; } qtdaddr = qtd.next; + /* + * Detect circular td lists, Windows creates these, counting on the + * active bit going low after exection to make the queue stop. + */ + if (qtdaddr == start_addr) { + break; + } get_dwords(q->ehci, NLPTR_GET(qtdaddr), (uint32_t *) &qtd, sizeof(EHCIqtd) >> 2); ehci_trace_qtd(q, NLPTR_GET(qtdaddr), &qtd);