]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/AtaAtapiPassThru: cache EnabledPciAttributes
authorLaszlo Ersek <lersek@redhat.com>
Thu, 7 Sep 2017 18:56:39 +0000 (20:56 +0200)
committerLaszlo Ersek <lersek@redhat.com>
Fri, 8 Sep 2017 18:22:32 +0000 (20:22 +0200)
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 <ard.biesheuvel@linaro.org>
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c
MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h

index 795443ef74f63cbf18d53e0d5559402e2da03d17..b7fdb8dd487629e4e4ffc4dd4e62d2907bdeec08 100644 (file)
@@ -94,6 +94,7 @@ ATA_ATAPI_PASS_THRU_INSTANCE gAtaAtapiPassThruInstanceTemplate = {
     NULL,\r
     NULL\r
   },\r
+  0,                  // EnabledPciAttributes\r
   0,                  // OriginalAttributes\r
   0,                  // PreviousPort\r
   0,                  // PreviousPortMultiplier\r
@@ -670,7 +671,7 @@ AtaAtapiPassThruStart (
   EFI_IDE_CONTROLLER_INIT_PROTOCOL  *IdeControllerInit;\r
   ATA_ATAPI_PASS_THRU_INSTANCE      *Instance;\r
   EFI_PCI_IO_PROTOCOL               *PciIo;\r
-  UINT64                            Supports;\r
+  UINT64                            EnabledPciAttributes;\r
   UINT64                            OriginalPciAttributes;\r
 \r
   Status                = EFI_SUCCESS;\r
@@ -722,14 +723,14 @@ AtaAtapiPassThruStart (
                     PciIo,\r
                     EfiPciIoAttributeOperationSupported,\r
                     0,\r
-                    &Supports\r
+                    &EnabledPciAttributes\r
                     );\r
   if (!EFI_ERROR (Status)) {\r
-    Supports &= (UINT64)EFI_PCI_DEVICE_ENABLE;\r
+    EnabledPciAttributes &= (UINT64)EFI_PCI_DEVICE_ENABLE;\r
     Status = PciIo->Attributes (\r
                       PciIo,\r
                       EfiPciIoAttributeOperationEnable,\r
-                      Supports,\r
+                      EnabledPciAttributes,\r
                       NULL\r
                       );\r
   }\r
@@ -749,6 +750,7 @@ AtaAtapiPassThruStart (
   Instance->ControllerHandle      = Controller;\r
   Instance->IdeControllerInit     = IdeControllerInit;\r
   Instance->PciIo                 = PciIo;\r
+  Instance->EnabledPciAttributes  = EnabledPciAttributes;\r
   Instance->OriginalPciAttributes = OriginalPciAttributes;\r
   Instance->AtaPassThru.Mode      = &Instance->AtaPassThruMode;\r
   Instance->ExtScsiPassThru.Mode  = &Instance->ExtScsiPassThruMode;\r
@@ -859,7 +861,6 @@ AtaAtapiPassThruStop (
   EFI_ATA_PASS_THRU_PROTOCOL        *AtaPassThru;\r
   EFI_PCI_IO_PROTOCOL               *PciIo;\r
   EFI_AHCI_REGISTERS                *AhciRegisters;\r
-  UINT64                            Supports;\r
 \r
   DEBUG ((EFI_D_INFO, "==AtaAtapiPassThru Stop== Controller = %x\n", Controller));\r
 \r
@@ -952,21 +953,12 @@ AtaAtapiPassThruStop (
   //\r
   // Disable this ATA host controller.\r
   //\r
-  Status = PciIo->Attributes (\r
-                    PciIo,\r
-                    EfiPciIoAttributeOperationSupported,\r
-                    0,\r
-                    &Supports\r
-                    );\r
-  if (!EFI_ERROR (Status)) {\r
-    Supports &= (UINT64)EFI_PCI_DEVICE_ENABLE;\r
-    PciIo->Attributes (\r
-             PciIo,\r
-             EfiPciIoAttributeOperationDisable,\r
-             Supports,\r
-             NULL\r
-             );\r
-  }\r
+  PciIo->Attributes (\r
+           PciIo,\r
+           EfiPciIoAttributeOperationDisable,\r
+           Instance->EnabledPciAttributes,\r
+           NULL\r
+           );\r
 \r
   //\r
   // Restore original PCI attributes\r
index 4f327dc30b60b6bee78ceae1e48d1b69365d313e..85e5a555395347966015fb10f0e9aa45cef1a268 100644 (file)
@@ -100,6 +100,7 @@ typedef struct {
   // The attached device list\r
   //\r
   LIST_ENTRY                        DeviceList;\r
+  UINT64                            EnabledPciAttributes;\r
   UINT64                            OriginalPciAttributes;\r
 \r
   //\r