From nobody Mon Apr 29 21:13:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1509697725421127.17835391885933; Fri, 3 Nov 2017 01:28:45 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id DD85D21F7F5D8; Fri, 3 Nov 2017 01:24:48 -0700 (PDT) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id CFD7D202E6182 for ; Fri, 3 Nov 2017 01:24:46 -0700 (PDT) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Nov 2017 01:28:40 -0700 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.7]) by orsmga004.jf.intel.com with ESMTP; 03 Nov 2017 01:28:39 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.88; helo=mga01.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,337,1505804400"; d="scan'208";a="145504455" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Fri, 3 Nov 2017 16:28:36 +0800 Message-Id: <20171103082836.125696-1-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.12.2.windows.2 Subject: [edk2] [PATCH] PcAtChipsetPkg/IsaAcpiDxe: Restore PCI attributes correctly X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laszlo Ersek , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 Cc: Star Zeng Cc: Laszlo Ersek Reviewed-by: Laszlo Ersek --- PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.c | 44 +++++++++++++++++------------= ---- PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.h | 3 ++- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.c b/PcAtChipsetPkg/IsaAc= piDxe/PcatIsaAcpi.c index 32381b112d..60d2fb5a5b 100644 --- a/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.c +++ b/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.c @@ -172,6 +172,7 @@ PcatIsaAcpiDriverBindingStart ( EFI_PCI_IO_PROTOCOL *PciIo; PCAT_ISA_ACPI_DEV *PcatIsaAcpiDev; UINT64 Supports; + UINT64 OriginalAttributes; BOOLEAN Enabled; =20 Enabled =3D FALSE; @@ -210,9 +211,18 @@ PcatIsaAcpiDriverBindingStart ( if (Supports =3D=3D 0 || Supports =3D=3D (EFI_PCI_IO_ATTRIBUTE_ISA_IO | = EFI_PCI_IO_ATTRIBUTE_ISA_IO_16)) { Status =3D EFI_UNSUPPORTED; goto Done; - } =20 + } + + Status =3D PciIo->Attributes ( + PciIo, + EfiPciIoAttributeOperationGet, + 0, + &OriginalAttributes + ); + if (EFI_ERROR (Status)) { + goto Done; + } =20 - Enabled =3D TRUE; Status =3D PciIo->Attributes ( PciIo,=20 EfiPciIoAttributeOperationEnable,=20 @@ -222,7 +232,8 @@ PcatIsaAcpiDriverBindingStart ( if (EFI_ERROR (Status)) { goto Done; } - =20 + + Enabled =3D TRUE; // // Allocate memory for the PCAT ISA ACPI Device structure // @@ -239,9 +250,10 @@ PcatIsaAcpiDriverBindingStart ( // // Initialize the PCAT ISA ACPI Device structure // - PcatIsaAcpiDev->Signature =3D PCAT_ISA_ACPI_DEV_SIGNATURE; - PcatIsaAcpiDev->Handle =3D Controller; - PcatIsaAcpiDev->PciIo =3D PciIo; + PcatIsaAcpiDev->Signature =3D PCAT_ISA_ACPI_DEV_SIGNATURE; + PcatIsaAcpiDev->Handle =3D Controller; + PcatIsaAcpiDev->PciIo =3D PciIo; + PcatIsaAcpiDev->OriginalAttribute =3D OriginalAttributes; =20 // // Initialize PcatIsaAcpiDeviceList @@ -274,8 +286,8 @@ Done: if (PciIo !=3D NULL && Enabled) { PciIo->Attributes ( PciIo,=20 - EfiPciIoAttributeOperationDisable,=20 - EFI_PCI_DEVICE_ENABLE | Supports | EFI_PCI_IO_ATTRIBUTE_ISA= _MOTHERBOARD_IO, + EfiPciIoAttributeOperationSet,=20 + OriginalAttributes, NULL=20 ); } @@ -321,7 +333,6 @@ PcatIsaAcpiDriverBindingStop ( EFI_STATUS Status; EFI_ISA_ACPI_PROTOCOL *IsaAcpi; PCAT_ISA_ACPI_DEV *PcatIsaAcpiDev; - UINT64 Supports; =20 // // Get the ISA ACPI Protocol Interface @@ -348,23 +359,14 @@ PcatIsaAcpiDriverBindingStop ( // Status =3D PcatIsaAcpiDev->PciIo->Attributes ( PcatIsaAcpiDev->PciIo, - EfiPciIoAttributeOperationSupported, - 0, - &Supports + EfiPciIoAttributeOperationSet, + PcatIsaAcpiDev->OriginalAttribute, + 0 ); if (EFI_ERROR (Status)) { return Status; } =20 - Supports &=3D (UINT64) (EFI_PCI_IO_ATTRIBUTE_ISA_IO | EFI_PCI_IO_ATTRIBU= TE_ISA_IO_16); - - PcatIsaAcpiDev->PciIo->Attributes ( - PcatIsaAcpiDev->PciIo,=20 - EfiPciIoAttributeOperationDisable,=20 - EFI_PCI_DEVICE_ENABLE | Supports | EFI_PCI_IO_A= TTRIBUTE_ISA_MOTHERBOARD_IO, - NULL=20 - ); -=20 // // Uninstall protocol interface: EFI_ISA_ACPI_PROTOCOL // diff --git a/PcAtChipsetPkg/IsaAcpiDxe/PcatIsaAcpi.h b/PcAtChipsetPkg/IsaAc= piDxe/PcatIsaAcpi.h index 0671127644..3ad3a3f313 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 =20 -Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials =20 are licensed and made available under the terms and conditions of the BSD = License =20 which accompanies this distribution. The full text of the license may be = found at =20 @@ -43,6 +43,7 @@ typedef struct { EFI_HANDLE Handle; =20 EFI_ISA_ACPI_PROTOCOL IsaAcpi; EFI_PCI_IO_PROTOCOL *PciIo; + UINT64 OriginalAttribute; } PCAT_ISA_ACPI_DEV; =20 #define PCAT_ISA_ACPI_DEV_FROM_THIS(a) BASE_CR(a, PCAT_ISA_ACPI_DEV, IsaAc= pi) --=20 2.12.2.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel