From ede32960cae55049899c565e808b0198fe6c559f Mon Sep 17 00:00:00 2001
Message-Id: <ede32960cae55049899c565e808b0198fe6c559f.1345545736.git.minovotn@redhat.com>
In-Reply-To: <004171b9879af86d3c14654d0080b5559ee48267.1345545736.git.minovotn@redhat.com>
References: <004171b9879af86d3c14654d0080b5559ee48267.1345545736.git.minovotn@redhat.com>
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Wed, 8 Aug 2012 12:41:10 +0200
Subject: [PATCH 2/8] usb-storage: fix SYNCHRONIZE_CACHE

RH-Author: Gerd Hoffmann <kraxel@redhat.com>
Message-id: <1344429670-18795-1-git-send-email-kraxel@redhat.com>
Patchwork-id: 40626
O-Subject: [RHEL-6.4 qemu-kvm PATCH] usb-storage: fix SYNCHRONIZE_CACHE
Bugzilla: 839957
RH-Acked-by: Hans de Goede <hdegoede@redhat.com>
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>

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 <kraxel@redhat.com>
(cherry picked from commit 54414218d78c9d043417b27bb29bd0334b4e3cb5)

bugzilla: #839957 - usb-storage: SYNCHRONIZE_CACHE is broken
brew: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=4736741
---
 hw/usb-msd.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

Signed-off-by: Michal Novotny <minovotn@redhat.com>
---
 hw/usb-msd.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/hw/usb-msd.c b/hw/usb-msd.c
index 2f7e5cb..b5ce183 100644
--- a/hw/usb-msd.c
+++ b/hw/usb-msd.c
@@ -249,6 +249,9 @@ static void usb_msd_command_complete(SCSIRequest *req, uint32_t status, int32_t
                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) {
                 s->data_len -= s->usb_len;
-- 
1.7.11.2

