mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-27 15:44:04 +02:00
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 <feng.tian@intel.com> Reviewed-by: Elvin Li <elvin.li@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14927 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
6855763eb2
commit
0f58371b5d
@ -2049,13 +2049,6 @@ EhcDriverBindingStop (
|
|||||||
Ehc = EHC_FROM_THIS (Usb2Hc);
|
Ehc = EHC_FROM_THIS (Usb2Hc);
|
||||||
PciIo = Ehc->PciIo;
|
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 (
|
Status = gBS->UninstallProtocolInterface (
|
||||||
Controller,
|
Controller,
|
||||||
&gEfiUsb2HcProtocolGuid,
|
&gEfiUsb2HcProtocolGuid,
|
||||||
@ -2066,6 +2059,13 @@ EhcDriverBindingStop (
|
|||||||
return Status;
|
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) {
|
if (Ehc->PollTimer != NULL) {
|
||||||
gBS->CloseEvent (Ehc->PollTimer);
|
gBS->CloseEvent (Ehc->PollTimer);
|
||||||
}
|
}
|
||||||
|
@ -1550,19 +1550,24 @@ UhciCleanDevUp (
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
USB_HC_DEV *Uhc;
|
USB_HC_DEV *Uhc;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Uninstall the USB_HC and USB_HC2 protocol, then disable the controller
|
// Uninstall the USB_HC and USB_HC2 protocol, then disable the controller
|
||||||
//
|
//
|
||||||
Uhc = UHC_FROM_USB2_HC_PROTO (This);
|
Uhc = UHC_FROM_USB2_HC_PROTO (This);
|
||||||
|
|
||||||
|
|
||||||
|
Status = gBS->UninstallProtocolInterface (
|
||||||
|
Controller,
|
||||||
|
&gEfiUsb2HcProtocolGuid,
|
||||||
|
&Uhc->Usb2Hc
|
||||||
|
);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
UhciStopHc (Uhc, UHC_GENERIC_TIMEOUT);
|
UhciStopHc (Uhc, UHC_GENERIC_TIMEOUT);
|
||||||
|
|
||||||
gBS->UninstallProtocolInterface (
|
|
||||||
Controller,
|
|
||||||
&gEfiUsb2HcProtocolGuid,
|
|
||||||
&Uhc->Usb2Hc
|
|
||||||
);
|
|
||||||
|
|
||||||
UhciFreeAllAsyncReq (Uhc);
|
UhciFreeAllAsyncReq (Uhc);
|
||||||
UhciDestoryFrameList (Uhc);
|
UhciDestoryFrameList (Uhc);
|
||||||
|
|
||||||
|
@ -2129,6 +2129,16 @@ XhcDriverBindingStop (
|
|||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Status = gBS->UninstallProtocolInterface (
|
||||||
|
Controller,
|
||||||
|
&gEfiUsb2HcProtocolGuid,
|
||||||
|
Usb2Hc
|
||||||
|
);
|
||||||
|
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
Xhc = XHC_FROM_THIS (Usb2Hc);
|
Xhc = XHC_FROM_THIS (Usb2Hc);
|
||||||
PciIo = Xhc->PciIo;
|
PciIo = Xhc->PciIo;
|
||||||
|
|
||||||
@ -2154,19 +2164,6 @@ XhcDriverBindingStop (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XhcHaltHC (Xhc, XHC_GENERIC_TIMEOUT);
|
|
||||||
XhcClearBiosOwnership (Xhc);
|
|
||||||
|
|
||||||
Status = gBS->UninstallProtocolInterface (
|
|
||||||
Controller,
|
|
||||||
&gEfiUsb2HcProtocolGuid,
|
|
||||||
Usb2Hc
|
|
||||||
);
|
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Xhc->PollTimer != NULL) {
|
if (Xhc->PollTimer != NULL) {
|
||||||
gBS->CloseEvent (Xhc->PollTimer);
|
gBS->CloseEvent (Xhc->PollTimer);
|
||||||
}
|
}
|
||||||
@ -2175,6 +2172,8 @@ XhcDriverBindingStop (
|
|||||||
gBS->CloseEvent (Xhc->ExitBootServiceEvent);
|
gBS->CloseEvent (Xhc->ExitBootServiceEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XhcHaltHC (Xhc, XHC_GENERIC_TIMEOUT);
|
||||||
|
XhcClearBiosOwnership (Xhc);
|
||||||
XhciDelAllAsyncIntTransfers (Xhc);
|
XhciDelAllAsyncIntTransfers (Xhc);
|
||||||
XhcFreeSched (Xhc);
|
XhcFreeSched (Xhc);
|
||||||
|
|
||||||
|
@ -1402,6 +1402,7 @@ UsbBusControllerDriverStop (
|
|||||||
EFI_TPL OldTpl;
|
EFI_TPL OldTpl;
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
EFI_STATUS ReturnStatus;
|
||||||
|
|
||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
|
|
||||||
@ -1411,6 +1412,7 @@ UsbBusControllerDriverStop (
|
|||||||
//
|
//
|
||||||
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
|
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
|
||||||
|
|
||||||
|
ReturnStatus = EFI_SUCCESS;
|
||||||
for (Index = 0; Index < NumberOfChildren; Index++) {
|
for (Index = 0; Index < NumberOfChildren; Index++) {
|
||||||
Status = gBS->OpenProtocol (
|
Status = gBS->OpenProtocol (
|
||||||
ChildHandleBuffer[Index],
|
ChildHandleBuffer[Index],
|
||||||
@ -1434,11 +1436,11 @@ UsbBusControllerDriverStop (
|
|||||||
UsbIf = USB_INTERFACE_FROM_USBIO (UsbIo);
|
UsbIf = USB_INTERFACE_FROM_USBIO (UsbIo);
|
||||||
UsbDev = UsbIf->Device;
|
UsbDev = UsbIf->Device;
|
||||||
|
|
||||||
UsbRemoveDevice (UsbDev);
|
ReturnStatus = UsbRemoveDevice (UsbDev);
|
||||||
}
|
}
|
||||||
|
|
||||||
gBS->RestoreTPL (OldTpl);
|
gBS->RestoreTPL (OldTpl);
|
||||||
return EFI_SUCCESS;
|
return ReturnStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG (( EFI_D_INFO, "UsbBusStop: usb bus stopped on %p\n", Controller));
|
DEBUG (( EFI_D_INFO, "UsbBusStop: usb bus stopped on %p\n", Controller));
|
||||||
@ -1471,53 +1473,60 @@ UsbBusControllerDriverStop (
|
|||||||
RootHub = Bus->Devices[0];
|
RootHub = Bus->Devices[0];
|
||||||
RootIf = RootHub->Interfaces[0];
|
RootIf = RootHub->Interfaces[0];
|
||||||
|
|
||||||
mUsbRootHubApi.Release (RootIf);
|
|
||||||
|
|
||||||
ASSERT (Bus->MaxDevices <= 256);
|
ASSERT (Bus->MaxDevices <= 256);
|
||||||
|
ReturnStatus = EFI_SUCCESS;
|
||||||
for (Index = 1; Index < Bus->MaxDevices; Index++) {
|
for (Index = 1; Index < Bus->MaxDevices; Index++) {
|
||||||
if (Bus->Devices[Index] != NULL) {
|
if (Bus->Devices[Index] != NULL) {
|
||||||
UsbRemoveDevice (Bus->Devices[Index]);
|
Status = UsbRemoveDevice (Bus->Devices[Index]);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
ReturnStatus = Status;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gBS->RestoreTPL (OldTpl);
|
gBS->RestoreTPL (OldTpl);
|
||||||
|
|
||||||
gBS->FreePool (RootIf);
|
if (!EFI_ERROR (ReturnStatus)) {
|
||||||
gBS->FreePool (RootHub);
|
mUsbRootHubApi.Release (RootIf);
|
||||||
Status = UsbBusFreeUsbDPList (&Bus->WantedUsbIoDPList);
|
gBS->FreePool (RootIf);
|
||||||
ASSERT (!EFI_ERROR (Status));
|
gBS->FreePool (RootHub);
|
||||||
|
|
||||||
//
|
Status = UsbBusFreeUsbDPList (&Bus->WantedUsbIoDPList);
|
||||||
// Uninstall the bus identifier and close USB_HC/USB2_HC protocols
|
ASSERT (!EFI_ERROR (Status));
|
||||||
//
|
|
||||||
gBS->UninstallProtocolInterface (Controller, &gEfiCallerIdGuid, &Bus->BusId);
|
|
||||||
|
|
||||||
if (Bus->Usb2Hc != NULL) {
|
//
|
||||||
gBS->CloseProtocol (
|
// Uninstall the bus identifier and close USB_HC/USB2_HC protocols
|
||||||
Controller,
|
//
|
||||||
&gEfiUsb2HcProtocolGuid,
|
gBS->UninstallProtocolInterface (Controller, &gEfiCallerIdGuid, &Bus->BusId);
|
||||||
This->DriverBindingHandle,
|
|
||||||
Controller
|
if (Bus->Usb2Hc != NULL) {
|
||||||
);
|
Status = gBS->CloseProtocol (
|
||||||
|
Controller,
|
||||||
|
&gEfiUsb2HcProtocolGuid,
|
||||||
|
This->DriverBindingHandle,
|
||||||
|
Controller
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Bus->UsbHc != NULL) {
|
||||||
|
Status = gBS->CloseProtocol (
|
||||||
|
Controller,
|
||||||
|
&gEfiUsbHcProtocolGuid,
|
||||||
|
This->DriverBindingHandle,
|
||||||
|
Controller
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!EFI_ERROR (Status)) {
|
||||||
|
gBS->CloseProtocol (
|
||||||
|
Controller,
|
||||||
|
&gEfiDevicePathProtocolGuid,
|
||||||
|
This->DriverBindingHandle,
|
||||||
|
Controller
|
||||||
|
);
|
||||||
|
|
||||||
|
gBS->FreePool (Bus);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Bus->UsbHc != NULL) {
|
|
||||||
gBS->CloseProtocol (
|
|
||||||
Controller,
|
|
||||||
&gEfiUsbHcProtocolGuid,
|
|
||||||
This->DriverBindingHandle,
|
|
||||||
Controller
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
gBS->CloseProtocol (
|
|
||||||
Controller,
|
|
||||||
&gEfiDevicePathProtocolGuid,
|
|
||||||
This->DriverBindingHandle,
|
|
||||||
Controller
|
|
||||||
);
|
|
||||||
|
|
||||||
gBS->FreePool (Bus);
|
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user