In AtaAtapiPassThruStop(), if the device has been operating in AHCI mode, we unmap the DMA buffers and then disable the device (including bus master DMA). The order of these actions is wrong; we shouldn't unmap DMA buffers until bus master DMA is turned off. Reverse the steps.
Cc: Ard Biesheuvel <[email protected]> Cc: Brijesh Singh <[email protected]> Cc: Eric Dong <[email protected]> Cc: Jiewen Yao <[email protected]> Cc: Star Zeng <[email protected]> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek <[email protected]> --- MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c | 24 ++++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c index b7fdb8dd4876..a48b295d26aa 100644 --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c @@ -911,16 +911,26 @@ AtaAtapiPassThruStop ( // // Free allocated resource // 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 ( PciIo, AhciRegisters->MapCommandTable @@ -948,20 +958,10 @@ AtaAtapiPassThruStop ( EFI_SIZE_TO_PAGES ((UINTN) AhciRegisters->MaxReceiveFisSize), AhciRegisters->AhciRFis ); } - // - // Disable this ATA host controller. - // - PciIo->Attributes ( - PciIo, - EfiPciIoAttributeOperationDisable, - Instance->EnabledPciAttributes, - NULL - ); - // // Restore original PCI attributes // Status = PciIo->Attributes ( PciIo, -- 2.14.1.3.gb7cf6e02401b _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

