summaryrefslogtreecommitdiffstats
path: root/PcAtChipsetPkg
diff options
context:
space:
mode:
authorRuiyu Ni <ruiyu.ni@intel.com>2017-11-02 09:21:56 +0800
committerRuiyu Ni <ruiyu.ni@intel.com>2017-11-08 11:42:45 +0800
commitcb68247d5c47c5adb667ed7433c6610641edbf95 (patch)
tree7b192dc43f46d98746f63c13defbb19435626621 /PcAtChipsetPkg
parent7046610163d3dd0f6b410ae0b3a564917db4ed0a (diff)
downloadedk2-cb68247d5c47c5adb667ed7433c6610641edbf95.tar.gz
edk2-cb68247d5c47c5adb667ed7433c6610641edbf95.tar.bz2
edk2-cb68247d5c47c5adb667ed7433c6610641edbf95.zip
PcAtChipsetPkg/IsaAcpiDxe: Restore PCI attributes correctly
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=405 The original code enables some BITs in PCI attributes in Start(), but wrongly to disable these BITs in Stop(). The correct behavior is to save the original PCI attributes before enables some BITs in Start(), and restore to original value in Stop(). Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Diffstat (limited to 'PcAtChipsetPkg')
-rw-r--r--PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.c48
-rw-r--r--PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.h3
2 files changed, 27 insertions, 24 deletions
diff --git a/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.c b/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.c
index 32381b112d..d82e2c4641 100644
--- a/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.c
+++ b/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.c
@@ -1,7 +1,7 @@
/** @file
EFI PCAT ISA ACPI Driver for a Generic PC Platform
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -172,6 +172,7 @@ PcatIsaAcpiDriverBindingStart (
EFI_PCI_IO_PROTOCOL *PciIo;
PCAT_ISA_ACPI_DEV *PcatIsaAcpiDev;
UINT64 Supports;
+ UINT64 OriginalAttributes;
BOOLEAN Enabled;
Enabled = FALSE;
@@ -210,9 +211,18 @@ PcatIsaAcpiDriverBindingStart (
if (Supports == 0 || Supports == (EFI_PCI_IO_ATTRIBUTE_ISA_IO | EFI_PCI_IO_ATTRIBUTE_ISA_IO_16)) {
Status = EFI_UNSUPPORTED;
goto Done;
- }
+ }
+
+ Status = PciIo->Attributes (
+ PciIo,
+ EfiPciIoAttributeOperationGet,
+ 0,
+ &OriginalAttributes
+ );
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
- Enabled = TRUE;
Status = PciIo->Attributes (
PciIo,
EfiPciIoAttributeOperationEnable,
@@ -222,7 +232,8 @@ PcatIsaAcpiDriverBindingStart (
if (EFI_ERROR (Status)) {
goto Done;
}
-
+
+ Enabled = TRUE;
//
// Allocate memory for the PCAT ISA ACPI Device structure
//
@@ -239,9 +250,10 @@ PcatIsaAcpiDriverBindingStart (
//
// Initialize the PCAT ISA ACPI Device structure
//
- PcatIsaAcpiDev->Signature = PCAT_ISA_ACPI_DEV_SIGNATURE;
- PcatIsaAcpiDev->Handle = Controller;
- PcatIsaAcpiDev->PciIo = PciIo;
+ PcatIsaAcpiDev->Signature = PCAT_ISA_ACPI_DEV_SIGNATURE;
+ PcatIsaAcpiDev->Handle = Controller;
+ PcatIsaAcpiDev->PciIo = PciIo;
+ PcatIsaAcpiDev->OriginalAttributes = OriginalAttributes;
//
// Initialize PcatIsaAcpiDeviceList
@@ -274,8 +286,8 @@ Done:
if (PciIo != NULL && Enabled) {
PciIo->Attributes (
PciIo,
- EfiPciIoAttributeOperationDisable,
- EFI_PCI_DEVICE_ENABLE | Supports | EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO,
+ EfiPciIoAttributeOperationSet,
+ OriginalAttributes,
NULL
);
}
@@ -321,7 +333,6 @@ PcatIsaAcpiDriverBindingStop (
EFI_STATUS Status;
EFI_ISA_ACPI_PROTOCOL *IsaAcpi;
PCAT_ISA_ACPI_DEV *PcatIsaAcpiDev;
- UINT64 Supports;
//
// Get the ISA ACPI Protocol Interface
@@ -344,27 +355,18 @@ PcatIsaAcpiDriverBindingStop (
PcatIsaAcpiDev = PCAT_ISA_ACPI_DEV_FROM_THIS (IsaAcpi);
//
- // Get supported PCI attributes
+ // Restore PCI attributes
//
Status = PcatIsaAcpiDev->PciIo->Attributes (
PcatIsaAcpiDev->PciIo,
- EfiPciIoAttributeOperationSupported,
- 0,
- &Supports
+ EfiPciIoAttributeOperationSet,
+ PcatIsaAcpiDev->OriginalAttributes,
+ NULL
);
if (EFI_ERROR (Status)) {
return Status;
}
- Supports &= (UINT64) (EFI_PCI_IO_ATTRIBUTE_ISA_IO | EFI_PCI_IO_ATTRIBUTE_ISA_IO_16);
-
- PcatIsaAcpiDev->PciIo->Attributes (
- PcatIsaAcpiDev->PciIo,
- EfiPciIoAttributeOperationDisable,
- EFI_PCI_DEVICE_ENABLE | Supports | EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO,
- NULL
- );
-
//
// Uninstall protocol interface: EFI_ISA_ACPI_PROTOCOL
//
diff --git a/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.h b/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.h
index 0671127644..d48c5882d5 100644
--- a/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.h
+++ b/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.h
@@ -1,7 +1,7 @@
/** @file
EFI PCAT ISA ACPI Driver for a Generic PC Platform
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -43,6 +43,7 @@ typedef struct {
EFI_HANDLE Handle;
EFI_ISA_ACPI_PROTOCOL IsaAcpi;
EFI_PCI_IO_PROTOCOL *PciIo;
+ UINT64 OriginalAttributes;
} PCAT_ISA_ACPI_DEV;
#define PCAT_ISA_ACPI_DEV_FROM_THIS(a) BASE_CR(a, PCAT_ISA_ACPI_DEV, IsaAcpi)