public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Leif Lindholm" <leif@nuviainc.com>
To: Tanmay Jagdale <tanmay.jagdale@linaro.org>
Cc: graeme@nuviainc.com, devel@edk2.groups.io, shashi.mallela@linaro.org
Subject: Re: [PATCH edk2-platforms 1/1] SbsaQemu: AcpiDxe: Read MPIDR from device tree
Date: Tue, 8 Sep 2020 20:08:37 +0100	[thread overview]
Message-ID: <20200908190837.GC5623@vanye> (raw)
In-Reply-To: <20200901182938.76281-1-tanmay.jagdale@linaro.org>

On Tue, Sep 01, 2020 at 23:59:38 +0530, Tanmay Jagdale wrote:
> The Qemu device tree for Sbsa platform now contains MPIDR value
> for every CPU in the form of "reg" property under every CPU's
> node. Hence, add a function that provides support to read this
> value from the device tree.
> 
> Signed-off-by: Tanmay Jagdale <tanmay.jagdale@linaro.org>

Thanks, Tanmay.

Reviewed-by: Leif Lindholm <leif@nuviainc.com>
Pushed as 8c5c22e667f8.

> ---
>  .../Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c | 35 ++++++++++++++++++-
>  1 file changed, 34 insertions(+), 1 deletion(-)
> 
> diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c
> index 47a9bd1d423a..fb7c1835c3d7 100644
> --- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c
> +++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c
> @@ -22,6 +22,9 @@
>  #include <Protocol/FdtClient.h>
>  #include <libfdt.h>
>  
> +STATIC INT32 FdtFirstCpuOffset;
> +STATIC INT32 FdtCpuNodeSize;
> +
>  /*
>   * A function that walks through the Device Tree created
>   * by Qemu and counts the number of CPUs present in it.
> @@ -56,12 +59,14 @@ CountCpusFromFdt (
>    // The count of these subnodes corresponds to the number of
>    // CPUs created by Qemu.
>    Prev = fdt_first_subnode (DeviceTreeBase, CpuNode);
> +  FdtFirstCpuOffset = Prev;
>    while (1) {
>      CpuCount++;
>      Node = fdt_next_subnode (DeviceTreeBase, Prev);
>      if (Node < 0) {
>        break;
>      }
> +    FdtCpuNodeSize = Node - Prev;
>      Prev = Node;
>    }
>  
> @@ -69,6 +74,34 @@ CountCpusFromFdt (
>    ASSERT_RETURN_ERROR (PcdStatus);
>  }
>  
> +/*
> + * Get MPIDR from device tree passed by Qemu
> + */
> +STATIC
> +UINT64
> +GetMpidr (
> +  IN UINTN   CpuId
> +  )
> +{
> +  VOID           *DeviceTreeBase;
> +  CONST UINT64   *RegVal;
> +  INT32          Len;
> +
> +  DeviceTreeBase = (VOID *)(UINTN)PcdGet64 (PcdDeviceTreeBaseAddress);
> +  ASSERT (DeviceTreeBase != NULL);
> +
> +  RegVal = fdt_getprop (DeviceTreeBase,
> +             FdtFirstCpuOffset + (CpuId * FdtCpuNodeSize),
> +             "reg",
> +             &Len);
> +  if (!RegVal) {
> +    DEBUG ((DEBUG_ERROR, "Couldn't find reg property for CPU:%d\n", CpuId));
> +    return 0;
> +  }
> +
> +  return (fdt64_to_cpu (ReadUnaligned64 (RegVal)));
> +}
> +
>  /*
>   * A Function to Compute the ACPI Table Checksum
>   */
> @@ -173,7 +206,7 @@ AddMadtTable (
>      CopyMem (New, &Gicc, sizeof (EFI_ACPI_6_0_GIC_STRUCTURE));
>      GiccPtr = (EFI_ACPI_6_0_GIC_STRUCTURE *) New;
>      GiccPtr->AcpiProcessorUid = NumCores;
> -    GiccPtr->MPIDR = NumCores;
> +    GiccPtr->MPIDR = GetMpidr (NumCores);
>      New += sizeof (EFI_ACPI_6_0_GIC_STRUCTURE);
>    }
>  
> -- 
> 2.28.0
> 

      parent reply	other threads:[~2020-09-08 19:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-01 18:29 [PATCH edk2-platforms 1/1] SbsaQemu: AcpiDxe: Read MPIDR from device tree Tanmay Jagdale
2020-09-03 14:29 ` Graeme Gregory
2020-09-08 19:08 ` Leif Lindholm [this message]

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=20200908190837.GC5623@vanye \
    --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