Skip to contentSkip to conversation

xhci fixes

PATCH In review Gerd Hoffmann 2 participants 5 messages Jan 8, 2013 – Jan 9, 2013

lore
Share & tools
lore
#0 lore raw

cover xhci fixes

Hi,

Little patch series which makes sure xhci cancels inflight transfers on device detach.

cheers,
Gerd

Gerd Hoffmann (3):
xhci: create xhci_detach_slot helper function
xhci: call xhci_detach_slot on root port detach too
xhci: nuke transfe5rs on detach

 hw/usb/hcd-xhci.c |   31 +++++++++++++++++++++++++------
 1 files changed, 25 insertions(+), 6 deletions(-)
#1 lore raw

PATCH 1/3 xhci: create xhci_detach_slot helper function

---
 hw/usb/hcd-xhci.c |   24 ++++++++++++++++++------
 1 files changed, 18 insertions(+), 6 deletions(-)
hw/usb/hcd-xhci.c +18 -6
index 9132920..5d4d876 100644
@@ -2198,6 +2198,23 @@ static unsigned int xhci_get_slot(XHCIState *xhci, XHCIEvent *event, XHCITRB *tr
     return slotid;
 }
 
+/* cleanup slot state on usb device detach */
+static void xhci_detach_slot(XHCIState *xhci, USBPort *uport)
+{
+    int slot;
+
+    for (slot = 0; slot < xhci->numslots; slot++) {
+        if (xhci->slots[slot].uport == uport) {
+            break;
+        }
+    }
+    if (slot == xhci->numslots) {
+        return;
+    }
+
+    xhci->slots[slot].uport = NULL;
+}
+
 static TRBCCode xhci_get_port_bandwidth(XHCIState *xhci, uint64_t pctx)
 {
     dma_addr_t ctx;
@@ -2971,13 +2988,8 @@ static void xhci_child_detach(USBPort *uport, USBDevice *child)
 {
     USBBus *bus = usb_bus_from_device(child);
     XHCIState *xhci = container_of(bus, XHCIState, bus);
-    int i;
 
-    for (i = 0; i < xhci->numslots; i++) {
-        if (xhci->slots[i].uport == uport) {
-            xhci->slots[i].uport = NULL;
-        }
-    }
+    xhci_detach_slot(xhci, uport);
 }
 
 static USBPortOps xhci_uport_ops = {
Signature · 1 line
1.7.1
#2 lore raw

PATCH 2/3 xhci: call xhci_detach_slot on root port detach too

In reply to Gerd Hoffmann
---
 hw/usb/hcd-xhci.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
hw/usb/hcd-xhci.c +1 -0
index 5d4d876..b4736f5 100644
@@ -2957,6 +2957,7 @@ static void xhci_detach(USBPort *usbport)
     XHCIState *xhci = usbport->opaque;
     XHCIPort *port = xhci_lookup_port(xhci, usbport);
 
+    xhci_detach_slot(xhci, usbport);
     xhci_port_update(port, 1);
 }
 
Signature · 1 line
1.7.1
#3 lore raw

PATCH 3/3 xhci: nuke transfe5rs on detach

In reply to Gerd Hoffmann
---
 hw/usb/hcd-xhci.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
hw/usb/hcd-xhci.c +7 -1
index b4736f5..f8f5aeb 100644
@@ -1197,6 +1197,7 @@ static int xhci_ep_nuke_xfers(XHCIState *xhci, unsigned int slotid,
             ep = epctx->transfers[xferi].packet.ep;
         }
         killed += xhci_ep_nuke_one_xfer(&epctx->transfers[xferi]);
+        epctx->transfers[xferi].packet.ep = NULL;
         xferi = (xferi + 1) % TD_QUEUE;
     }
     if (ep) {
@@ -2201,7 +2202,7 @@ static unsigned int xhci_get_slot(XHCIState *xhci, XHCIEvent *event, XHCITRB *tr
 /* cleanup slot state on usb device detach */
 static void xhci_detach_slot(XHCIState *xhci, USBPort *uport)
 {
-    int slot;
+    int slot, ep;
 
     for (slot = 0; slot < xhci->numslots; slot++) {
         if (xhci->slots[slot].uport == uport) {
@@ -2212,6 +2213,11 @@ static void xhci_detach_slot(XHCIState *xhci, USBPort *uport)
         return;
     }
 
+    for (ep = 0; ep < 31; ep++) {
+        if (xhci->slots[slot].eps[ep]) {
+            xhci_ep_nuke_xfers(xhci, slot+1, ep+1);
+        }
+    }
     xhci->slots[slot].uport = NULL;
 }
 
Signature · 1 line
1.7.1
#4 lore raw
In reply to Gerd Hoffmann

Hi,

Other then the typo in the commit messages for the 3th patch, this sets looks good. ACK series.

Regards,

Hans

Quoted 17 lines · Gerd Hoffmann
   Hi,

Little patch series which makes sure xhci cancels inflight transfers on device detach.

cheers,
Gerd

Gerd Hoffmann (3):
xhci: create xhci_detach_slot helper function
xhci: call xhci_detach_slot on root port detach too
xhci: nuke transfe5rs on detach

  hw/usb/hcd-xhci.c |   31 +++++++++++++++++++++++++------
  1 files changed, 25 insertions(+), 6 deletions(-)