mirror of https://github.com/acidanthera/audk.git
MdeModulePkg/AtaAtapiPassThru: Error handling enhancement for uninstalling protocol interface failure case
Signed-off-by: Feng Tian <feng.tian@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14928 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
0f58371b5d
commit
32e817c995
|
@ -870,53 +870,17 @@ AtaAtapiPassThruStop (
|
|||
|
||||
Instance = ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS (AtaPassThru);
|
||||
|
||||
//
|
||||
// Close Non-Blocking timer and free Task list.
|
||||
//
|
||||
if (Instance->TimerEvent != NULL) {
|
||||
gBS->CloseEvent (Instance->TimerEvent);
|
||||
Instance->TimerEvent = NULL;
|
||||
}
|
||||
DestroyAsynTaskList (Instance, FALSE);
|
||||
|
||||
//
|
||||
// Disable this ATA host controller.
|
||||
//
|
||||
PciIo = Instance->PciIo;
|
||||
Status = PciIo->Attributes (
|
||||
PciIo,
|
||||
EfiPciIoAttributeOperationSupported,
|
||||
0,
|
||||
&Supports
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Supports &= EFI_PCI_DEVICE_ENABLE;
|
||||
PciIo->Attributes (
|
||||
PciIo,
|
||||
EfiPciIoAttributeOperationDisable,
|
||||
Supports,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Restore original PCI attributes
|
||||
//
|
||||
Status = PciIo->Attributes (
|
||||
PciIo,
|
||||
EfiPciIoAttributeOperationSet,
|
||||
Instance->OriginalPciAttributes,
|
||||
NULL
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
gBS->UninstallMultipleProtocolInterfaces (
|
||||
Status = gBS->UninstallMultipleProtocolInterfaces (
|
||||
Controller,
|
||||
&gEfiAtaPassThruProtocolGuid, &(Instance->AtaPassThru),
|
||||
&gEfiExtScsiPassThruProtocolGuid, &(Instance->ExtScsiPassThru),
|
||||
NULL
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Close protocols opened by AtaAtapiPassThru controller driver
|
||||
//
|
||||
|
@ -927,6 +891,14 @@ AtaAtapiPassThruStop (
|
|||
Controller
|
||||
);
|
||||
|
||||
//
|
||||
// Close Non-Blocking timer and free Task list.
|
||||
//
|
||||
if (Instance->TimerEvent != NULL) {
|
||||
gBS->CloseEvent (Instance->TimerEvent);
|
||||
Instance->TimerEvent = NULL;
|
||||
}
|
||||
DestroyAsynTaskList (Instance, FALSE);
|
||||
//
|
||||
// Free allocated resource
|
||||
//
|
||||
|
@ -936,6 +908,8 @@ AtaAtapiPassThruStop (
|
|||
// If the current working mode is AHCI mode, then pre-allocated resource
|
||||
// for AHCI initialization should be released.
|
||||
//
|
||||
PciIo = Instance->PciIo;
|
||||
|
||||
if (Instance->Mode == EfiAtaAhciMode) {
|
||||
AhciRegisters = &Instance->AhciRegisters;
|
||||
PciIo->Unmap (
|
||||
|
@ -966,6 +940,37 @@ AtaAtapiPassThruStop (
|
|||
AhciRegisters->AhciRFis
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Disable this ATA host controller.
|
||||
//
|
||||
Status = PciIo->Attributes (
|
||||
PciIo,
|
||||
EfiPciIoAttributeOperationSupported,
|
||||
0,
|
||||
&Supports
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Supports &= EFI_PCI_DEVICE_ENABLE;
|
||||
PciIo->Attributes (
|
||||
PciIo,
|
||||
EfiPciIoAttributeOperationDisable,
|
||||
Supports,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Restore original PCI attributes
|
||||
//
|
||||
Status = PciIo->Attributes (
|
||||
PciIo,
|
||||
EfiPciIoAttributeOperationSet,
|
||||
Instance->OriginalPciAttributes,
|
||||
NULL
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
FreePool (Instance);
|
||||
|
||||
return Status;
|
||||
|
|
Loading…
Reference in New Issue