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 From: Gerd Hoffmann 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> Subject: [Qemu-devel] [PATCH 5/7] usb-storage: don't try to send the status early. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann 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: -- 1.7.1