diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c index b7fdb8dd48..a48b295d26 100644 --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c @@ -913,12 +913,22 @@ AtaAtapiPassThruStop ( // DestroyDeviceInfoList (Instance); + PciIo = Instance->PciIo; + + // + // Disable this ATA host controller. + // + PciIo->Attributes ( + PciIo, + EfiPciIoAttributeOperationDisable, + Instance->EnabledPciAttributes, + NULL + ); + // // 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 ( @@ -950,16 +960,6 @@ AtaAtapiPassThruStop ( ); } - // - // Disable this ATA host controller. - // - PciIo->Attributes ( - PciIo, - EfiPciIoAttributeOperationDisable, - Instance->EnabledPciAttributes, - NULL - ); - // // Restore original PCI attributes //