dcavalca / rpms / qemu

Forked from rpms/qemu a year ago
Clone

Blame 0016-usb-storage-cancel-I-O-on-reset.patch

Justin M. Forbes 45e84a
From f63d074313c5df917535587b50802ece7beb6e45 Mon Sep 17 00:00:00 2001
Justin M. Forbes 45e84a
From: Gerd Hoffmann <kraxel@redhat.com>
Justin M. Forbes 45e84a
Date: Wed, 4 Jan 2012 18:13:54 +0100
Justin M. Forbes 45e84a
Subject: [PATCH 16/25] usb-storage: cancel I/O on reset
Justin M. Forbes 45e84a
Justin M. Forbes 45e84a
When resetting the usb-storage device we'll have to carefully cancel
Justin M. Forbes 45e84a
and clear any requests which might be in flight, otherwise we'll confuse
Justin M. Forbes 45e84a
the state machine.
Justin M. Forbes 45e84a
Justin M. Forbes 45e84a
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Justin M. Forbes 45e84a
---
Justin M. Forbes 45e84a
 hw/usb-msd.c |   12 ++++++++++++
Justin M. Forbes 45e84a
 1 files changed, 12 insertions(+), 0 deletions(-)
Justin M. Forbes 45e84a
Justin M. Forbes 45e84a
diff --git a/hw/usb-msd.c b/hw/usb-msd.c
Justin M. Forbes 45e84a
index 4c06950..3147131 100644
Justin M. Forbes 45e84a
--- a/hw/usb-msd.c
Justin M. Forbes 45e84a
+++ b/hw/usb-msd.c
Justin M. Forbes 45e84a
@@ -278,6 +278,18 @@ static void usb_msd_handle_reset(USBDevice *dev)
Justin M. Forbes 45e84a
     MSDState *s = (MSDState *)dev;
Justin M. Forbes 45e84a
Justin M. Forbes 45e84a
     DPRINTF("Reset\n");
Justin M. Forbes 45e84a
+    if (s->req) {
Justin M. Forbes 45e84a
+        scsi_req_cancel(s->req);
Justin M. Forbes 45e84a
+    }
Justin M. Forbes 45e84a
+    assert(s->req == NULL);
Justin M. Forbes 45e84a
+
Justin M. Forbes 45e84a
+    if (s->packet) {
Justin M. Forbes 45e84a
+        USBPacket *p = s->packet;
Justin M. Forbes 45e84a
+        s->packet = NULL;
Justin M. Forbes 45e84a
+        p->result = USB_RET_STALL;
Justin M. Forbes 45e84a
+        usb_packet_complete(dev, p);
Justin M. Forbes 45e84a
+    }
Justin M. Forbes 45e84a
+
Justin M. Forbes 45e84a
     s->mode = USB_MSDM_CBW;
Justin M. Forbes 45e84a
 }
Justin M. Forbes 45e84a
Justin M. Forbes 45e84a
-- 
Justin M. Forbes 45e84a
1.7.7.5
Justin M. Forbes 45e84a