MdeModulePkg/XhciDxe/Xhci: Don't check for invalid PSIV

PSID matching relies on comparing the PSIV against the PortSpeed
value. This patch stops edk2 from checking for a PSIV of 0, as it
is not valid; this reduces the number of register access by
approximately 6 per second.

Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
Reviewed-by: Sean Rhodes <sean@starlabs.systems>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
This commit is contained in:
Matt DeVillier 2022-12-16 16:58:05 +08:00 committed by mergify[bot]
parent 3f378450df
commit 01c2fb0d22

View File

@ -371,6 +371,7 @@ XhcGetRootHubPortStatus (
UINT32 TotalPort; UINT32 TotalPort;
UINTN Index; UINTN Index;
UINTN MapSize; UINTN MapSize;
UINT8 PortSpeed;
EFI_STATUS Status; EFI_STATUS Status;
USB_DEV_ROUTE ParentRouteChart; USB_DEV_ROUTE ParentRouteChart;
EFI_TPL OldTpl; EFI_TPL OldTpl;
@ -397,17 +398,21 @@ XhcGetRootHubPortStatus (
State = XhcReadOpReg (Xhc, Offset); State = XhcReadOpReg (Xhc, Offset);
PortSpeed = (State & XHC_PORTSC_PS) >> 10;
// //
// According to XHCI 1.1 spec November 2017, // According to XHCI 1.1 spec November 2017,
// Section 7.2 xHCI Support Protocol Capability // Section 7.2 xHCI Support Protocol Capability
// //
PortStatus->PortStatus = XhcCheckUsbPortSpeedUsedPsic (Xhc, ((State & XHC_PORTSC_PS) >> 10)); if (PortSpeed > 0) {
PortStatus->PortStatus = XhcCheckUsbPortSpeedUsedPsic (Xhc, PortSpeed);
// If no match found in ext cap reg, fall back to PORTSC
if (PortStatus->PortStatus == 0) { if (PortStatus->PortStatus == 0) {
// //
// According to XHCI 1.1 spec November 2017, // According to XHCI 1.1 spec November 2017,
// bit 10~13 of the root port status register identifies the speed of the attached device. // bit 10~13 of the root port status register identifies the speed of the attached device.
// //
switch ((State & XHC_PORTSC_PS) >> 10) { switch (PortSpeed) {
case 2: case 2:
PortStatus->PortStatus |= USB_PORT_STAT_LOW_SPEED; PortStatus->PortStatus |= USB_PORT_STAT_LOW_SPEED;
break; break;
@ -425,6 +430,7 @@ XhcGetRootHubPortStatus (
break; break;
} }
} }
}
// //
// Convert the XHCI port/port change state to UEFI status // Convert the XHCI port/port change state to UEFI status