DM USB: xHCI: [REVERTME] release memory on port resetting.

There is fd leakage during guest OS rebooting process, and this is
a WA patch to fix it. Formal patch will be made later.

Tracked-On: #4897
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
This commit is contained in:
Xiaoguang Wu 2020-06-02 15:56:34 +08:00 committed by wenlingz
parent 1672eca2b9
commit 06d3f4bcb2
3 changed files with 20 additions and 4 deletions

View File

@ -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;

View File

@ -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:

View File

@ -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;