From nobody Mon Feb 9 03:13:35 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+49808+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+49808+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1572621013; cv=none; d=zoho.com; s=zohoarc; b=AYjnuOGAHUlFGy7aof76AIteKM/k1j4esVBi+hYgKoJP8lrFdG6GJeIDmAd6nYq/ZO+5s/GL5ewIhRnETJWwE+13LF56/1wnoHZ9Co2vnIUV6zevIxEvJDAWPBUV8THQtoJJsMZFVnCHunyZyV79rwLe98s0/LbIvngGXiA11+I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572621013; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=hr3z+X4YQRdEVz9CutZotFRuYkmfMyqFcsP/RhZBXfk=; b=RxnWLLEpo1bSmfaxxlXWwgfp+1Ovqj8y7O9BgGNd001WtGO2YNR60kCi5VRqMTX3MFisTKjm8UVwnzx/6Dv0Xk3F4vaHJ5pvSc57Gh68LFx05L1b96GZ8teU7S733RLCqbleN3yJpV9t2Rc+7hMzWI5Tgp+XgyDIjDyNqgq1F98= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+49808+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1572621013707482.7583348168275; Fri, 1 Nov 2019 08:10:13 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id aaaaYY1788612xaaaaaaaaaa; Fri, 01 Nov 2019 08:10:13 -0700 X-Received: from mga18.intel.com (mga18.intel.com []) by mx.groups.io with SMTP id smtpd.web12.5161.1572621011267459384 for ; Fri, 01 Nov 2019 08:10:12 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Nov 2019 08:10:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,256,1569308400"; d="scan'208";a="194687061" X-Received: from pidsbabios005.gar.corp.intel.com ([10.223.9.183]) by orsmga008.jf.intel.com with ESMTP; 01 Nov 2019 08:10:10 -0700 From: "Javeed, Ashraf" To: devel@edk2.groups.io Cc: Jian J Wang , Hao A Wu , Ray Ni Subject: [edk2-devel] [edk2-staging/UEFI_PCI_ENHANCE-2 PATCH 04/12] PciBusDxe: Inclusion of new PCI Platform Protocol 2 Date: Fri, 1 Nov 2019 20:39:44 +0530 Message-Id: <20191101150952.3340-5-ashraf.javeed@intel.com> In-Reply-To: <20191101150952.3340-1-ashraf.javeed@intel.com> References: <20191101150952.3340-1-ashraf.javeed@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ashraf.javeed@intel.com X-Gm-Message-State: aaaaaaaaaaaaaaaaaaaaaaaax1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1572621013; bh=hMybX39Tre4zXDIvGZKgYq55VtcReffju9r0g6U/8e8=; h=Cc:Date:From:Reply-To:Subject:To; b=i5b5+9cPbiR4za4e3+79bX2Tj82ZQE3T479fDqvcy7lRadLWm+cTkx8T7zkkFXGfH+c aK9XOrqcCjunJ2Is4tXgmoirQwPe6yHnTzWFGgDESvpuWHRNk631/1MNgOrMMBZ43XDk3 3OMQN7JwDd7LjvY+0jFYpzIqNkvIkO0Vtj0= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2194 The code changes are made to support the new PCI Platform Protocol, as well as the legacy PCI Platform Protocol interfaces. The code change is made to consume the new interface to acquire the PCI device-specific platform policy. This code change is made to support the enabling of the other PCI features in the PCI Bus driver. Signed-off-by: Ashraf Javeed Cc: Jian J Wang Cc: Hao A Wu Cc: Ray Ni --- MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h | 2 ++ MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf | 2 ++ MdeModulePkg/Bus/Pci/PciBusDxe/PciPlatformSupport.c | 208 ++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= ++++++++++++++++++++++++++++++++++++++++-- MdeModulePkg/Bus/Pci/PciBusDxe/PciPlatformSupport.h | 18 ++++++++++++++++= ++ 4 files changed, 228 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h b/MdeModulePkg/Bus/Pci= /PciBusDxe/PciBus.h index 141c158..95a677b 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h @@ -27,6 +27,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include +#include =20 #include #include diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf b/MdeModulePkg/Bu= s/Pci/PciBusDxe/PciBusDxe.inf index 4ce99ce..44dec53 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf @@ -95,6 +95,8 @@ gEfiLoadFile2ProtocolGuid ## SOMETIMES_PRODUCES gEdkiiIoMmuProtocolGuid ## SOMETIMES_CONSUMES gEfiLoadedImageDevicePathProtocolGuid ## CONSUMES + gEfiPciPlatformProtocol2Guid ## SOMETIMES_CONSUMES + gEfiPciOverrideProtocol2Guid ## SOMETIMES_CONSUMES =20 [FeaturePcd] gEfiMdeModulePkgTokenSpaceGuid.PcdPciBusHotplugDeviceSupport ## CON= SUMES diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciPlatformSupport.c b/MdeModul= ePkg/Bus/Pci/PciBusDxe/PciPlatformSupport.c index 6f95794..238959e 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciPlatformSupport.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciPlatformSupport.c @@ -14,6 +14,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent EFI_PCI_PLATFORM_PROTOCOL *mPciPlatformProtocol; EFI_PCI_OVERRIDE_PROTOCOL *mPciOverrideProtocol; =20 +EFI_PCI_PLATFORM_PROTOCOL2 *mPciPlatformProtocol2; +EFI_PCI_OVERRIDE_PROTOCOL2 *mPciOverrideProtocol2; =20 =20 /** @@ -24,6 +26,29 @@ VOID LocatePciPlatformProtocol ( ) { + mPciPlatformProtocol2 =3D NULL; + gBS->LocateProtocol ( + &gEfiPciPlatformProtocol2Guid, + NULL, + (VOID **) &mPciPlatformProtocol2 + ); + + // + // If PCI Platform protocol doesn't exist, try to get Pci Override Proto= col. + // + if (mPciPlatformProtocol2 =3D=3D NULL) { + mPciOverrideProtocol2 =3D NULL; + gBS->LocateProtocol ( + &gEfiPciOverrideProtocol2Guid, + NULL, + (VOID **) &mPciOverrideProtocol2 + ); + } + // + // fetch the old PCI Platform Protocols if new are not installed + // + if (mPciOverrideProtocol2 =3D=3D NULL) { + mPciPlatformProtocol =3D NULL; gBS->LocateProtocol ( &gEfiPciPlatformProtocolGuid, @@ -42,6 +67,7 @@ LocatePciPlatformProtocol ( (VOID **) &mPciOverrideProtocol ); } + } } =20 /** @@ -52,13 +78,17 @@ BOOLEAN CheckPciPlatformProtocolInstall ( ) { - + if (mPciPlatformProtocol2 !=3D NULL) { + return TRUE; + } else if (mPciOverrideProtocol2 !=3D NULL) { + return TRUE; + } else { if (mPciPlatformProtocol !=3D NULL) { return TRUE; } else if (mPciOverrideProtocol !=3D NULL){ return TRUE; } - + } return FALSE; } =20 @@ -90,6 +120,32 @@ PciPlatformPreprocessController ( ) { EFI_STATUS Status; + + if (mPciPlatformProtocol2 !=3D NULL) { + // + // Call PlatformPci::PrepController() if the protocol is present. + // + Status =3D mPciPlatformProtocol2->PlatformPrepController ( + mPciPlatformProtocol2, + HostBridgeHandle, + RootBridgeHandle, + RootBridgePciAddress, + Phase, + ExecPhase + ); + } else if (mPciOverrideProtocol2 !=3D NULL) { + // + // Call PlatformPci::PrepController() if the protocol is present. + // + Status =3D mPciOverrideProtocol2->PlatformPrepController ( + mPciOverrideProtocol2, + HostBridgeHandle, + RootBridgeHandle, + RootBridgePciAddress, + Phase, + ExecPhase + ); + } else { if (mPciPlatformProtocol !=3D NULL) { // // Call PlatformPci::PrepController() if the protocol is present. @@ -120,6 +176,7 @@ PciPlatformPreprocessController ( // return EFI_NOT_FOUND; } + } return Status; } =20 @@ -142,6 +199,21 @@ PciPlatformNotifyPhase ( { EFI_STATUS Status; =20 + if (mPciPlatformProtocol2 !=3D NULL) { + Status =3D mPciPlatformProtocol2->PlatformNotify ( + mPciPlatformProtocol2, + HostBridgeHandle, + Phase, + ExecPhase + ); + } else if (mPciOverrideProtocol2 !=3D NULL) { + Status =3D mPciOverrideProtocol2->PlatformNotify ( + mPciOverrideProtocol2, + HostBridgeHandle, + Phase, + ExecPhase + ); + } else { =20 if (mPciPlatformProtocol !=3D NULL) { Status =3D mPciPlatformProtocol->PlatformNotify ( @@ -163,6 +235,7 @@ PciPlatformNotifyPhase ( // return EFI_NOT_FOUND; } + } return Status; } =20 @@ -179,6 +252,18 @@ PciGetPlatformPolicy ( ) { EFI_STATUS Status; + + if (mPciPlatformProtocol2 !=3D NULL) { + Status =3D mPciPlatformProtocol2->GetPlatformPolicy ( + mPciPlatformProtocol2, + PciPolicy + ); + } else if (mPciOverrideProtocol2 !=3D NULL) { + Status =3D mPciOverrideProtocol2->GetPlatformPolicy ( + mPciOverrideProtocol2, + PciPolicy + ); + } else { if (mPciPlatformProtocol !=3D NULL) { Status =3D mPciPlatformProtocol->GetPlatformPolicy ( mPciPlatformProtocol, @@ -197,6 +282,7 @@ PciGetPlatformPolicy ( // return EFI_NOT_FOUND; } + } return Status; } =20 @@ -223,6 +309,22 @@ GetPlatformPciOptionRom ( EFI_STATUS Status; VOID *PlatformOpRomBuffer; UINTN PlatformOpRomSize; + + if (mPciPlatformProtocol2 !=3D NULL) { + Status =3D mPciPlatformProtocol2->GetPciRom ( + mPciPlatformProtocol2, + PciIoDevice->Handle, + &PlatformOpRomBuffer, + &PlatformOpRomSize + ); + } else if (mPciOverrideProtocol2 !=3D NULL) { + Status =3D mPciOverrideProtocol2->GetPciRom ( + mPciOverrideProtocol2, + PciIoDevice->Handle, + &PlatformOpRomBuffer, + &PlatformOpRomSize + ); + } else { if (mPciPlatformProtocol !=3D NULL) { Status =3D mPciPlatformProtocol->GetPciRom ( mPciPlatformProtocol, @@ -243,6 +345,7 @@ GetPlatformPciOptionRom ( // return EFI_NOT_FOUND; } + } =20 if (!EFI_ERROR (Status)) { PciIoDevice->EmbeddedRom =3D FALSE; @@ -252,3 +355,104 @@ GetPlatformPciOptionRom ( } return Status; } + +/** + Generic routine to setup the PCI features as per its predetermined defau= lts. +**/ +VOID +SetupDefaultsDevicePlatformPolicy ( + IN PCI_IO_DEVICE *PciDevice + ) +{ +} + +/** + Intermediate routine to either get the PCI device specific platform poli= cies + through the PCI Platform Protocol, or its alias the PCI Override Protoco= l. + + @param PciIoDevice A pointer to PCI_IO_DEVICE + @param PciPlatformProtocol A pointer to EFI_PCI_PLATFORM_PROTOCOL2 + + @retval EFI_STATUS The direct status from the PCI Platform Prot= ocol + @retval EFI_SUCCESS if on returning predetermined PCI features d= efaults, + for the case when protocol returns as EFI_UN= SUPPORTED + to indicate PCI device exist and it has no p= latform + policy defined. +**/ +EFI_STATUS +GetPciDevicePlatformPolicyEx ( + IN PCI_IO_DEVICE *PciIoDevice, + IN EFI_PCI_PLATFORM_PROTOCOL2 *PciPlatformProtocol + ) +{ + EFI_PCI_PLATFORM_EXTENDED_POLICY PciPlatformExtendedPolicy; + EFI_STATUS Status; + + ZeroMem (&PciPlatformExtendedPolicy, sizeof (EFI_PCI_PLATFORM_EXTENDED_P= OLICY)); + Status =3D PciPlatformProtocol->GetDevicePolicy ( + PciPlatformProtocol, + PciIoDevice->Handle, + &PciPlatformExtendedPolicy + ); + switch (Status) { + case EFI_SUCCESS: + // + // platform chipset policies are returned for this PCI device + // + + DEBUG (( + DEBUG_INFO, "[device policy: platform]" + )); + return Status; + + case EFI_UNSUPPORTED: + // + // platform chipset policies are not provided for this PCI device + // let the enumeration happen as per the PCI standard way + // + SetupDefaultsDevicePlatformPolicy (PciIoDevice); + DEBUG (( + DEBUG_INFO, "[device policy: default]" + )); + return EFI_SUCCESS; + + default: + DEBUG (( + DEBUG_ERROR, "[device policy: none (error)]" + )); + return Status; + } +} + +/** + Gets the PCI device-specific platform policy from the PCI Platform Proto= col. + If no PCI Platform protocol is published than setup the PCI feature to p= redetermined + defaults, in order to align all the PCI devices in the PCI hierarchy, as= applicable. + + @param PciDevice A pointer to PCI_IO_DEVICE + + @retval EFI_STATUS The direct status from the PCI Platform Protocol + @retval EFI_SUCCESS On return of predetermined PCI features defaults, = for + the case when protocol returns as EFI_UNSUPPORTED = to + indicate PCI device exist and it has no platform p= olicy + defined. Also, on returns when no PCI Platform Pro= tocol + exist. +**/ +EFI_STATUS +GetPciDevicePlatformPolicy ( + IN PCI_IO_DEVICE *PciDevice + ) +{ + if (mPciPlatformProtocol2 !=3D NULL) { + return GetPciDevicePlatformPolicyEx (PciDevice, mPciPlatformProtocol2); + } else if (mPciOverrideProtocol2 !=3D NULL) { + return GetPciDevicePlatformPolicyEx (PciDevice, mPciOverrideProtocol2); + } else { + // + // new PCI Platform Protocol 2 is not installed; let the enumeration h= appen + // as per PCI standard way + // + SetupDefaultsDevicePlatformPolicy (PciDevice); + return EFI_SUCCESS; + } +} diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciPlatformSupport.h b/MdeModul= ePkg/Bus/Pci/PciBusDxe/PciPlatformSupport.h index c0d3b49..a13131c 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciPlatformSupport.h +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciPlatformSupport.h @@ -106,4 +106,22 @@ GetPlatformPciOptionRom ( IN PCI_IO_DEVICE *PciIoDevice ); =20 +/** + Gets the PCI device-specific platform policy from the PCI Platform Proto= col. + If no PCI Platform protocol is published than setup the PCI feature to p= redetermined + defaults, in order to align all the PCI devices in the PCI hierarchy, as= applicable. + + @param PciDevice A pointer to PCI_IO_DEVICE + + @retval EFI_STATUS The direct status from the PCI Platform Protocol + @retval EFI_SUCCESS On return of predetermined PCI features defaults, = for + the case when protocol returns as EFI_UNSUPPORTED = to + indicate PCI device exist and it has no platform p= olicy + defined. Also, on returns when no PCI Platform Pro= tocol + exist. +**/ +EFI_STATUS +GetPciDevicePlatformPolicy ( + IN PCI_IO_DEVICE *PciDevice + ); #endif --=20 2.21.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#49808): https://edk2.groups.io/g/devel/message/49808 Mute This Topic: https://groups.io/mt/40419685/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-