diff --git a/devicemodel/hw/pci/xhci.c b/devicemodel/hw/pci/xhci.c index 50b9282e8..cf7485c4b 100644 --- a/devicemodel/hw/pci/xhci.c +++ b/devicemodel/hw/pci/xhci.c @@ -1992,6 +1992,7 @@ pci_xhci_cmd_reset_device(struct pci_xhci_vdev *xdev, uint32_t slot) pci_xhci_reset_slot(xdev, slot); done: + cmderr = XHCI_TRB_ERROR_SUCCESS; return cmderr; } @@ -2064,6 +2065,7 @@ pci_xhci_cmd_address_device(struct pci_xhci_vdev *xdev, goto done; } + di->slot = slot; xdev->native_ports[index].state = VPORT_EMULATED; xdev->devices[rh_port] = dev; xdev->ndevices++; @@ -3795,6 +3797,8 @@ pci_xhci_reset_port(struct pci_xhci_vdev *xdev, int portn, int warm) struct usb_native_devinfo *di; int speed, error; int index; + int slot; + struct pci_xhci_dev_emu *dev; UPRINTF(LINF, "reset port %d\r\n", portn); @@ -3813,6 +3817,21 @@ pci_xhci_reset_port(struct pci_xhci_vdev *xdev, int portn, int warm) if (warm && di->bcd >= 0x300) port->portsc |= XHCI_PS_WRC; + slot = di->slot; + if (xdev->slot_allocated[slot] && xdev->slots[slot]) { + dev = xdev->slots[slot]; + + UPRINTF(LWRN, "xgwu reset port %d, dev1 %p, dev2 %p\r\n", + portn, dev, xdev->devices[portn]); + + if (dev && xdev->devices[portn] == dev) { + pci_xhci_dev_destroy(dev); + xdev->devices[portn] = NULL; + xdev->slots[slot] = NULL; + xdev->ndevices--; + } + } + if ((port->portsc & XHCI_PS_PRC) == 0) { port->portsc |= XHCI_PS_PRC; diff --git a/devicemodel/hw/platform/usb_pmapper.c b/devicemodel/hw/platform/usb_pmapper.c index a3a00883f..e3dbaca5f 100644 --- a/devicemodel/hw/platform/usb_pmapper.c +++ b/devicemodel/hw/platform/usb_pmapper.c @@ -1094,10 +1094,6 @@ usb_dev_init(void *pdata, char *opt) goto errout; } - if (usb_dev_native_toggle_if_drivers(udev, 0) < 0) { - UPRINTF(LWRN, "fail to detach interface driver.\r\n"); - goto errout; - } return udev; errout: diff --git a/devicemodel/include/usb_core.h b/devicemodel/include/usb_core.h index 52cef5655..f2f8c10d7 100644 --- a/devicemodel/include/usb_core.h +++ b/devicemodel/include/usb_core.h @@ -188,6 +188,7 @@ struct usb_native_devinfo { uint16_t bcd; uint16_t pid; uint16_t vid; + uint32_t slot; enum usb_native_devtype type; struct usb_devpath path; void *priv_data;