From patchwork Mon Nov 21 16:15:46 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 126827 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 1393AB71E9 for ; Tue, 22 Nov 2011 03:32:21 +1100 (EST) Received: from localhost ([::1]:59111 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RSWn4-0006F8-1H for incoming@patchwork.ozlabs.org; Mon, 21 Nov 2011 11:32:18 -0500 Received: from eggs.gnu.org ([140.186.70.92]:57452) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RSWmt-0005zB-0O for qemu-devel@nongnu.org; Mon, 21 Nov 2011 11:32:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RSWmp-0007YT-2G for qemu-devel@nongnu.org; Mon, 21 Nov 2011 11:32:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:25078) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RSWmo-0007YC-OJ for qemu-devel@nongnu.org; Mon, 21 Nov 2011 11:32:03 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pALGW1hp004643 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 21 Nov 2011 11:32:01 -0500 Received: from rincewind.home.kraxel.org (ovpn-116-20.ams2.redhat.com [10.36.116.20]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id pALGW0Z6020018; Mon, 21 Nov 2011 11:32:00 -0500 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id 14B0D405CE; Mon, 21 Nov 2011 17:15:48 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 21 Nov 2011 17:15:46 +0100 Message-Id: <1321892148-16835-6-git-send-email-kraxel@redhat.com> In-Reply-To: <1321892148-16835-1-git-send-email-kraxel@redhat.com> References: <1321892148-16835-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 5/7] usb-storage: don't try to send the status early. 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 Until recently all scsi commands sent to scsi-disk did either transfer data or finished instantly. The correct implementation of SYNCRONIZE_CACHE changed the picture though, and usb-storage needs a fix to handle that case correctly. --- hw/usb-msd.c | 16 ++++++++++------ 1 files changed, 10 insertions(+), 6 deletions(-) diff --git a/hw/usb-msd.c b/hw/usb-msd.c index 6f32a0e..68e3756 100644 --- a/hw/usb-msd.c +++ b/hw/usb-msd.c @@ -378,9 +378,7 @@ static int usb_msd_handle_data(USBDevice *dev, USBPacket *p) s->scsi_len = 0; s->req = scsi_req_new(s->scsi_dev, tag, 0, cbw.cmd, NULL); scsi_req_enqueue(s->req); - /* ??? Should check that USB and SCSI data transfer - directions match. */ - if (s->mode != USB_MSDM_CSW && s->residue == 0) { + if (s->req && s->req->cmd.xfer != SCSI_XFER_NONE) { scsi_req_continue(s->req); } ret = p->result; @@ -439,9 +437,15 @@ static int usb_msd_handle_data(USBDevice *dev, USBPacket *p) goto fail; } - usb_msd_send_status(s, p); - s->mode = USB_MSDM_CBW; - ret = 13; + if (s->req) { + /* still in flight */ + s->packet = p; + ret = USB_RET_ASYNC; + } else { + usb_msd_send_status(s, p); + s->mode = USB_MSDM_CBW; + ret = 13; + } break; case USB_MSDM_DATAIN: