public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Sami Mujawar" <sami.mujawar@arm.com>
To: devel@edk2.groups.io, kuqin12@gmail.com
Cc: Joe Lopez <joelopez@microsoft.com>,
	Pierre Gondois <pierre.gondois@arm.com>,
	"nd@arm.com" <nd@arm.com>
Subject: Re: [edk2-devel] [PATCH v3 5/6] DynamicTablesPkg: AcpiSsdtPcieLibArm: Added function to reserve ECAM space
Date: Mon, 8 Aug 2022 14:22:29 +0100	[thread overview]
Message-ID: <7b2fb1d3-6acf-9cc8-025d-2ef598976df4@arm.com> (raw)
In-Reply-To: <20220731053727.536-6-kuqin12@gmail.com>

Hi Kun,

Thank you for this patch.

These changes look good to me.

Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>

Regards,

Sami Mujawar

On 31/07/2022 06:37 am, Kun Qin via groups.io wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3998
>
> Certain OSes will complain if the ECAM config space is not reserved in
> the ACPI namespace.
>
> This change adds a function to reserve PNP motherboard resources for a
> given PCI node.
>
> Co-authored-by: Joe Lopez <joelopez@microsoft.com>
> Signed-off-by: Kun Qin <kuqin12@gmail.com>
> Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>
> ---
>
> Notes:
>      v2:
>      - Only create RES0 after config space checking [Pierre]
>      
>      v3:
>      - Updated function names and descriptions [Pierre]
>      - Moved translation calculation to CONFIG case [Pierre]
>
>   DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c | 171 ++++++++++++++++++++
>   1 file changed, 171 insertions(+)
>
> diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c
> index ceffe2838c03..658a089c8f1f 100644
> --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c
> +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c
> @@ -616,6 +616,169 @@ GeneratePciCrs (
>     return Status;
>
>   }
>
>   
>
> +/** Generate a RES0 device node to reserve PNP motherboard resources
>
> +  for a given PCI node.
>
> +
>
> +  @param [in]   PciNode       Parent PCI node handle of the generated
>
> +                              resource object.
>
> +  @param [out]  CrsNode       CRS node of the AML tree to populate.
>
> +
>
> +  @retval EFI_SUCCESS             The function completed successfully.
>
> +  @retval EFI_INVALID_PARAMETER   Invalid input parameter.
>
> +  @retval EFI_OUT_OF_RESOURCES    Could not allocate memory.
>
> +**/
>
> +STATIC
>
> +EFI_STATUS
>
> +EFIAPI
>
> +GenerateMotherboardDevice (
>
> +  IN  AML_OBJECT_NODE_HANDLE  PciNode,
>
> +  OUT AML_OBJECT_NODE_HANDLE  *CrsNode
>
> +  )
>
> +{
>
> +  EFI_STATUS              Status;
>
> +  UINT32                  EisaId;
>
> +  AML_OBJECT_NODE_HANDLE  ResNode;
>
> +
>
> +  if (CrsNode == NULL) {
>
> +    ASSERT (0);
>
> +    return EFI_INVALID_PARAMETER;
>
> +  }
>
> +
>
> +  // ASL: Device (RES0) {}
>
> +  Status = AmlCodeGenDevice ("RES0", PciNode, &ResNode);
>
> +  if (EFI_ERROR (Status)) {
>
> +    ASSERT (0);
>
> +    return Status;
>
> +  }
>
> +
>
> +  // ASL: Name (_HID, EISAID ("PNP0C02"))
>
> +  Status = AmlGetEisaIdFromString ("PNP0C02", &EisaId); /* PNP Motherboard Resources */
>
> +  if (EFI_ERROR (Status)) {
>
> +    ASSERT (0);
>
> +    return Status;
>
> +  }
>
> +
>
> +  Status = AmlCodeGenNameInteger ("_HID", EisaId, ResNode, NULL);
>
> +  if (EFI_ERROR (Status)) {
>
> +    ASSERT (0);
>
> +    return Status;
>
> +  }
>
> +
>
> +  // ASL: Name (_CRS, ResourceTemplate () {})
>
> +  Status = AmlCodeGenNameResourceTemplate ("_CRS", ResNode, CrsNode);
>
> +  if (EFI_ERROR (Status)) {
>
> +    ASSERT (0);
>
> +    return Status;
>
> +  }
>
> +
>
> +  return Status;
>
> +}
>
> +
>
> +/** Reserves ECAM space for PCI config space
>
> +
>
> +  @param [in]       Generator       The SSDT Pci generator.
>
> +  @param [in]       CfgMgrProtocol  Pointer to the Configuration Manager
>
> +                                    Protocol interface.
>
> +  @param [in]       PciInfo         Pci device information.
>
> +  @param [in, out]  PciNode         RootNode of the AML tree to populate.
>
> +
>
> +  @retval EFI_SUCCESS             The function completed successfully.
>
> +  @retval EFI_INVALID_PARAMETER   Invalid parameter.
>
> +  @retval EFI_OUT_OF_RESOURCES    Could not allocate memory.
>
> +**/
>
> +STATIC
>
> +EFI_STATUS
>
> +EFIAPI
>
> +ReserveEcamSpace (
>
> +  IN            ACPI_PCI_GENERATOR                            *Generator,
>
> +  IN      CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,
>
> +  IN      CONST CM_ARM_PCI_CONFIG_SPACE_INFO                  *PciInfo,
>
> +  IN  OUT       AML_OBJECT_NODE_HANDLE                        PciNode
>
> +  )
>
> +{
>
> +  EFI_STATUS                   Status;
>
> +  AML_OBJECT_NODE_HANDLE       CrsNode;
>
> +  BOOLEAN                      Translation;
>
> +  UINT32                       Index;
>
> +  CM_ARM_OBJ_REF               *RefInfo;
>
> +  UINT32                       RefCount;
>
> +  CM_ARM_PCI_ADDRESS_MAP_INFO  *AddrMapInfo;
>
> +  BOOLEAN                      IsPosDecode;
>
> +
>
> +  // Get the array of CM_ARM_OBJ_REF referencing the
>
> +  // CM_ARM_PCI_ADDRESS_MAP_INFO objects.
>
> +  Status = GetEArmObjCmRef (
>
> +             CfgMgrProtocol,
>
> +             PciInfo->AddressMapToken,
>
> +             &RefInfo,
>
> +             &RefCount
>
> +             );
>
> +  if (EFI_ERROR (Status)) {
>
> +    ASSERT (0);
>
> +    return Status;
>
> +  }
>
> +
>
> +  for (Index = 0; Index < RefCount; Index++) {
>
> +    // Get CM_ARM_PCI_ADDRESS_MAP_INFO structures one by one.
>
> +    Status = GetEArmObjPciAddressMapInfo (
>
> +               CfgMgrProtocol,
>
> +               RefInfo[Index].ReferenceToken,
>
> +               &AddrMapInfo,
>
> +               NULL
>
> +               );
>
> +    if (EFI_ERROR (Status)) {
>
> +      ASSERT (0);
>
> +      return Status;
>
> +    }
>
> +
>
> +    switch (AddrMapInfo->SpaceCode) {
>
> +      case PCI_SS_CONFIG:
>
> +        Translation = (AddrMapInfo->CpuAddress != AddrMapInfo->PciAddress);
>
> +        if (AddrMapInfo->CpuAddress >= AddrMapInfo->PciAddress) {
>
> +          IsPosDecode = TRUE;
>
> +        } else {
>
> +          IsPosDecode = FALSE;
>
> +        }
>
> +
>
> +        Status = GenerateMotherboardDevice (PciNode, &CrsNode);
>
> +        if (EFI_ERROR (Status)) {
>
> +          ASSERT (0);
>
> +          break;
>
> +        }
>
> +
>
> +        Status = AmlCodeGenRdQWordMemory (
>
> +                   FALSE,
>
> +                   IsPosDecode,
>
> +                   TRUE,
>
> +                   TRUE,
>
> +                   FALSE, // non-cacheable
>
> +                   TRUE,
>
> +                   0,
>
> +                   AddrMapInfo->PciAddress,
>
> +                   AddrMapInfo->PciAddress + AddrMapInfo->AddressSize - 1,
>
> +                   Translation ? AddrMapInfo->CpuAddress - AddrMapInfo->PciAddress : 0,
>
> +                   AddrMapInfo->AddressSize,
>
> +                   0,
>
> +                   NULL,
>
> +                   0,
>
> +                   TRUE,
>
> +                   CrsNode,
>
> +                   NULL
>
> +                   );
>
> +        break;
>
> +      default:
>
> +        break;
>
> +    } // switch
>
> +
>
> +    if (EFI_ERROR (Status)) {
>
> +      ASSERT (0);
>
> +      return Status;
>
> +    }
>
> +  }
>
> +
>
> +  return Status;
>
> +}
>
> +
>
>   /** Generate a Pci device.
>
>   
>
>     @param [in]       Generator       The SSDT Pci generator.
>
> @@ -702,9 +865,17 @@ GeneratePciDevice (
>       return Status;
>
>     }
>
>   
>
> +  // Add the PNP Motherboard Resources Device to reserve ECAM space
>
> +  Status = ReserveEcamSpace (Generator, CfgMgrProtocol, PciInfo, PciNode);
>
> +  if (EFI_ERROR (Status)) {
>
> +    ASSERT (0);
>
> +    return Status;
>
> +  }
>
> +
>
>     // Add the template _OSC method.
>
>     Status = AddOscMethod (PciInfo, PciNode);
>
>     ASSERT_EFI_ERROR (Status);
>
> +
>
>     return Status;
>
>   }
>
>   
>

  reply	other threads:[~2022-08-08 13:22 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-31  5:37 [PATCH v3 0/6] Enhance DynamicTablesPkg modules Kun Qin
2022-07-31  5:37 ` [PATCH v3 1/6] DynamicTablesPkg: DynamicPlatRepoLib: Added MemoryAllocationLib to inf Kun Qin
2022-07-31  5:37 ` [PATCH v3 2/6] DynamicTablesPkg: DynamicPlatRepoLib: Fix incorrect dereferencing Kun Qin
2022-07-31  5:37 ` [PATCH v3 3/6] DynamicTablesPkg: DynamicPlatRepoLib: Adding more token fixers Kun Qin
2022-07-31  5:37 ` [PATCH v3 4/6] DynamicTablesPkg: DynamicTableManagerDxe: Added check for installed tables Kun Qin
2022-08-08 13:05   ` Sami Mujawar
2022-08-08 15:39     ` Sami Mujawar
2022-08-08 23:43       ` Kun Qin
2022-08-09  9:01         ` Sami Mujawar
2022-08-10 22:31           ` Kun Qin
2022-07-31  5:37 ` [PATCH v3 5/6] DynamicTablesPkg: AcpiSsdtPcieLibArm: Added function to reserve ECAM space Kun Qin
2022-08-08 13:22   ` Sami Mujawar [this message]
2022-08-08 15:39     ` [edk2-devel] " Sami Mujawar
2022-08-10  8:51       ` PierreGondois
2022-08-10 22:37         ` Kun Qin
2022-07-31  5:37 ` [PATCH v3 6/6] DynamicTablesPkg: AcpiSsdtPcieLibArm: Added case handling for PCI config Kun Qin
2022-08-08 13:22   ` Sami Mujawar

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=7b2fb1d3-6acf-9cc8-025d-2ef598976df4@arm.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