summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c
diff options
context:
space:
mode:
authorFeng Tian <feng.tian@intel.com>2016-07-06 10:18:37 +0800
committerFeng Tian <feng.tian@intel.com>2016-07-25 09:36:41 +0800
commitbf4808d6443775c9c5170b0ca9c521e6d9c977c1 (patch)
tree55cadf2c8c0b9b4ecdfbc212e298b3c6c2c4ae15 /MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c
parent698554923f055daf560d4954d0cc735d3df30430 (diff)
downloadedk2-bf4808d6443775c9c5170b0ca9c521e6d9c977c1.tar.gz
edk2-bf4808d6443775c9c5170b0ca9c521e6d9c977c1.tar.bz2
edk2-bf4808d6443775c9c5170b0ca9c521e6d9c977c1.zip
MdeModulePkg/UsbBus: reduce the port status polling before port reset
This change is used to remove the port status polling in port reset functions. Why it's needed is because: 1) The same polling on same port has taken place prior to this removed one. See UsbEnumeratePort()->GetPortStatus(). So this polling in UsbEnumerateNewDev()->ResetPort() is redundant. 2) EDKII Xhci driver hooks all GetPortStatus() operations. If we don't remove this one, XHCI driver's XhcPollPortStatusChange() may enter twice in reset process and wrongly think the device is unplugged. Cc: Star Zeng <star.zeng@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Feng Tian <feng.tian@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
Diffstat (limited to 'MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c')
-rw-r--r--MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c
index 79453fed26..ea54d37c93 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c
+++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c
@@ -643,6 +643,7 @@ UsbFindChild (
@param HubIf The HUB that has the device connected.
@param Port The port index of the hub (started with zero).
+ @param ResetIsNeeded The boolean to control whether skip the reset of the port.
@retval EFI_SUCCESS The device is enumerated (added or removed).
@retval EFI_OUT_OF_RESOURCES Failed to allocate resource for the device.
@@ -652,7 +653,8 @@ UsbFindChild (
EFI_STATUS
UsbEnumerateNewDev (
IN USB_INTERFACE *HubIf,
- IN UINT8 Port
+ IN UINT8 Port,
+ IN BOOLEAN ResetIsNeeded
)
{
USB_BUS *Bus;
@@ -677,16 +679,18 @@ UsbEnumerateNewDev (
// and the hub is a EHCI root hub, ResetPort will release
// the device to its companion UHCI and return an error.
//
- Status = HubApi->ResetPort (HubIf, Port);
-
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "UsbEnumerateNewDev: failed to reset port %d - %r\n", Port, Status));
-
- return Status;
+ if (ResetIsNeeded) {
+ Status = HubApi->ResetPort (HubIf, Port);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_ERROR, "UsbEnumerateNewDev: failed to reset port %d - %r\n", Port, Status));
+
+ return Status;
+ }
+ DEBUG (( EFI_D_INFO, "UsbEnumerateNewDev: hub port %d is reset\n", Port));
+ } else {
+ DEBUG (( EFI_D_INFO, "UsbEnumerateNewDev: hub port %d reset is skipped\n", Port));
}
- DEBUG (( EFI_D_INFO, "UsbEnumerateNewDev: hub port %d is reset\n", Port));
-
Child = UsbCreateDevice (HubIf, Port);
if (Child == NULL) {
@@ -964,7 +968,11 @@ UsbEnumeratePort (
// Now, new device connected, enumerate and configure the device
//
DEBUG (( EFI_D_INFO, "UsbEnumeratePort: new device connected at port %d\n", Port));
- Status = UsbEnumerateNewDev (HubIf, Port);
+ if (USB_BIT_IS_SET (PortState.PortChangeStatus, USB_PORT_STAT_C_RESET)) {
+ Status = UsbEnumerateNewDev (HubIf, Port, FALSE);
+ } else {
+ Status = UsbEnumerateNewDev (HubIf, Port, TRUE);
+ }
} else {
DEBUG (( EFI_D_INFO, "UsbEnumeratePort: device disconnected event on port %d\n", Port));