From patchwork Tue May 8 12:06:56 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 157674 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 17D51B6FA0 for ; Tue, 8 May 2012 22:07:47 +1000 (EST) Received: from localhost ([::1]:47945 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SRjCi-0004fQ-PF for incoming@patchwork.ozlabs.org; Tue, 08 May 2012 08:07:44 -0400 Received: from eggs.gnu.org ([208.118.235.92]:36356) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SRjCX-0004fB-NF for qemu-devel@nongnu.org; Tue, 08 May 2012 08:07:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SRjC0-00069g-Jj for qemu-devel@nongnu.org; Tue, 08 May 2012 08:07:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:22030) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SRjC0-00069I-Bl for qemu-devel@nongnu.org; Tue, 08 May 2012 08:07:00 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q48C6waX027247 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 8 May 2012 08:06:58 -0400 Received: from rincewind.home.kraxel.org (ovpn-116-24.ams2.redhat.com [10.36.116.24]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q48C6vdt019961; Tue, 8 May 2012 08:06:57 -0400 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id 7EE48412BA; Tue, 8 May 2012 14:06:56 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 8 May 2012 14:06:56 +0200 Message-Id: <1336478816-32522-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: erik.rull@rdsoftware.de, Gerd Hoffmann Subject: [Qemu-devel] [PATCH] usb-host: handle guest-issued clear halt 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 Most important here is to update our internal endpoint state so we know the endpoint isn't in halted state any more. Without this usb-host tries to clear halt again with the next data transfer submitted. Doing this twice is (a) not correct and (b) confuses some usb devices, rendering them non-functional in the guest. Signed-off-by: Gerd Hoffmann --- hw/usb/host-linux.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/hw/usb/host-linux.c b/hw/usb/host-linux.c index bb08542..9094120 100644 --- a/hw/usb/host-linux.c +++ b/hw/usb/host-linux.c @@ -1101,6 +1101,15 @@ static int usb_host_handle_control(USBDevice *dev, USBPacket *p, ret = usb_host_set_interface(s, index, value); trace_usb_host_req_emulated(s->bus_num, s->addr, p, ret); return ret; + + case EndpointOutRequest | USB_REQ_CLEAR_FEATURE: + if (value == 0) { /* clear halt */ + int pid = (index & USB_DIR_IN) ? USB_TOKEN_IN : USB_TOKEN_OUT; + ioctl(s->fd, USBDEVFS_CLEAR_HALT, &index); + clear_halt(s, pid, index & 0x0f); + trace_usb_host_req_emulated(s->bus_num, s->addr, p, 0); + return 0; + } } /* The rest are asynchronous */