mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-07-05 11:36:50 +00:00
DM USB: xHCI: fix an synchronization issue during resuming process
When disable slot cmd is received by device model, the operation should be: release the pci_xhci_dev_emu variable first, and signal xhci_vbdp_thread to wakeup later. Tho old implementation is not right, this patch is used to fix it. Tracked-On: #2823 Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com> Acked-by: Yu Wang <yu1.wang@intel.com>
This commit is contained in:
parent
d5b35aa785
commit
66dabd1260
@ -1891,10 +1891,11 @@ pci_xhci_cmd_disable_slot(struct pci_xhci_vdev *xdev, uint32_t slot)
|
|||||||
{
|
{
|
||||||
struct pci_xhci_dev_emu *dev;
|
struct pci_xhci_dev_emu *dev;
|
||||||
struct usb_dev *udev;
|
struct usb_dev *udev;
|
||||||
struct usb_native_devinfo *di = NULL;
|
struct usb_native_devinfo di;
|
||||||
struct usb_devpath *path;
|
struct usb_devpath *path;
|
||||||
uint32_t cmderr;
|
uint32_t cmderr;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
bool partial_destroy = false;
|
||||||
|
|
||||||
UPRINTF(LINF, "pci_xhci disable slot %u\r\n", slot);
|
UPRINTF(LINF, "pci_xhci disable slot %u\r\n", slot);
|
||||||
|
|
||||||
@ -1933,23 +1934,31 @@ pci_xhci_cmd_disable_slot(struct pci_xhci_vdev *xdev, uint32_t slot)
|
|||||||
xdev->slots[slot] = NULL;
|
xdev->slots[slot] = NULL;
|
||||||
xdev->slot_allocated[slot] = false;
|
xdev->slot_allocated[slot] = false;
|
||||||
|
|
||||||
di = &udev->info;
|
di = udev->info;
|
||||||
for (j = 0; j < XHCI_MAX_VIRT_PORTS; ++j) {
|
for (j = 0; j < XHCI_MAX_VIRT_PORTS; ++j) {
|
||||||
path = &xdev->vbdp_devs[j].path;
|
path = &xdev->vbdp_devs[j].path;
|
||||||
|
|
||||||
if (!usb_dev_path_cmp(path, &di->path))
|
if (!usb_dev_path_cmp(path, &di.path))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
xdev->vbdp_devs[j].state |= S3_VBDP_DIS_SLOT;
|
xdev->vbdp_devs[j].state |= S3_VBDP_DIS_SLOT;
|
||||||
sem_post(&xdev->vbdp_sem);
|
partial_destroy = true;
|
||||||
UPRINTF(LINF, "signal device %d-%s to connect\r\n",
|
|
||||||
di->path.bus, usb_dev_path(&di->path));
|
|
||||||
}
|
}
|
||||||
UPRINTF(LINF, "disable slot %d for native device %d-%s\r\n",
|
UPRINTF(LINF, "disable slot %d for native device %d-%s\r\n",
|
||||||
slot, di->path.bus, usb_dev_path(&di->path));
|
slot, di.path.bus, usb_dev_path(&di.path));
|
||||||
|
|
||||||
/* release all the resource allocated for virtual device */
|
/* release all the resource allocated for virtual device */
|
||||||
pci_xhci_dev_destroy(dev, true);
|
pci_xhci_dev_destroy(dev, true);
|
||||||
|
|
||||||
|
/* For devices connected before suspending, it is necessary
|
||||||
|
* to signal the xhci_vbdp_thread to prepare the subsequent
|
||||||
|
* connect event.
|
||||||
|
*/
|
||||||
|
if (partial_destroy) {
|
||||||
|
sem_post(&xdev->vbdp_sem);
|
||||||
|
UPRINTF(LINF, "signal device %d-%s to connect\r\n",
|
||||||
|
di.path.bus, usb_dev_path(&di.path));
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
UPRINTF(LWRN, "invalid slot %d\r\n", slot);
|
UPRINTF(LWRN, "invalid slot %d\r\n", slot);
|
||||||
|
|
||||||
|
@ -1183,7 +1183,7 @@ usb_dev_native_sys_conn_cb(struct libusb_context *ctx, struct libusb_device
|
|||||||
struct usb_native_devinfo di;
|
struct usb_native_devinfo di;
|
||||||
bool ret;
|
bool ret;
|
||||||
|
|
||||||
UPRINTF(LDBG, "connect event\r\n");
|
UPRINTF(LINF, "connect event\r\n");
|
||||||
|
|
||||||
if (!ctx || !ldev) {
|
if (!ctx || !ldev) {
|
||||||
UPRINTF(LFTL, "connect callback fails!\n");
|
UPRINTF(LFTL, "connect callback fails!\n");
|
||||||
@ -1207,7 +1207,7 @@ usb_dev_native_sys_disconn_cb(struct libusb_context *ctx, struct libusb_device
|
|||||||
struct usb_native_devinfo di;
|
struct usb_native_devinfo di;
|
||||||
bool ret;
|
bool ret;
|
||||||
|
|
||||||
UPRINTF(LDBG, "disconnect event\r\n");
|
UPRINTF(LINF, "disconnect event\r\n");
|
||||||
|
|
||||||
if (!ctx || !ldev) {
|
if (!ctx || !ldev) {
|
||||||
UPRINTF(LFTL, "disconnect callback fails!\n");
|
UPRINTF(LFTL, "disconnect callback fails!\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user