Revision: 14927
http://sourceforge.net/p/edk2/code/14927
Author: erictian
Date: 2013-12-03 07:04:08 +0000 (Tue, 03 Dec 2013)
Log Message:
-----------
MdeModulePkg/Usb: All h/w related stop operation at DriverBindingStop() should
be behind s/w related stop operation, which could avoid h/w not working if s/w
stop operation fails.
Signed-off-by: Feng Tian <[email protected]>
Reviewed-by: Elvin Li <[email protected]>
Modified Paths:
--------------
trunk/edk2/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c
trunk/edk2/MdeModulePkg/Bus/Pci/UhciDxe/Uhci.c
trunk/edk2/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
trunk/edk2/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c
Modified: trunk/edk2/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c
===================================================================
--- trunk/edk2/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c 2013-12-02 21:45:28 UTC
(rev 14926)
+++ trunk/edk2/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c 2013-12-03 07:04:08 UTC
(rev 14927)
@@ -2049,13 +2049,6 @@
Ehc = EHC_FROM_THIS (Usb2Hc);
PciIo = Ehc->PciIo;
- //
- // Stop AsyncRequest Polling timer then stop the EHCI driver
- // and uninstall the EHCI protocl.
- //
- gBS->SetTimer (Ehc->PollTimer, TimerCancel, EHC_ASYNC_POLL_INTERVAL);
- EhcHaltHC (Ehc, EHC_GENERIC_TIMEOUT);
-
Status = gBS->UninstallProtocolInterface (
Controller,
&gEfiUsb2HcProtocolGuid,
@@ -2066,6 +2059,13 @@
return Status;
}
+ //
+ // Stop AsyncRequest Polling timer then stop the EHCI driver
+ // and uninstall the EHCI protocl.
+ //
+ gBS->SetTimer (Ehc->PollTimer, TimerCancel, EHC_ASYNC_POLL_INTERVAL);
+ EhcHaltHC (Ehc, EHC_GENERIC_TIMEOUT);
+
if (Ehc->PollTimer != NULL) {
gBS->CloseEvent (Ehc->PollTimer);
}
Modified: trunk/edk2/MdeModulePkg/Bus/Pci/UhciDxe/Uhci.c
===================================================================
--- trunk/edk2/MdeModulePkg/Bus/Pci/UhciDxe/Uhci.c 2013-12-02 21:45:28 UTC
(rev 14926)
+++ trunk/edk2/MdeModulePkg/Bus/Pci/UhciDxe/Uhci.c 2013-12-03 07:04:08 UTC
(rev 14927)
@@ -1550,19 +1550,24 @@
)
{
USB_HC_DEV *Uhc;
+ EFI_STATUS Status;
//
// Uninstall the USB_HC and USB_HC2 protocol, then disable the controller
//
Uhc = UHC_FROM_USB2_HC_PROTO (This);
- UhciStopHc (Uhc, UHC_GENERIC_TIMEOUT);
- gBS->UninstallProtocolInterface (
- Controller,
- &gEfiUsb2HcProtocolGuid,
- &Uhc->Usb2Hc
- );
+ Status = gBS->UninstallProtocolInterface (
+ Controller,
+ &gEfiUsb2HcProtocolGuid,
+ &Uhc->Usb2Hc
+ );
+ if (EFI_ERROR (Status)) {
+ return ;
+ }
+
+ UhciStopHc (Uhc, UHC_GENERIC_TIMEOUT);
UhciFreeAllAsyncReq (Uhc);
UhciDestoryFrameList (Uhc);
Modified: trunk/edk2/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
===================================================================
--- trunk/edk2/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c 2013-12-02 21:45:28 UTC
(rev 14926)
+++ trunk/edk2/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c 2013-12-03 07:04:08 UTC
(rev 14927)
@@ -2129,6 +2129,16 @@
return Status;
}
+ Status = gBS->UninstallProtocolInterface (
+ Controller,
+ &gEfiUsb2HcProtocolGuid,
+ Usb2Hc
+ );
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
Xhc = XHC_FROM_THIS (Usb2Hc);
PciIo = Xhc->PciIo;
@@ -2154,19 +2164,6 @@
}
}
- XhcHaltHC (Xhc, XHC_GENERIC_TIMEOUT);
- XhcClearBiosOwnership (Xhc);
-
- Status = gBS->UninstallProtocolInterface (
- Controller,
- &gEfiUsb2HcProtocolGuid,
- Usb2Hc
- );
-
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
if (Xhc->PollTimer != NULL) {
gBS->CloseEvent (Xhc->PollTimer);
}
@@ -2175,6 +2172,8 @@
gBS->CloseEvent (Xhc->ExitBootServiceEvent);
}
+ XhcHaltHC (Xhc, XHC_GENERIC_TIMEOUT);
+ XhcClearBiosOwnership (Xhc);
XhciDelAllAsyncIntTransfers (Xhc);
XhcFreeSched (Xhc);
Modified: trunk/edk2/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c
===================================================================
--- trunk/edk2/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c 2013-12-02 21:45:28 UTC
(rev 14926)
+++ trunk/edk2/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c 2013-12-03 07:04:08 UTC
(rev 14927)
@@ -1402,6 +1402,7 @@
EFI_TPL OldTpl;
UINTN Index;
EFI_STATUS Status;
+ EFI_STATUS ReturnStatus;
Status = EFI_SUCCESS;
@@ -1411,6 +1412,7 @@
//
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
+ ReturnStatus = EFI_SUCCESS;
for (Index = 0; Index < NumberOfChildren; Index++) {
Status = gBS->OpenProtocol (
ChildHandleBuffer[Index],
@@ -1434,11 +1436,11 @@
UsbIf = USB_INTERFACE_FROM_USBIO (UsbIo);
UsbDev = UsbIf->Device;
- UsbRemoveDevice (UsbDev);
+ ReturnStatus = UsbRemoveDevice (UsbDev);
}
gBS->RestoreTPL (OldTpl);
- return EFI_SUCCESS;
+ return ReturnStatus;
}
DEBUG (( EFI_D_INFO, "UsbBusStop: usb bus stopped on %p\n", Controller));
@@ -1471,53 +1473,60 @@
RootHub = Bus->Devices[0];
RootIf = RootHub->Interfaces[0];
- mUsbRootHubApi.Release (RootIf);
-
ASSERT (Bus->MaxDevices <= 256);
+ ReturnStatus = EFI_SUCCESS;
for (Index = 1; Index < Bus->MaxDevices; Index++) {
if (Bus->Devices[Index] != NULL) {
- UsbRemoveDevice (Bus->Devices[Index]);
+ Status = UsbRemoveDevice (Bus->Devices[Index]);
+ if (EFI_ERROR (Status)) {
+ ReturnStatus = Status;
+ }
}
}
gBS->RestoreTPL (OldTpl);
- gBS->FreePool (RootIf);
- gBS->FreePool (RootHub);
- Status = UsbBusFreeUsbDPList (&Bus->WantedUsbIoDPList);
- ASSERT (!EFI_ERROR (Status));
+ if (!EFI_ERROR (ReturnStatus)) {
+ mUsbRootHubApi.Release (RootIf);
+ gBS->FreePool (RootIf);
+ gBS->FreePool (RootHub);
- //
- // Uninstall the bus identifier and close USB_HC/USB2_HC protocols
- //
- gBS->UninstallProtocolInterface (Controller, &gEfiCallerIdGuid, &Bus->BusId);
+ Status = UsbBusFreeUsbDPList (&Bus->WantedUsbIoDPList);
+ ASSERT (!EFI_ERROR (Status));
- if (Bus->Usb2Hc != NULL) {
- gBS->CloseProtocol (
- Controller,
- &gEfiUsb2HcProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- }
+ //
+ // Uninstall the bus identifier and close USB_HC/USB2_HC protocols
+ //
+ gBS->UninstallProtocolInterface (Controller, &gEfiCallerIdGuid,
&Bus->BusId);
- if (Bus->UsbHc != NULL) {
- gBS->CloseProtocol (
- Controller,
- &gEfiUsbHcProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- }
+ if (Bus->Usb2Hc != NULL) {
+ Status = gBS->CloseProtocol (
+ Controller,
+ &gEfiUsb2HcProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
+ }
- gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ if (Bus->UsbHc != NULL) {
+ Status = gBS->CloseProtocol (
+ Controller,
+ &gEfiUsbHcProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
+ }
- gBS->FreePool (Bus);
+ if (!EFI_ERROR (Status)) {
+ gBS->CloseProtocol (
+ Controller,
+ &gEfiDevicePathProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
+ gBS->FreePool (Bus);
+ }
+ }
return Status;
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits