From: "Javeed, Ashraf" <ashraf.javeed@intel.com>
To: devel@edk2.groups.io
Cc: Jian J Wang <jian.j.wang@intel.com>,
Hao A Wu <hao.a.wu@intel.com>, Ray Ni <ray.ni@intel.com>
Subject: [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 [thread overview]
Message-ID: <20191101150952.3340-5-ashraf.javeed@intel.com> (raw)
In-Reply-To: <20191101150952.3340-1-ashraf.javeed@intel.com>
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2194
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 <ashraf.javeed@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
---
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 <Protocol/PciOverride.h>
#include <Protocol/PciEnumerationComplete.h>
#include <Protocol/IoMmu.h>
+#include <Protocol/PciPlatform2.h>
+#include <Protocol/PciOverride2.h>
#include <Library/DebugLib.h>
#include <Library/UefiDriverEntryPoint.h>
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_CONSUMES
+ gEfiPciOverrideProtocol2Guid ## SOMETIMES_CONSUMES
[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;
+EFI_PCI_PLATFORM_PROTOCOL2 *mPciPlatformProtocol2;
+EFI_PCI_OVERRIDE_PROTOCOL2 *mPciOverrideProtocol2;
/**
@@ -24,6 +26,29 @@ VOID
LocatePciPlatformProtocol (
)
{
+ mPciPlatformProtocol2 = NULL;
+ gBS->LocateProtocol (
+ &gEfiPciPlatformProtocol2Guid,
+ NULL,
+ (VOID **) &mPciPlatformProtocol2
+ );
+
+ //
+ // If PCI Platform protocol doesn't exist, try to get Pci Override Protocol.
+ //
+ if (mPciPlatformProtocol2 == NULL) {
+ mPciOverrideProtocol2 = NULL;
+ gBS->LocateProtocol (
+ &gEfiPciOverrideProtocol2Guid,
+ NULL,
+ (VOID **) &mPciOverrideProtocol2
+ );
+ }
+ //
+ // fetch the old PCI Platform Protocols if new are not installed
+ //
+ if (mPciOverrideProtocol2 == NULL) {
+
mPciPlatformProtocol = NULL;
gBS->LocateProtocol (
&gEfiPciPlatformProtocolGuid,
@@ -42,6 +67,7 @@ LocatePciPlatformProtocol (
(VOID **) &mPciOverrideProtocol
);
}
+ }
}
/**
@@ -52,13 +78,17 @@ BOOLEAN
CheckPciPlatformProtocolInstall (
)
{
-
+ if (mPciPlatformProtocol2 != NULL) {
+ return TRUE;
+ } else if (mPciOverrideProtocol2 != NULL) {
+ return TRUE;
+ } else {
if (mPciPlatformProtocol != NULL) {
return TRUE;
} else if (mPciOverrideProtocol != NULL){
return TRUE;
}
-
+ }
return FALSE;
}
@@ -90,6 +120,32 @@ PciPlatformPreprocessController (
)
{
EFI_STATUS Status;
+
+ if (mPciPlatformProtocol2 != NULL) {
+ //
+ // Call PlatformPci::PrepController() if the protocol is present.
+ //
+ Status = mPciPlatformProtocol2->PlatformPrepController (
+ mPciPlatformProtocol2,
+ HostBridgeHandle,
+ RootBridgeHandle,
+ RootBridgePciAddress,
+ Phase,
+ ExecPhase
+ );
+ } else if (mPciOverrideProtocol2 != NULL) {
+ //
+ // Call PlatformPci::PrepController() if the protocol is present.
+ //
+ Status = mPciOverrideProtocol2->PlatformPrepController (
+ mPciOverrideProtocol2,
+ HostBridgeHandle,
+ RootBridgeHandle,
+ RootBridgePciAddress,
+ Phase,
+ ExecPhase
+ );
+ } else {
if (mPciPlatformProtocol != NULL) {
//
// Call PlatformPci::PrepController() if the protocol is present.
@@ -120,6 +176,7 @@ PciPlatformPreprocessController (
//
return EFI_NOT_FOUND;
}
+ }
return Status;
}
@@ -142,6 +199,21 @@ PciPlatformNotifyPhase (
{
EFI_STATUS Status;
+ if (mPciPlatformProtocol2 != NULL) {
+ Status = mPciPlatformProtocol2->PlatformNotify (
+ mPciPlatformProtocol2,
+ HostBridgeHandle,
+ Phase,
+ ExecPhase
+ );
+ } else if (mPciOverrideProtocol2 != NULL) {
+ Status = mPciOverrideProtocol2->PlatformNotify (
+ mPciOverrideProtocol2,
+ HostBridgeHandle,
+ Phase,
+ ExecPhase
+ );
+ } else {
if (mPciPlatformProtocol != NULL) {
Status = mPciPlatformProtocol->PlatformNotify (
@@ -163,6 +235,7 @@ PciPlatformNotifyPhase (
//
return EFI_NOT_FOUND;
}
+ }
return Status;
}
@@ -179,6 +252,18 @@ PciGetPlatformPolicy (
)
{
EFI_STATUS Status;
+
+ if (mPciPlatformProtocol2 != NULL) {
+ Status = mPciPlatformProtocol2->GetPlatformPolicy (
+ mPciPlatformProtocol2,
+ PciPolicy
+ );
+ } else if (mPciOverrideProtocol2 != NULL) {
+ Status = mPciOverrideProtocol2->GetPlatformPolicy (
+ mPciOverrideProtocol2,
+ PciPolicy
+ );
+ } else {
if (mPciPlatformProtocol != NULL) {
Status = mPciPlatformProtocol->GetPlatformPolicy (
mPciPlatformProtocol,
@@ -197,6 +282,7 @@ PciGetPlatformPolicy (
//
return EFI_NOT_FOUND;
}
+ }
return Status;
}
@@ -223,6 +309,22 @@ GetPlatformPciOptionRom (
EFI_STATUS Status;
VOID *PlatformOpRomBuffer;
UINTN PlatformOpRomSize;
+
+ if (mPciPlatformProtocol2 != NULL) {
+ Status = mPciPlatformProtocol2->GetPciRom (
+ mPciPlatformProtocol2,
+ PciIoDevice->Handle,
+ &PlatformOpRomBuffer,
+ &PlatformOpRomSize
+ );
+ } else if (mPciOverrideProtocol2 != NULL) {
+ Status = mPciOverrideProtocol2->GetPciRom (
+ mPciOverrideProtocol2,
+ PciIoDevice->Handle,
+ &PlatformOpRomBuffer,
+ &PlatformOpRomSize
+ );
+ } else {
if (mPciPlatformProtocol != NULL) {
Status = mPciPlatformProtocol->GetPciRom (
mPciPlatformProtocol,
@@ -243,6 +345,7 @@ GetPlatformPciOptionRom (
//
return EFI_NOT_FOUND;
}
+ }
if (!EFI_ERROR (Status)) {
PciIoDevice->EmbeddedRom = FALSE;
@@ -252,3 +355,104 @@ GetPlatformPciOptionRom (
}
return Status;
}
+
+/**
+ Generic routine to setup the PCI features as per its predetermined defaults.
+**/
+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 Protocol.
+
+ @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 Protocol
+ @retval EFI_SUCCESS if on returning predetermined PCI features defaults,
+ for the case when protocol returns as EFI_UNSUPPORTED
+ to indicate PCI device exist and it has no 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 = 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 Protocol.
+ 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 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 policy
+ defined. Also, on returns when no PCI Platform Protocol
+ exist.
+**/
+EFI_STATUS
+GetPciDevicePlatformPolicy (
+ IN PCI_IO_DEVICE *PciDevice
+ )
+{
+ if (mPciPlatformProtocol2 != NULL) {
+ return GetPciDevicePlatformPolicyEx (PciDevice, mPciPlatformProtocol2);
+ } else if (mPciOverrideProtocol2 != NULL) {
+ return GetPciDevicePlatformPolicyEx (PciDevice, mPciOverrideProtocol2);
+ } else {
+ //
+ // new PCI Platform Protocol 2 is not installed; let the enumeration 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
);
+/**
+ Gets the PCI device-specific platform policy from the PCI Platform Protocol.
+ 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 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 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
next prev parent reply other threads:[~2019-11-01 15:10 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-01 15:09 [edk2-staging/UEFI_PCI_ENHANCE-2 PATCH 00/12] New PCI features - MPS, MRRS, RO, NS, CTO Javeed, Ashraf
2019-11-01 15:09 ` [edk2-staging/UEFI_PCI_ENHANCE-2 PATCH 01/12] MdeModulePkg/PciBusDxe:New PCI features separation with PCD Javeed, Ashraf
2019-11-01 15:09 ` [edk2-staging/UEFI_PCI_ENHANCE-2 PATCH 02/12] PciBusDxe: Reorganize the PCI Platform Protocol usage code Javeed, Ashraf
2019-11-01 15:09 ` [edk2-staging/UEFI_PCI_ENHANCE-2 PATCH 03/12] PciBusDxe: Separation of the PCI device registration and start Javeed, Ashraf
2019-11-01 15:09 ` Javeed, Ashraf [this message]
2019-11-01 15:09 ` [edk2-staging/UEFI_PCI_ENHANCE-2 PATCH 05/12] PciBusDxe: Setup sub-phases for PCI feature enumeration Javeed, Ashraf
2019-11-01 15:09 ` [edk2-staging/UEFI_PCI_ENHANCE-2 PATCH 06/12] PciBusDxe: Integration of setup " Javeed, Ashraf
2019-11-01 15:09 ` [edk2-staging/UEFI_PCI_ENHANCE-2 PATCH 07/12] PciBusDxe: Record the PCI-Express Capability Structure Javeed, Ashraf
2019-11-01 15:09 ` [edk2-staging/UEFI_PCI_ENHANCE-2 PATCH 08/12] PciBusDxe: New PCI feature Max_Payload_Size Javeed, Ashraf
2019-11-01 15:09 ` [edk2-staging/UEFI_PCI_ENHANCE-2 PATCH 09/12] PciBusDxe: New PCI feature Max_Read_Req_Size Javeed, Ashraf
2019-11-01 15:09 ` [edk2-staging/UEFI_PCI_ENHANCE-2 PATCH 10/12] PciBusDxe: New PCI feature Relax Ordering Javeed, Ashraf
2019-11-01 15:09 ` [edk2-staging/UEFI_PCI_ENHANCE-2 PATCH 11/12] PciBusDxe: New PCI feature No-Snoop Javeed, Ashraf
2019-11-01 15:09 ` [edk2-staging/UEFI_PCI_ENHANCE-2 PATCH 12/12] PciBusDxe: New PCI feature Completion Timeout Javeed, Ashraf
[not found] ` <15D3127A726D26A6.7420@groups.io>
2019-11-13 3:22 ` [edk2-devel] [edk2-staging/UEFI_PCI_ENHANCE-2 PATCH 01/12] MdeModulePkg/PciBusDxe:New PCI features separation with PCD Javeed, Ashraf
2019-12-16 12:46 ` Ni, Ray
[not found] ` <15D3127AABF5037C.32624@groups.io>
2019-11-13 3:23 ` [edk2-devel] [edk2-staging/UEFI_PCI_ENHANCE-2 PATCH 02/12] PciBusDxe: Reorganize the PCI Platform Protocol usage code Javeed, Ashraf
2019-12-16 12:46 ` Ni, Ray
[not found] ` <15D3127A98E21087.7420@groups.io>
2019-11-13 3:25 ` [edk2-devel] [edk2-staging/UEFI_PCI_ENHANCE-2 PATCH 03/12] PciBusDxe: Separation of the PCI device registration and start Javeed, Ashraf
2019-12-17 1:38 ` Ni, Ray
2019-12-17 3:19 ` Javeed, Ashraf
2019-12-19 1:34 ` Ni, Ray
2019-12-19 4:12 ` Javeed, Ashraf
[not found] ` <15D3127AAE5DC481.32624@groups.io>
2019-11-13 3:26 ` [edk2-devel] [edk2-staging/UEFI_PCI_ENHANCE-2 PATCH 04/12] PciBusDxe: Inclusion of new PCI Platform Protocol 2 Javeed, Ashraf
[not found] ` <15D3127B934F51D3.12315@groups.io>
2019-11-13 3:27 ` [edk2-devel] [edk2-staging/UEFI_PCI_ENHANCE-2 PATCH 05/12] PciBusDxe: Setup sub-phases for PCI feature enumeration Javeed, Ashraf
2019-12-17 11:56 ` Ni, Ray
2019-12-18 7:14 ` Javeed, Ashraf
2019-12-19 5:48 ` Ni, Ray
[not found] ` <15E1AFB3EABD031C.30484@groups.io>
2020-03-05 14:12 ` Ni, Ray
2020-03-16 9:33 ` Javeed, Ashraf
2020-03-16 14:00 ` Ni, Ray
2020-03-17 7:20 ` Javeed, Ashraf
2020-03-17 15:36 ` Ni, Ray
2020-04-20 13:22 ` Javeed, Ashraf
2020-04-21 6:03 ` Javeed, Ashraf
2020-04-21 6:22 ` Javeed, Ashraf
2020-05-08 8:26 ` Ni, Ray
[not found] ` <15D3127BE430E7DA.31784@groups.io>
2019-11-13 3:28 ` [edk2-devel] [edk2-staging/UEFI_PCI_ENHANCE-2 PATCH 06/12] PciBusDxe: Integration of setup " Javeed, Ashraf
2019-12-17 11:59 ` Ni, Ray
2019-12-18 7:15 ` Javeed, Ashraf
[not found] ` <15D3127C6DFCD4A7.12315@groups.io>
2019-11-13 3:29 ` [edk2-devel] [edk2-staging/UEFI_PCI_ENHANCE-2 PATCH 07/12] PciBusDxe: Record the PCI-Express Capability Structure Javeed, Ashraf
2019-12-17 12:03 ` Ni, Ray
2019-12-18 7:32 ` Javeed, Ashraf
[not found] ` <15D3127D273722D4.32624@groups.io>
2019-11-13 3:30 ` [edk2-devel] [edk2-staging/UEFI_PCI_ENHANCE-2 PATCH 08/12] PciBusDxe: New PCI feature Max_Payload_Size Javeed, Ashraf
2019-12-18 8:38 ` Ni, Ray
2019-12-18 9:10 ` Ni, Ray
2019-12-18 14:35 ` Javeed, Ashraf
2019-12-19 2:14 ` Ni, Ray
[not found] ` <15D3127DA6E2D860.7420@groups.io>
2019-11-13 3:31 ` [edk2-devel] [edk2-staging/UEFI_PCI_ENHANCE-2 PATCH 09/12] PciBusDxe: New PCI feature Max_Read_Req_Size Javeed, Ashraf
[not found] ` <15D3127E471DF360.32624@groups.io>
2019-11-13 3:32 ` [edk2-devel] [edk2-staging/UEFI_PCI_ENHANCE-2 PATCH 10/12] PciBusDxe: New PCI feature Relax Ordering Javeed, Ashraf
[not found] ` <15D3127EB6ED8506.12315@groups.io>
2019-11-13 3:33 ` [edk2-devel] [edk2-staging/UEFI_PCI_ENHANCE-2 PATCH 11/12] PciBusDxe: New PCI feature No-Snoop Javeed, Ashraf
[not found] ` <15D3127F5541064B.31784@groups.io>
2019-11-13 3:34 ` [edk2-devel] [edk2-staging/UEFI_PCI_ENHANCE-2 PATCH 12/12] PciBusDxe: New PCI feature Completion Timeout Javeed, Ashraf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191101150952.3340-5-ashraf.javeed@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox