From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web11.2398.1573615587701825412 for ; Tue, 12 Nov 2019 19:26:27 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: ashraf.javeed@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Nov 2019 19:26:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,299,1569308400"; d="scan'208";a="194537164" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga007.jf.intel.com with ESMTP; 12 Nov 2019 19:26:27 -0800 Received: from fmsmsx119.amr.corp.intel.com (10.18.124.207) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 12 Nov 2019 19:26:26 -0800 Received: from bgsmsx155.gar.corp.intel.com (10.224.48.102) by FMSMSX119.amr.corp.intel.com (10.18.124.207) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 12 Nov 2019 19:26:25 -0800 Received: from bgsmsx101.gar.corp.intel.com ([169.254.1.49]) by BGSMSX155.gar.corp.intel.com ([169.254.12.236]) with mapi id 14.03.0439.000; Wed, 13 Nov 2019 08:56:23 +0530 From: "Javeed, Ashraf" To: "devel@edk2.groups.io" , "Javeed, Ashraf" CC: "Wang, Jian J" , "Wu, Hao A" , "Ni, Ray" Subject: Re: [edk2-devel] [edk2-staging/UEFI_PCI_ENHANCE-2 PATCH 04/12] PciBusDxe: Inclusion of new PCI Platform Protocol 2 Thread-Topic: [edk2-devel] [edk2-staging/UEFI_PCI_ENHANCE-2 PATCH 04/12] PciBusDxe: Inclusion of new PCI Platform Protocol 2 Thread-Index: AQHVkMZ7Z8fU+qRweECDvFhu5dJSMKeIgnaQ Date: Wed, 13 Nov 2019 03:26:22 +0000 Message-ID: <95C5C2B113DE604FB208120C742E9824579171AD@BGSMSX101.gar.corp.intel.com> References: <20191101150952.3340-1-ashraf.javeed@intel.com> <15D3127AAE5DC481.32624@groups.io> In-Reply-To: <15D3127AAE5DC481.32624@groups.io> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiOTc1YTkyNzUtYjlhMi00ODM4LWJlNzItNGIyMjU2ZTQ5MTIwIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiUFdPcGFQSjJ4NTBIOGJkWXlHZTRYbFwvc3BjZkJVXC9FeEdJUitRcWFvdlFUMGpyVm92ZTNLSzBHTmFmcWxTUWk5In0= x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.223.10.10] MIME-Version: 1.0 Return-Path: ashraf.javeed@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable This patch is also uploaded in the following Repo, for review:- https://github.com/ashrafj/edk2-staging/commit/bcaab03c212a8d6c3e23ab986aa= 3ec05b60dd61d Thanks Ashraf > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Javeed, > Ashraf > Sent: Friday, November 1, 2019 8:40 PM > To: devel@edk2.groups.io > Cc: Wang, Jian J ; Wu, Hao A = ; > Ni, Ray > Subject: [edk2-devel] [edk2-staging/UEFI_PCI_ENHANCE-2 PATCH 04/12] > PciBusDxe: Inclusion of new PCI Platform Protocol 2 >=20 > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2194 >=20 > The code changes are made to support the new PCI Platform Protocol, as w= ell > as the legacy PCI Platform Protocol interfaces. >=20 > The code change is made to consume the new interface to acquire the PCI > device-specific platform policy. >=20 > This code change is made to support the enabling of the other PCI featur= es in > the PCI Bus driver. >=20 > 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(-) >=20 > 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/Bus/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_CONSUME= S > + gEfiPciOverrideProtocol2Guid ## SOMETIMES_CONSUME= S >=20 > [FeaturePcd] > gEfiMdeModulePkgTokenSpaceGuid.PcdPciBusHotplugDeviceSupport ## > CONSUMES > diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciPlatformSupport.c > b/MdeModulePkg/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 Pr= otocol. > + // > + 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 de= faults. > +**/ > +VOID > +SetupDefaultsDevicePlatformPolicy ( > + IN PCI_IO_DEVICE *PciDevice > + ) > +{ > +} > + > +/** > + Intermediate routine to either get the PCI device specific platform > +policies > + through the PCI Platform Protocol, or its alias the PCI Override Prot= ocol. > + > + @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 P= rotocol > + @retval EFI_SUCCESS if on returning predetermined PCI feature= s defaults, > + for the case when protocol returns as EFI= _UNSUPPORTED > + to indicate PCI device exist and it has n= o platform > + 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_POLICY)); > + 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 Pr= otocol. > + If no PCI Platform protocol is published than setup the PCI feature > +to predetermined > + 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 Protoco= l > + @retval EFI_SUCCESS On return of predetermined PCI features default= s, for > + the case when protocol returns as EFI_UNSUPPORT= ED to > + indicate PCI device exist and it has no platfor= m policy > + defined. Also, on returns when no PCI Platform = Protocol > + 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 enumeratio= n happen > + // as per PCI standard way > + // > + SetupDefaultsDevicePlatformPolicy (PciDevice); > + return EFI_SUCCESS; > + } > +} > diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciPlatformSupport.h > b/MdeModulePkg/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 Pr= otocol. > + If no PCI Platform protocol is published than setup the PCI feature > +to predetermined > + 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 Protoco= l > + @retval EFI_SUCCESS On return of predetermined PCI features default= s, for > + the case when protocol returns as EFI_UNSUPPORT= ED to > + indicate PCI device exist and it has no platfor= m policy > + defined. Also, on returns when no PCI Platform = Protocol > + exist. > +**/ > +EFI_STATUS > +GetPciDevicePlatformPolicy ( > + IN PCI_IO_DEVICE *PciDevice > + ); > #endif > -- > 2.21.0.windows.1 >=20 >=20 >=20