From patchwork Fri Apr 22 10:44:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 8909521 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A89FF9F39A for ; Fri, 22 Apr 2016 10:45:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 129A220149 for ; Fri, 22 Apr 2016 10:45:19 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 51F7E20145 for ; Fri, 22 Apr 2016 10:45:18 +0000 (UTC) Received: from localhost ([::1]:59039 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1atYaL-0005lC-OZ for patchwork-qemu-devel@patchwork.kernel.org; Fri, 22 Apr 2016 06:45:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50510) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1atYaD-0005cH-48 for qemu-devel@nongnu.org; Fri, 22 Apr 2016 06:45:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1atYaA-0003f9-DD for qemu-devel@nongnu.org; Fri, 22 Apr 2016 06:45:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46306) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1atYaA-0003eM-8L for qemu-devel@nongnu.org; Fri, 22 Apr 2016 06:45:06 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C96F43DB; Fri, 22 Apr 2016 10:45:05 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-34.ams2.redhat.com [10.36.116.34]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3MAj45e012909; Fri, 22 Apr 2016 06:45:05 -0400 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 03A2081C63; Fri, 22 Apr 2016 12:45:03 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 22 Apr 2016 12:44:53 +0200 Message-Id: <1461321893-15811-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2.6 candidate] usb/uhci: move pid check X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Gerd Hoffmann Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP commit "5f77e06 usb: add pid check at the first of uhci_handle_td()" moved the pid verification to the start of the uhci_handle_td function, to simplify the error handling (we don't have to free stuff which we didn't allocate in the first place ...). Problem is now the check fires too often, it raises error IRQs even for TDs which we are not going to process because they are not set active. So, lets move down the check a bit, so it is done only for active TDs, but still before we are going to allocate stuff to process the requested transfer. Reported-by: Joe Clifford Tested-by: Joe Clifford Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-uhci.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c index 18057bf..ca72a80 100644 --- a/hw/usb/hcd-uhci.c +++ b/hw/usb/hcd-uhci.c @@ -776,19 +776,6 @@ static int uhci_handle_td(UHCIState *s, UHCIQueue *q, uint32_t qh_addr, uint8_t pid = td->token & 0xff; UHCIAsync *async; - switch (pid) { - case USB_TOKEN_OUT: - case USB_TOKEN_SETUP: - case USB_TOKEN_IN: - break; - default: - /* invalid pid : frame interrupted */ - s->status |= UHCI_STS_HCPERR; - s->cmd &= ~UHCI_CMD_RS; - uhci_update_irq(s); - return TD_RESULT_STOP_FRAME; - } - async = uhci_async_find_td(s, td_addr); if (async) { if (uhci_queue_verify(async->queue, qh_addr, td, td_addr, queuing)) { @@ -828,6 +815,19 @@ static int uhci_handle_td(UHCIState *s, UHCIQueue *q, uint32_t qh_addr, return TD_RESULT_NEXT_QH; } + switch (pid) { + case USB_TOKEN_OUT: + case USB_TOKEN_SETUP: + case USB_TOKEN_IN: + break; + default: + /* invalid pid : frame interrupted */ + s->status |= UHCI_STS_HCPERR; + s->cmd &= ~UHCI_CMD_RS; + uhci_update_irq(s); + return TD_RESULT_STOP_FRAME; + } + if (async) { if (queuing) { /* we are busy filling the queue, we are not prepared