From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by mx.groups.io with SMTP id smtpd.web09.34852.1613999690276213078 for ; Mon, 22 Feb 2021 05:14:50 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@nuviainc-com.20150623.gappssmtp.com header.s=20150623 header.b=c8REXIsc; spf=pass (domain: nuviainc.com, ip: 209.85.221.51, mailfrom: leif@nuviainc.com) Received: by mail-wr1-f51.google.com with SMTP id l30so3351401wrb.12 for ; Mon, 22 Feb 2021 05:14:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuviainc-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=ovbC0lGUHkTO8/BrDxBDp7X2DdAPyZZ2ma9CIGlXItY=; b=c8REXIscZG4uqRifx+z+9fqNEUt8VduWpqtXHHAXLMK1PPTwIMiBl/c03gqdbxUfKu CquzExl09uau92AnTXXGgsqy8o3j8KGQmoBLiT58R14UhOekiuqEccXSJJ+vyS9y+ERl 67N+vMdJe8HK39gJhdfCzTKbn5DZFyCI8Nx0l10RHRNGW/j/H7eRaXH47TYZM8CGeWgc s4UW7gTwFOWH3oodAYyX3pMVY6H30cMG4cRmBo2NVOC98m6s4kPLJwD4LbjSDjVv0/S3 XLzM47lG+CF6Qe4BAxs6X2VHGwg6Hdufrv3kw0sDl8YRCTWBNCCdn0NQm9Z8A+661A8+ jmhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ovbC0lGUHkTO8/BrDxBDp7X2DdAPyZZ2ma9CIGlXItY=; b=Pfq6Mvu1CeJy1dcoB+ECIoKEafQe5X7u2l3WWkwyfeytbYfDWov672zU7pDwJr1UGc guiAVmL5I3FJNGm1uiBBCuuCqkenq576s5Lt/ACW7hF4sxCgMleP+4VbkLVIzQvRXF+B STHMDvOT5QG8y6BWpu9dWbQIe9sPreCTWrtmn3GsLu+SPvaw6Ig0wDA4QNJO67EIOLuL 4O9cQgwZMKenjBR0hxiVmltlhB7hOpB/a0arQqLrjOsl6sYqTuB9J7XrO9ssDJ3oYq4u 73PUhYsqC7UOpeK8SioFvE0bVBHmx+sTf4FWrfODb/8lmS8ujb/uTHGwEveY5KlTqjNi DR1A== X-Gm-Message-State: AOAM53019Mczj77aXtWzaSoQiZSdwMSNvMdCLSXF5vj8R1//pvK8u6Ei Ih7on9AdAoV75SPYnwV/ZsAM5A== X-Google-Smtp-Source: ABdhPJwE4fPnhsrpJ/Q3WNV7Jb7qHxtVFXidhWAlU9PC4FeBfKJxSacazYdrLZjV1WMGro4MARlLBw== X-Received: by 2002:a5d:570a:: with SMTP id a10mr22111714wrv.70.1613999688863; Mon, 22 Feb 2021 05:14:48 -0800 (PST) Return-Path: Received: from vanye (cpc1-cmbg19-2-0-cust915.5-4.cable.virginm.net. [82.27.183.148]) by smtp.gmail.com with ESMTPSA id u6sm30648227wmg.41.2021.02.22.05.14.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Feb 2021 05:14:48 -0800 (PST) Date: Mon, 22 Feb 2021 13:14:46 +0000 From: "Leif Lindholm" To: Rebecca Cran Cc: devel@edk2.groups.io, Ard Biesheuvel , Graeme Gregory , Radoslaw Biernacki Subject: Re: [edk2-platforms PATCH v3 2/3] SbsaQemu: Update SbsaQemuAcpiDxe to use FdtHelperLib Message-ID: <20210222131446.GU1664@vanye> References: <20210219035741.1467-1-rebecca@nuviainc.com> <20210219035741.1467-3-rebecca@nuviainc.com> MIME-Version: 1.0 In-Reply-To: <20210219035741.1467-3-rebecca@nuviainc.com> User-Agent: Mutt/1.10.1 (2018-07-13) Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Feb 18, 2021 at 20:57:40 -0700, Rebecca Cran wrote: > Use the copy of the CountCpusFromFdt function from FdtHelperLib. This patch also needs to invoke CountCpusFromFdt ... Hmm, come to think of it. Could we change the name of the function (in 1/3) to FdtHelperCountCpus? Since it's now a global symbol, some namespace protection wouldn't go amiss. Anyway, in this patch, where CountCpusFromFdt was invoked, we now need to invoke the bit that doesn't get migrated to the helper library: Status = PcdSet32S (PcdCoreCount, NumCores); ASSERT_RETURN_ERROR (Status); Urgh... If you could possibly find it in your heart to add a new temporary variable called CoreIndex to AddMadtTable() and use that instead of using NumCores as an index further down, that would improve this code in general. / Leif > Signed-off-by: Rebecca Cran > --- > Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c | 50 +------------------- > Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf | 1 + > 2 files changed, 2 insertions(+), 49 deletions(-) > > diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c > index fb7c1835c3d7..02ba3e452c06 100644 > --- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c > +++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c > @@ -12,6 +12,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -25,55 +26,6 @@ > 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. > - */ > -STATIC > -VOID > -CountCpusFromFdt ( > - VOID > -) > -{ > - VOID *DeviceTreeBase; > - INT32 Node, Prev; > - RETURN_STATUS PcdStatus; > - INT32 CpuNode; > - INT32 CpuCount; > - > - DeviceTreeBase = (VOID *)(UINTN)PcdGet64 (PcdDeviceTreeBaseAddress); > - ASSERT (DeviceTreeBase != NULL); > - > - // Make sure we have a valid device tree blob > - ASSERT (fdt_check_header (DeviceTreeBase) == 0); > - > - CpuNode = fdt_path_offset (DeviceTreeBase, "/cpus"); > - if (CpuNode <= 0) { > - DEBUG ((DEBUG_ERROR, "Unable to locate /cpus in device tree\n")); > - return; > - } > - > - CpuCount = 0; > - > - // Walk through /cpus node and count the number of subnodes. > - // 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; > - } > - > - PcdStatus = PcdSet32S (PcdCoreCount, CpuCount); > - ASSERT_RETURN_ERROR (PcdStatus); > -} > - > /* > * Get MPIDR from device tree passed by Qemu > */ > diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf > index 127eef029f3c..a58ebfaf76d5 100644 > --- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf > +++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf > @@ -34,6 +34,7 @@ > BaseLib > DebugLib > DxeServicesLib > + FdtHelperLib > FdtLib > PcdLib > PrintLib > -- > 2.26.2 >