From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:53600) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RSU6d-0003Fa-F2 for qemu-devel@nongnu.org; Mon, 21 Nov 2011 08:40:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RSU6U-0000ku-Mb for qemu-devel@nongnu.org; Mon, 21 Nov 2011 08:40:19 -0500 Received: from mx1.redhat.com ([209.132.183.28]:18027) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RSU6U-0000kU-8g for qemu-devel@nongnu.org; Mon, 21 Nov 2011 08:40:10 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pALDe9GR029250 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 21 Nov 2011 08:40:09 -0500 From: Gerd Hoffmann Date: Mon, 21 Nov 2011 14:40:00 +0100 Message-Id: <1321882802-3337-7-git-send-email-kraxel@redhat.com> In-Reply-To: <1321882802-3337-1-git-send-email-kraxel@redhat.com> References: <1321882802-3337-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 6/8] 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: pbonzini@redhat.com, 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