mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-18 23:52:14 -06:00
xhci: recheck slot status
Factor out slot status check into a helper function. Add an additional check after completing transfers. This is needed in case a guest queues multiple transfers in a row and a device unplug happens while qemu processes them. Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1786413 Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-id: 20200107083606.12393-1-kraxel@redhat.com
This commit is contained in:
parent
34b9d6a1f8
commit
236846a019
1 changed files with 12 additions and 3 deletions
|
@ -1861,6 +1861,13 @@ static void xhci_kick_ep(XHCIState *xhci, unsigned int slotid,
|
||||||
xhci_kick_epctx(epctx, streamid);
|
xhci_kick_epctx(epctx, streamid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool xhci_slot_ok(XHCIState *xhci, int slotid)
|
||||||
|
{
|
||||||
|
return (xhci->slots[slotid - 1].uport &&
|
||||||
|
xhci->slots[slotid - 1].uport->dev &&
|
||||||
|
xhci->slots[slotid - 1].uport->dev->attached);
|
||||||
|
}
|
||||||
|
|
||||||
static void xhci_kick_epctx(XHCIEPContext *epctx, unsigned int streamid)
|
static void xhci_kick_epctx(XHCIEPContext *epctx, unsigned int streamid)
|
||||||
{
|
{
|
||||||
XHCIState *xhci = epctx->xhci;
|
XHCIState *xhci = epctx->xhci;
|
||||||
|
@ -1878,9 +1885,7 @@ static void xhci_kick_epctx(XHCIEPContext *epctx, unsigned int streamid)
|
||||||
|
|
||||||
/* If the device has been detached, but the guest has not noticed this
|
/* If the device has been detached, but the guest has not noticed this
|
||||||
yet the 2 above checks will succeed, but we must NOT continue */
|
yet the 2 above checks will succeed, but we must NOT continue */
|
||||||
if (!xhci->slots[epctx->slotid - 1].uport ||
|
if (!xhci_slot_ok(xhci, epctx->slotid)) {
|
||||||
!xhci->slots[epctx->slotid - 1].uport->dev ||
|
|
||||||
!xhci->slots[epctx->slotid - 1].uport->dev->attached) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1987,6 +1992,10 @@ static void xhci_kick_epctx(XHCIEPContext *epctx, unsigned int streamid)
|
||||||
} else {
|
} else {
|
||||||
xhci_fire_transfer(xhci, xfer, epctx);
|
xhci_fire_transfer(xhci, xfer, epctx);
|
||||||
}
|
}
|
||||||
|
if (!xhci_slot_ok(xhci, epctx->slotid)) {
|
||||||
|
/* surprise removal -> stop processing */
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (xfer->complete) {
|
if (xfer->complete) {
|
||||||
/* update ring dequeue ptr */
|
/* update ring dequeue ptr */
|
||||||
xhci_set_ep_state(xhci, epctx, stctx, epctx->state);
|
xhci_set_ep_state(xhci, epctx, stctx, epctx->state);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue