Skip to content

Commit b10ad4b

Browse files
xiaoguangwuacrnsi
authored andcommitted
DM USB: xHCI: refine the logic of CCS bit of PORTSC register
The CCS bit of PORTSC register should be set according to the mapped native port connection status, use xdev->devices if equal NULL is not enough due to devices only be clear in disable slot which can't reflect the native connection state in some gaps. Tracked-On: #3163 Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com> Acked-by: Yu Wang <yu1.wang@intel.com>
1 parent ae06668 commit b10ad4b

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

devicemodel/hw/pci/xhci.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,6 @@ struct pci_xhci_vdev {
416416

417417
/* portregs and devices arrays are set up to start from idx=1 */
418418
#define XHCI_PORTREG_PTR(x, n) (&(x)->portregs[(n)])
419-
#define XHCI_DEVINST_PTR(x, n) ((x)->devices[(n)])
420419
#define XHCI_SLOTDEV_PTR(x, n) ((x)->slots[(n)])
421420
#define XHCI_HALTED(xdev) ((xdev)->opregs.usbsts & XHCI_STS_HCH)
422421
#define XHCI_GADDR(xdev, a) paddr_guest2host((xdev)->dev->vmctx, (a), \
@@ -473,6 +472,18 @@ static struct pci_xhci_option_elem xhci_option_table[] = {
473472
{"cap", pci_xhci_parse_extcap}
474473
};
475474

475+
static bool
476+
pci_xhci_is_vport_free(struct pci_xhci_vdev *xdev, int portnum)
477+
{
478+
int i;
479+
480+
for (i = 0; i < XHCI_MAX_VIRT_PORTS; i++)
481+
if (xdev->native_ports[i].vport == portnum)
482+
return true;
483+
484+
return false;
485+
}
486+
476487
static int
477488
pci_xhci_get_free_vport(struct pci_xhci_vdev *xdev,
478489
struct usb_native_devinfo *di)
@@ -1255,11 +1266,6 @@ pci_xhci_portregs_write(struct pci_xhci_vdev *xdev,
12551266
return;
12561267
}
12571268

1258-
if (XHCI_DEVINST_PTR(xdev, port) == NULL) {
1259-
UPRINTF(LDBG, "portregs_write to unattached port %d\r\n",
1260-
port);
1261-
}
1262-
12631269
p = XHCI_PORTREG_PTR(xdev, port);
12641270
switch (offset) {
12651271
case 0:
@@ -1282,7 +1288,7 @@ pci_xhci_portregs_write(struct pci_xhci_vdev *xdev,
12821288
p->portsc &= XHCI_PS_PED | XHCI_PS_PLS_MASK |
12831289
XHCI_PS_SPEED_MASK | XHCI_PS_PIC_MASK;
12841290

1285-
if (XHCI_DEVINST_PTR(xdev, port))
1291+
if (pci_xhci_is_vport_free(xdev, port) == true)
12861292
p->portsc |= XHCI_PS_CCS;
12871293

12881294
p->portsc |= (value &

0 commit comments

Comments
 (0)