From 06f9847dc3da670c36629c80ae47fea4bf726268 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Fri, 13 Jul 2012 11:35:51 +0200 Subject: [PATCH 1/2] usb-storage: improve debug logging Signed-off-by: Gerd Hoffmann --- hw/usb/dev-storage.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c index 7fa8b83d2e..976fe1acc5 100644 --- a/hw/usb/dev-storage.c +++ b/hw/usb/dev-storage.c @@ -383,6 +383,9 @@ static int usb_msd_handle_data(USBDevice *dev, USBPacket *p) assert(le32_to_cpu(s->csw.residue) == 0); s->scsi_len = 0; s->req = scsi_req_new(s->scsi_dev, tag, 0, cbw.cmd, NULL); +#ifdef DEBUG_MSD + scsi_req_print(s->req); +#endif scsi_req_enqueue(s->req); if (s->req && s->req->cmd.xfer != SCSI_XFER_NONE) { scsi_req_continue(s->req); @@ -410,7 +413,7 @@ static int usb_msd_handle_data(USBDevice *dev, USBPacket *p) } } if (p->result < p->iov.size) { - DPRINTF("Deferring packet %p\n", p); + DPRINTF("Deferring packet %p [wait data-out]\n", p); s->packet = p; ret = USB_RET_ASYNC; } else { @@ -445,6 +448,7 @@ static int usb_msd_handle_data(USBDevice *dev, USBPacket *p) if (s->req) { /* still in flight */ + DPRINTF("Deferring packet %p [wait status]\n", p); s->packet = p; ret = USB_RET_ASYNC; } else { @@ -471,7 +475,7 @@ static int usb_msd_handle_data(USBDevice *dev, USBPacket *p) } } if (p->result < p->iov.size) { - DPRINTF("Deferring packet %p\n", p); + DPRINTF("Deferring packet %p [wait data-in]\n", p); s->packet = p; ret = USB_RET_ASYNC; } else { From 54414218d78c9d043417b27bb29bd0334b4e3cb5 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Fri, 13 Jul 2012 11:38:13 +0200 Subject: [PATCH 2/2] usb-storage: fix SYNCHRONIZE_CACHE Commit 59310659073d85745854f2f10c4292555c5a1c51 is incomplete, we'll arrive in the scsi command complete callback in CSW state and must handle that case correctly. Signed-off-by: Gerd Hoffmann --- hw/usb/dev-storage.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c index 976fe1acc5..ff48d91049 100644 --- a/hw/usb/dev-storage.c +++ b/hw/usb/dev-storage.c @@ -247,6 +247,9 @@ static void usb_msd_command_complete(SCSIRequest *req, uint32_t status, size_t r the status read packet. */ usb_msd_send_status(s, p); s->mode = USB_MSDM_CBW; + } else if (s->mode == USB_MSDM_CSW) { + usb_msd_send_status(s, p); + s->mode = USB_MSDM_CBW; } else { if (s->data_len) { int len = (p->iov.size - p->result);