public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Leif Lindholm" <leif@nuviainc.com>
To: Nhi Pham <nhi@os.amperecomputing.com>
Cc: devel@edk2.groups.io, patches@amperecomputing.com,
	vunguyen@os.amperecomputing.com,
	Thang Nguyen <thang@os.amperecomputing.com>,
	Chuong Tran <chuong@os.amperecomputing.com>,
	Phong Vo <phong@os.amperecomputing.com>,
	Michael D Kinney <michael.d.kinney@intel.com>,
	Ard Biesheuvel <ardb+tianocore@kernel.org>,
	Nate DeSimone <nathaniel.l.desimone@intel.com>
Subject: Re: [edk2-platforms][PATCH v4 25/31] Ampere: Utilize the PCIe User setting
Date: Tue, 26 Oct 2021 13:57:21 +0100	[thread overview]
Message-ID: <20211026125721.brcrawkqcqra5bki@leviathan> (raw)
In-Reply-To: <20211022061809.31087-26-nhi@os.amperecomputing.com>

On Fri, Oct 22, 2021 at 13:18:03 +0700, Nhi Pham wrote:
> From: Vu Nguyen <vunguyen@os.amperecomputing.com>
> 
> This change allows to configure the PCIe bifurcation mode and update
> the ACPI IORT tables based on the PCIe User setting.
> 
> Cc: Thang Nguyen <thang@os.amperecomputing.com>
> Cc: Chuong Tran <chuong@os.amperecomputing.com>
> Cc: Phong Vo <phong@os.amperecomputing.com>
> Cc: Leif Lindholm <leif@nuviainc.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> 
> Signed-off-by: Nhi Pham <nhi@os.amperecomputing.com>

Reviewed-by: Leif Lindholm <leif@nuviainc.com>

> ---
>  Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.inf |  2 +
>  Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/PcieInitPei.inf   |  5 +++
>  Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiIort.c          | 32 ++++++++++++----
>  Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/PcieInitPei.c     | 40 ++++++++++++++++++--
>  4 files changed, 69 insertions(+), 10 deletions(-)
> 
> diff --git a/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.inf b/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.inf
> index 415f795d2a54..804e761a1524 100644
> --- a/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.inf
> +++ b/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.inf
> @@ -52,6 +52,7 @@ [LibraryClasses]
>    UefiBootServicesTableLib
>    UefiDriverEntryPoint
>    UefiLib
> +  UefiRuntimeServicesTableLib
>  
>  [Pcd]
>    gArmPlatformTokenSpaceGuid.PcdCoreCount
> @@ -70,6 +71,7 @@ [Guids]
>    gEfiEventReadyToBootGuid
>    gPlatformInfoHobGuid
>    gRootComplexInfoHobGuid
> +  gRootComplexConfigFormSetGuid
>  
>  [Protocols]
>    gEfiAcpiTableProtocolGuid                     ## ALWAYS_CONSUMED
> diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/PcieInitPei.inf b/Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/PcieInitPei.inf
> index 17ac1672dac8..32d60bec1440 100644
> --- a/Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/PcieInitPei.inf
> +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/PcieInitPei.inf
> @@ -31,9 +31,14 @@ [LibraryClasses]
>    DebugLib
>    HobLib
>    PeimEntryPoint
> +  PeiServicesLib
> +
> +[Ppis]
> +  gEfiPeiReadOnlyVariable2PpiGuid
>  
>  [Guids]
>    gRootComplexInfoHobGuid
> +  gRootComplexConfigFormSetGuid
>    gPlatformInfoHobGuid
>  
>  [Depex]
> diff --git a/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiIort.c b/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiIort.c
> index b8f8cfa356af..97be85c51f25 100644
> --- a/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiIort.c
> +++ b/Platform/Ampere/JadePkg/Drivers/AcpiPlatformDxe/AcpiIort.c
> @@ -7,6 +7,7 @@
>  **/
>  
>  #include <AcpiHeader.h>
> +#include <Guid/RootComplexConfigHii.h>
>  #include <Guid/RootComplexInfoHob.h>
>  #include <IndustryStandard/Acpi30.h>
>  #include <IndustryStandard/IoRemappingTable.h>
> @@ -17,6 +18,7 @@
>  #include <Library/HobLib.h>
>  #include <Library/MemoryAllocationLib.h>
>  #include <Library/UefiBootServicesTableLib.h>
> +#include <Library/UefiRuntimeServicesTableLib.h>
>  #include <Platform/Ac01.h>
>  #include <Protocol/AcpiTable.h>
>  
> @@ -282,8 +284,10 @@ AcpiInstallIort (
>    EFI_ACPI_TABLE_PROTOCOL           *AcpiTableProtocol;
>    EFI_STATUS                        Status;
>    INT32                             EnabledRCs[AC01_PCIE_MAX_ROOT_COMPLEX];
> +  ROOT_COMPLEX_CONFIG_VARSTORE_DATA VarStoreConfig;
>    UINT32                            RcCount, SmmuPmuAgentCount, TotalCount;
>    UINT8                             Idx;
> +  UINTN                             BufferSize;
>    UINTN                             TableKey;
>    VOID                              *Hob;
>    VOID                              *IortBuffer;
> @@ -313,14 +317,28 @@ AcpiInstallIort (
>    }
>  
>    SmmuPmuAgentCount = 0;
> -  for (Idx = 0; Idx < RcCount; Idx++) {
> -    if (mRootComplexList[EnabledRCs[Idx]].Type == RootComplexTypeA) {
> -      SmmuPmuAgentCount += AC01_RCA_MAX_TBU_PMU;
> -    } else {
> -      SmmuPmuAgentCount += AC01_RCB_MAX_TBU_PMU;
> +
> +  //
> +  // Check SMMU setting
> +  //
> +  BufferSize = sizeof (VarStoreConfig);
> +  Status = gRT->GetVariable (
> +                  ROOT_COMPLEX_CONFIG_VARSTORE_NAME,
> +                  &gRootComplexConfigFormSetGuid,
> +                  NULL,
> +                  &BufferSize,
> +                  &VarStoreConfig
> +                  );
> +  if (!EFI_ERROR (Status) && VarStoreConfig.SmmuPmu) {
> +    for (Idx = 0; Idx < RcCount; Idx++) {
> +      if (mRootComplexList[EnabledRCs[Idx]].Type == RootComplexTypeA) {
> +        SmmuPmuAgentCount += AC01_RCA_MAX_TBU_PMU;
> +      } else {
> +        SmmuPmuAgentCount += AC01_RCB_MAX_TBU_PMU;
> +      }
> +      // Plus 1 TCU
> +      SmmuPmuAgentCount += 1;
>      }
> -    // Plus 1 TCU
> -    SmmuPmuAgentCount += 1;
>    }
>  
>    TotalCount = sizeof (EFI_ACPI_6_0_IO_REMAPPING_TABLE) +
> diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/PcieInitPei.c b/Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/PcieInitPei.c
> index 76cbb76f38f0..3e873a669332 100644
> --- a/Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/PcieInitPei.c
> +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/PcieInitPei.c
> @@ -8,6 +8,7 @@
>  
>  #include <PiPei.h>
>  
> +#include <Guid/RootComplexConfigHii.h>
>  #include <Guid/RootComplexInfoHob.h>
>  #include <Library/AmpereCpuLib.h>
>  #include <Library/BaseMemoryLib.h>
> @@ -15,7 +16,9 @@
>  #include <Library/DebugLib.h>
>  #include <Library/HobLib.h>
>  #include <Library/Ac01PcieLib.h>
> +#include <Library/PeiServicesLib.h>
>  #include <Platform/Ac01.h>
> +#include <Ppi/ReadOnlyVariable2.h>
>  
>  #include "RootComplexNVParam.h"
>  
> @@ -43,8 +46,39 @@ BuildRootComplexData (
>    )
>  {
>    AC01_ROOT_COMPLEX                    *RootComplex;
> +  BOOLEAN                              ConfigFound;
> +  EFI_PEI_READ_ONLY_VARIABLE2_PPI      *VariablePpi;
> +  EFI_STATUS                           Status;
> +  ROOT_COMPLEX_CONFIG_VARSTORE_DATA    RootComplexConfig;
>    UINT8                                RCIndex;
>    UINT8                                PcieIndex;
> +  UINTN                                DataSize;
> +
> +  ConfigFound = FALSE;
> +
> +  //
> +  // Get the Root Complex config from NVRAM
> +  //
> +  Status = PeiServicesLocatePpi (
> +             &gEfiPeiReadOnlyVariable2PpiGuid,
> +             0,
> +             NULL,
> +             (VOID **)&VariablePpi
> +             );
> +  if (!EFI_ERROR (Status)) {
> +    DataSize = sizeof (RootComplexConfig);
> +    Status = VariablePpi->GetVariable (
> +                            VariablePpi,
> +                            ROOT_COMPLEX_CONFIG_VARSTORE_NAME,
> +                            &gRootComplexConfigFormSetGuid,
> +                            NULL,
> +                            &DataSize,
> +                            &RootComplexConfig
> +                            );
> +    if (!EFI_ERROR (Status)) {
> +      ConfigFound = TRUE;
> +    }
> +  }
>  
>    ZeroMem (&mRootComplexList, sizeof (AC01_ROOT_COMPLEX) * AC01_PCIE_MAX_ROOT_COMPLEX);
>  
> @@ -58,9 +92,9 @@ BuildRootComplexData (
>  
>    for (RCIndex = 0; RCIndex < AC01_PCIE_MAX_ROOT_COMPLEX; RCIndex++) {
>      RootComplex = &mRootComplexList[RCIndex];
> -    RootComplex->Active = TRUE;
> -    RootComplex->DevMapLow = 0;
> -    RootComplex->DevMapHigh = 0;
> +    RootComplex->Active = ConfigFound ? RootComplexConfig.RCStatus[RCIndex] : TRUE;
> +    RootComplex->DevMapLow = ConfigFound ? RootComplexConfig.RCBifurcationLow[RCIndex] : 0;
> +    RootComplex->DevMapHigh = ConfigFound ? RootComplexConfig.RCBifurcationLow[RCIndex] : 0;
>      RootComplex->Socket = RCIndex / AC01_PCIE_MAX_RCS_PER_SOCKET;
>      RootComplex->ID = RCIndex % AC01_PCIE_MAX_RCS_PER_SOCKET;
>      RootComplex->CsrBase = mCsrBase[RCIndex];
> -- 
> 2.17.1
> 

  reply	other threads:[~2021-10-26 12:57 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-22  6:17 [edk2-platforms][PATCH v4 00/31] Add new Ampere Mt. Jade platform Nhi Pham
2021-10-22  6:17 ` [edk2-platforms][PATCH v4 01/31] Ampere: Initial support for Ampere Altra processor and " Nhi Pham
2021-10-26 11:14   ` Leif Lindholm
2021-11-03  9:31     ` Nhi Pham
2021-10-22  6:17 ` [edk2-platforms][PATCH v4 02/31] AmpereAltraPkg: Add FlashLib library instance Nhi Pham
2021-10-26 11:25   ` Leif Lindholm
2021-11-03  9:32     ` Nhi Pham
2021-10-22  6:17 ` [edk2-platforms][PATCH v4 03/31] AmpereAltraPkg: Add FailSafe and WDT support Nhi Pham
2021-10-26 12:15   ` Leif Lindholm
2021-11-03  9:35     ` Nhi Pham
2021-10-22  6:17 ` [edk2-platforms][PATCH v4 04/31] AmpereAltraPkg: Add DwI2cLib library instance Nhi Pham
2021-10-22  6:17 ` [edk2-platforms][PATCH v4 05/31] AmpereAltraPkg: Add DwGpioLib " Nhi Pham
2021-10-22  6:17 ` [edk2-platforms][PATCH v4 06/31] JadePkg: Implement RealTimeClockLib for PCF85063 Nhi Pham
2021-10-22  6:17 ` [edk2-platforms][PATCH v4 07/31] AmpereAltraPkg: Add BootProgress support Nhi Pham
2021-10-22  6:17 ` [edk2-platforms][PATCH v4 08/31] AmpereAltraPkg: Support UEFI non-volatile variable Nhi Pham
2021-10-26 12:21   ` Leif Lindholm
2021-10-22  6:17 ` [edk2-platforms][PATCH v4 09/31] AmpereSiliconPkg: Add PlatformManagerUiLib library instance Nhi Pham
2021-10-22  6:17 ` [edk2-platforms][PATCH v4 10/31] AmpereAltraPkg, JadePkg: Add ACPI support Nhi Pham
2021-10-22  6:17 ` [edk2-platforms][PATCH v4 11/31] AmpereAltraPkg: Add Root Complex HOB data structures Nhi Pham
2021-10-26 12:23   ` Leif Lindholm
2021-10-22  6:17 ` [edk2-platforms][PATCH v4 12/31] AmpereAltraPkg: Add Ac01PcieLib library instance Nhi Pham
2021-10-26 12:45   ` Leif Lindholm
2021-11-03  9:33     ` Nhi Pham
2021-10-22  6:17 ` [edk2-platforms][PATCH v4 13/31] JadePkg: Add BoardPcieLib " Nhi Pham
2021-10-26 12:46   ` Leif Lindholm
2021-11-03  9:33     ` Nhi Pham
2021-10-22  6:17 ` [edk2-platforms][PATCH v4 14/31] AmpereAltraPkg: Add driver to initialize PCIe Root Complex Nhi Pham
2021-10-26 12:49   ` Leif Lindholm
2021-10-22  6:17 ` [edk2-platforms][PATCH v4 15/31] AmpereAltraPkg: Add PciHostBridgeLib library instance Nhi Pham
2021-10-26 12:49   ` Leif Lindholm
2021-10-22  6:17 ` [edk2-platforms][PATCH v4 16/31] AmpereAltraPkg: Add PciSegmentLib " Nhi Pham
2021-10-26 12:53   ` Leif Lindholm
2021-11-03  9:35     ` Nhi Pham
2021-10-22  6:17 ` [edk2-platforms][PATCH v4 17/31] JadePkg: Enable PciHostBridgeDxe driver Nhi Pham
2021-10-22  6:17 ` [edk2-platforms][PATCH v4 18/31] JadePkg: Add PciPlatformDxe driver Nhi Pham
2021-10-22  6:17 ` [edk2-platforms][PATCH v4 19/31] JadePkg: Add ACPI tables to support PCIe Nhi Pham
2021-10-26 12:54   ` Leif Lindholm
2021-10-22  6:17 ` [edk2-platforms][PATCH v4 20/31] JadePkg: Add ASpeed GOP driver Nhi Pham
2021-10-22  6:17 ` [edk2-platforms][PATCH v4 21/31] AmpereAltraPkg: Add Random Number Generator Support Nhi Pham
2021-10-22  6:18 ` [edk2-platforms][PATCH v4 22/31] JadePkg: Add SMBIOS tables support Nhi Pham
2021-10-22  6:18 ` [edk2-platforms][PATCH v4 23/31] AmpereAltraPkg: Add DebugInfoPei module Nhi Pham
2021-10-22  6:18 ` [edk2-platforms][PATCH v4 24/31] AmpereAltraPkg: Add configuration screen for PCIe Nhi Pham
2021-10-26 12:56   ` Leif Lindholm
2021-10-22  6:18 ` [edk2-platforms][PATCH v4 25/31] Ampere: Utilize the PCIe User setting Nhi Pham
2021-10-26 12:57   ` Leif Lindholm [this message]
2021-10-22  6:18 ` [edk2-platforms][PATCH v4 26/31] AmpereAltraPkg: Add platform info screen Nhi Pham
2021-10-22  6:18 ` [edk2-platforms][PATCH v4 27/31] AmpereAltraPkg: Add configuration screen for Memory Nhi Pham
2021-10-26 12:58   ` Leif Lindholm
2021-10-22  6:18 ` [edk2-platforms][PATCH v4 28/31] AmpereAltraPkg: Add configuration screen for CPU Nhi Pham
2021-10-22  6:18 ` [edk2-platforms][PATCH v4 29/31] AmpereAltraPkg: Add configuration screen for ACPI Nhi Pham
2021-10-22  6:18 ` [edk2-platforms][PATCH v4 30/31] AmpereAltraPkg: Add configuration screen for RAS Nhi Pham
2021-10-22  6:18 ` [edk2-platforms][PATCH v4 31/31] AmpereAltraPkg: Add configuration screen for Watchdog timer Nhi Pham
2021-10-26 13:03   ` Leif Lindholm
2021-11-03  9:36     ` Nhi Pham
2021-10-26 13:08 ` [edk2-platforms][PATCH v4 00/31] Add new Ampere Mt. Jade platform Leif Lindholm
2021-11-03  9:37   ` Nhi Pham

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=20211026125721.brcrawkqcqra5bki@leviathan \
    --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