Merge remote-tracking branch 'kraxel/usb.76' into staging
* kraxel/usb.76: usb-host: Initialize dev->port the obviously safe way usb-host: Drop superfluous null test from usb_host_auto_scan() ehci: Assert state machine is sane w.r.t. EHCIQueue xhci: nuke transfe5rs on detach xhci: call xhci_detach_slot on root port detach too xhci: create xhci_detach_slot helper function Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
commit
b55160c3d9
|
@ -2092,18 +2092,22 @@ static void ehci_advance_state(EHCIState *ehci, int async)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EST_ADVANCEQUEUE:
|
case EST_ADVANCEQUEUE:
|
||||||
|
assert(q != NULL);
|
||||||
again = ehci_state_advqueue(q);
|
again = ehci_state_advqueue(q);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EST_FETCHQTD:
|
case EST_FETCHQTD:
|
||||||
|
assert(q != NULL);
|
||||||
again = ehci_state_fetchqtd(q);
|
again = ehci_state_fetchqtd(q);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EST_HORIZONTALQH:
|
case EST_HORIZONTALQH:
|
||||||
|
assert(q != NULL);
|
||||||
again = ehci_state_horizqh(q);
|
again = ehci_state_horizqh(q);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EST_EXECUTE:
|
case EST_EXECUTE:
|
||||||
|
assert(q != NULL);
|
||||||
again = ehci_state_execute(q);
|
again = ehci_state_execute(q);
|
||||||
if (async) {
|
if (async) {
|
||||||
ehci->async_stepdown = 0;
|
ehci->async_stepdown = 0;
|
||||||
|
|
|
@ -1197,6 +1197,7 @@ static int xhci_ep_nuke_xfers(XHCIState *xhci, unsigned int slotid,
|
||||||
ep = epctx->transfers[xferi].packet.ep;
|
ep = epctx->transfers[xferi].packet.ep;
|
||||||
}
|
}
|
||||||
killed += xhci_ep_nuke_one_xfer(&epctx->transfers[xferi]);
|
killed += xhci_ep_nuke_one_xfer(&epctx->transfers[xferi]);
|
||||||
|
epctx->transfers[xferi].packet.ep = NULL;
|
||||||
xferi = (xferi + 1) % TD_QUEUE;
|
xferi = (xferi + 1) % TD_QUEUE;
|
||||||
}
|
}
|
||||||
if (ep) {
|
if (ep) {
|
||||||
|
@ -2198,6 +2199,28 @@ static unsigned int xhci_get_slot(XHCIState *xhci, XHCIEvent *event, XHCITRB *tr
|
||||||
return slotid;
|
return slotid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* cleanup slot state on usb device detach */
|
||||||
|
static void xhci_detach_slot(XHCIState *xhci, USBPort *uport)
|
||||||
|
{
|
||||||
|
int slot, ep;
|
||||||
|
|
||||||
|
for (slot = 0; slot < xhci->numslots; slot++) {
|
||||||
|
if (xhci->slots[slot].uport == uport) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (slot == xhci->numslots) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
static TRBCCode xhci_get_port_bandwidth(XHCIState *xhci, uint64_t pctx)
|
static TRBCCode xhci_get_port_bandwidth(XHCIState *xhci, uint64_t pctx)
|
||||||
{
|
{
|
||||||
dma_addr_t ctx;
|
dma_addr_t ctx;
|
||||||
|
@ -2940,6 +2963,7 @@ static void xhci_detach(USBPort *usbport)
|
||||||
XHCIState *xhci = usbport->opaque;
|
XHCIState *xhci = usbport->opaque;
|
||||||
XHCIPort *port = xhci_lookup_port(xhci, usbport);
|
XHCIPort *port = xhci_lookup_port(xhci, usbport);
|
||||||
|
|
||||||
|
xhci_detach_slot(xhci, usbport);
|
||||||
xhci_port_update(port, 1);
|
xhci_port_update(port, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2971,13 +2995,8 @@ static void xhci_child_detach(USBPort *uport, USBDevice *child)
|
||||||
{
|
{
|
||||||
USBBus *bus = usb_bus_from_device(child);
|
USBBus *bus = usb_bus_from_device(child);
|
||||||
XHCIState *xhci = container_of(bus, XHCIState, bus);
|
XHCIState *xhci = container_of(bus, XHCIState, bus);
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < xhci->numslots; i++) {
|
xhci_detach_slot(xhci, uport);
|
||||||
if (xhci->slots[i].uport == uport) {
|
|
||||||
xhci->slots[i].uport = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static USBPortOps xhci_uport_ops = {
|
static USBPortOps xhci_uport_ops = {
|
||||||
|
|
|
@ -1314,7 +1314,7 @@ static int usb_host_open(USBHostDevice *dev, int bus_num,
|
||||||
|
|
||||||
dev->bus_num = bus_num;
|
dev->bus_num = bus_num;
|
||||||
dev->addr = addr;
|
dev->addr = addr;
|
||||||
strcpy(dev->port, port);
|
pstrcpy(dev->port, sizeof(dev->port), port);
|
||||||
dev->fd = fd;
|
dev->fd = fd;
|
||||||
|
|
||||||
/* read the device description */
|
/* read the device description */
|
||||||
|
@ -1760,7 +1760,7 @@ static int usb_host_auto_scan(void *opaque, int bus_num,
|
||||||
if (f->addr > 0 && f->addr != addr) {
|
if (f->addr > 0 && f->addr != addr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (f->port != NULL && (port == NULL || strcmp(f->port, port) != 0)) {
|
if (f->port != NULL && strcmp(f->port, port) != 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue