From: Laszlo Ersek Date: Thu, 7 Sep 2017 18:56:39 +0000 (+0200) Subject: MdeModulePkg/AtaAtapiPassThru: cache EnabledPciAttributes X-Git-Tag: edk2-stable201903~3465 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=eed3f713052204e31f1c4703ef544897881c552e MdeModulePkg/AtaAtapiPassThru: cache EnabledPciAttributes Both AtaAtapiPassThruStart() and AtaAtapiPassThruStop() fetch the supported attributes of the device, just so they can toggle the IO+MMIO+BusMaster subset. After we compute this bitmask in AtaAtapiPassThruStart(), we can cache it for later, and save the fetch in AtaAtapiPassThruStop(). Cc: Ard Biesheuvel Cc: Brijesh Singh Cc: Eric Dong Cc: Jiewen Yao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek Reviewed-by: Jiewen Yao Reviewed-by: Star Zeng Reviewed-by: Ard Biesheuvel --- diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c index 795443ef74..b7fdb8dd48 100644 --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c @@ -94,6 +94,7 @@ ATA_ATAPI_PASS_THRU_INSTANCE gAtaAtapiPassThruInstanceTemplate = { NULL, NULL }, + 0, // EnabledPciAttributes 0, // OriginalAttributes 0, // PreviousPort 0, // PreviousPortMultiplier @@ -670,7 +671,7 @@ AtaAtapiPassThruStart ( EFI_IDE_CONTROLLER_INIT_PROTOCOL *IdeControllerInit; ATA_ATAPI_PASS_THRU_INSTANCE *Instance; EFI_PCI_IO_PROTOCOL *PciIo; - UINT64 Supports; + UINT64 EnabledPciAttributes; UINT64 OriginalPciAttributes; Status = EFI_SUCCESS; @@ -722,14 +723,14 @@ AtaAtapiPassThruStart ( PciIo, EfiPciIoAttributeOperationSupported, 0, - &Supports + &EnabledPciAttributes ); if (!EFI_ERROR (Status)) { - Supports &= (UINT64)EFI_PCI_DEVICE_ENABLE; + EnabledPciAttributes &= (UINT64)EFI_PCI_DEVICE_ENABLE; Status = PciIo->Attributes ( PciIo, EfiPciIoAttributeOperationEnable, - Supports, + EnabledPciAttributes, NULL ); } @@ -749,6 +750,7 @@ AtaAtapiPassThruStart ( Instance->ControllerHandle = Controller; Instance->IdeControllerInit = IdeControllerInit; Instance->PciIo = PciIo; + Instance->EnabledPciAttributes = EnabledPciAttributes; Instance->OriginalPciAttributes = OriginalPciAttributes; Instance->AtaPassThru.Mode = &Instance->AtaPassThruMode; Instance->ExtScsiPassThru.Mode = &Instance->ExtScsiPassThruMode; @@ -859,7 +861,6 @@ AtaAtapiPassThruStop ( EFI_ATA_PASS_THRU_PROTOCOL *AtaPassThru; EFI_PCI_IO_PROTOCOL *PciIo; EFI_AHCI_REGISTERS *AhciRegisters; - UINT64 Supports; DEBUG ((EFI_D_INFO, "==AtaAtapiPassThru Stop== Controller = %x\n", Controller)); @@ -952,21 +953,12 @@ AtaAtapiPassThruStop ( // // Disable this ATA host controller. // - Status = PciIo->Attributes ( - PciIo, - EfiPciIoAttributeOperationSupported, - 0, - &Supports - ); - if (!EFI_ERROR (Status)) { - Supports &= (UINT64)EFI_PCI_DEVICE_ENABLE; - PciIo->Attributes ( - PciIo, - EfiPciIoAttributeOperationDisable, - Supports, - NULL - ); - } + PciIo->Attributes ( + PciIo, + EfiPciIoAttributeOperationDisable, + Instance->EnabledPciAttributes, + NULL + ); // // Restore original PCI attributes diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h index 4f327dc30b..85e5a55539 100644 --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h @@ -100,6 +100,7 @@ typedef struct { // The attached device list // LIST_ENTRY DeviceList; + UINT64 EnabledPciAttributes; UINT64 OriginalPciAttributes; //