From c3d4cc36e14db45b744674a8aae897b2cabd9692 Mon Sep 17 00:00:00 2001 From: Xiaoguang Wu Date: Fri, 5 Jul 2019 10:15:08 +0800 Subject: [PATCH] DM USB: xHCI: refine the logic of Stop Endpoint cmd When the Stop Endpoint command is trapped, should not clear all the data structure. Instead, only reset the ring buffer. The reason is the xHCI may continue queue TRB without doing whole initializing process again. Tracked-On: #3401 Signed-off-by: Xiaoguang Wu Acked-by: Yu Wang --- devicemodel/hw/pci/xhci.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/devicemodel/hw/pci/xhci.c b/devicemodel/hw/pci/xhci.c index 8f7a1b1d9..1f457fb24 100644 --- a/devicemodel/hw/pci/xhci.c +++ b/devicemodel/hw/pci/xhci.c @@ -1321,6 +1321,7 @@ pci_xhci_portregs_write(struct pci_xhci_vdev *xdev, break; UPRINTF(LDBG, "Port new PLS: %d\r\n", newpls); + switch (newpls) { case 0: /* U0 */ case 3: /* U3 */ @@ -2215,10 +2216,10 @@ pci_xhci_cmd_reset_ep(struct pci_xhci_vdev *xdev, /* let usb_dev_comp_req to free the memory */ libusb_cancel_transfer(r->trn); } - memset(xfer, 0, sizeof(*xfer)); - if (devep->ep_xfer) - memset(devep->ep_xfer, 0, sizeof(*devep->ep_xfer)); + xfer->ndata = 0; + xfer->head = 0; + xfer->tail = 0; ep_ctx->dwEpCtx0 = (ep_ctx->dwEpCtx0 & ~0x7) | XHCI_ST_EPCTX_STOPPED;