Skip to contentSkip to conversation

usb-host: handle guest-issued clear halt

PATCH In review Gerd Hoffmann 3 participants 4 messages May 8, 2012 – May 11, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb-host: handle guest-issued clear halt

Most important here is to update our internal endpoint state so we know the endpoint isn't in halted state any more. Without this usb-host tries to clear halt again with the next data transfer submitted. Doing this twice is (a) not correct and (b) confuses some usb devices, rendering them non-functional in the guest.

---
 hw/usb/host-linux.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
hw/usb/host-linux.c +9 -0
index bb08542..9094120 100644
@@ -1101,6 +1101,15 @@ static int usb_host_handle_control(USBDevice *dev, USBPacket *p,
         ret = usb_host_set_interface(s, index, value);
         trace_usb_host_req_emulated(s->bus_num, s->addr, p, ret);
         return ret;
+
+    case EndpointOutRequest | USB_REQ_CLEAR_FEATURE:
+        if (value == 0) { /* clear halt */
+            int pid = (index & USB_DIR_IN) ? USB_TOKEN_IN : USB_TOKEN_OUT;
+            ioctl(s->fd, USBDEVFS_CLEAR_HALT, &index);
+            clear_halt(s, pid, index & 0x0f);
+            trace_usb_host_req_emulated(s->bus_num, s->addr, p, 0);
+            return 0;
+        }
     }
 
     /* The rest are asynchronous */
Signature · 1 line
1.7.1
#1 lore raw

Looks good, ACK.

Quoted 31 lines · Gerd Hoffmann

Most important here is to update our internal endpoint state so we know the endpoint isn't in halted state any more. Without this usb-host tries to clear halt again with the next data transfer submitted. Doing this twice is (a) not correct and (b) confuses some usb devices, rendering them non-functional in the guest.

---
  hw/usb/host-linux.c |    9 +++++++++
  1 files changed, 9 insertions(+), 0 deletions(-)
hw/usb/host-linux.c +9 -0
index bb08542..9094120 100644
@@ -1101,6 +1101,15 @@ static int usb_host_handle_control(USBDevice *dev, USBPacket *p,
          ret = usb_host_set_interface(s, index, value);
          trace_usb_host_req_emulated(s->bus_num, s->addr, p, ret);
          return ret;
+
+    case EndpointOutRequest | USB_REQ_CLEAR_FEATURE:
+        if (value == 0) { /* clear halt */
+            int pid = (index&  USB_DIR_IN) ? USB_TOKEN_IN : USB_TOKEN_OUT;
+            ioctl(s->fd, USBDEVFS_CLEAR_HALT,&index);
+            clear_halt(s, pid, index&  0x0f);
+            trace_usb_host_req_emulated(s->bus_num, s->addr, p, 0);
+            return 0;
+        }
      }
 
      /* The rest are asynchronous */
#2 lore raw
In reply to Gerd Hoffmann

Looks VERY good, ACK!
The DVD drive works now!

hw/usb/host-linux.c static int usb_host_handle_control(USBDevice *dev,

Quoted 16 lines · Gerd Hoffmann

Most important here is to update our internal endpoint state so we know the endpoint isn't in halted state any more. Without this usb-host tries to clear halt again with the next data transfer submitted. Doing this twice is (a) not correct and (b) confuses some usb devices, rendering them non-functional in the guest.

---
 hw/usb/host-linux.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
hw/usb/host-linux.c +0 -0
index bb08542..9094120 100644
@@ -1101,6 +1101,15 @@ static int usb_host_handle_control(USBDevice *dev,

USBPacket *p,

hw/usb/host-linux.c static int usb_host_handle_control(USBDevice *dev, USBPacket *p,

Quoted 7 lines
hw/usb/host-linux.c +4 -0
         ret = usb_host_set_interface(s, index, value);
         trace_usb_host_req_emulated(s->bus_num, s->addr, p, ret);
         return ret;
+
+    case EndpointOutRequest | USB_REQ_CLEAR_FEATURE:
+        if (value == 0) { /* clear halt */
+            int pid = (index & USB_DIR_IN) ? USB_TOKEN_IN :

USB_TOKEN_OUT;

Quoted 12 lines
hw/usb/host-linux.c +5 -1
+            ioctl(s->fd, USBDEVFS_CLEAR_HALT, &index);
+            clear_halt(s, pid, index & 0x0f);
+            trace_usb_host_req_emulated(s->bus_num, s->addr, p, 0);
+            return 0;
+        }
     }
 
     /* The rest are asynchronous */
--

1.7.1

#3 lore raw
In reply to Gerd Hoffmann
Quoted 5 lines · Gerd Hoffmann

Most important here is to update our internal endpoint state so we know the endpoint isn't in halted state any more. Without this usb-host tries to clear halt again with the next data transfer submitted. Doing this twice is (a) not correct and (b) confuses some usb devices, rendering them non-functional in the guest.

Anthony, can you pick this directly?
It is the only 1.1 usb patch in the queue right now ...

cheers,
Gerd