From: "Marcin Juszkiewicz" <marcin.juszkiewicz@linaro.org>
To: devel@edk2.groups.io
Cc: Xiong Yining <xiongyining1480@phytium.com.cn>,
Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>,
Leif Lindholm <quic_llindhol@quicinc.com>,
Ard Biesheuvel <ardb+tianocore@kernel.org>,
Graeme Gregory <graeme@xora.org.uk>,
Chen Baozi <chenbaozi@phytium.com.cn>,
Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Subject: [edk2-devel] [PATCH edk2-platforms v4 6/6] SbsaQemu: export proper cache values in PPTT
Date: Wed, 10 Jul 2024 19:52:24 +0200 [thread overview]
Message-ID: <20240710-acpi65-v4-6-bc32224e4be4@linaro.org> (raw)
In-Reply-To: <20240710-acpi65-v4-0-bc32224e4be4@linaro.org>
We were exporting fake cpu cache values instead of reading them from
CCSIDR registers.
This change gets rid of fake values in favour of existing ones.
Code taken from Ampere platform core.
Reported-by: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
---
.../SbsaQemu/Include/IndustryStandard/SbsaQemuAcpi.h | 32 ++++++-----------
.../Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c | 36 ++++++++++++++++++++
2 files changed, 46 insertions(+), 22 deletions(-)
diff --git a/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuAcpi.h b/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuAcpi.h
index fa2e2b30bb7d..9a7c96fc6970 100644
--- a/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuAcpi.h
+++ b/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuAcpi.h
@@ -74,18 +74,6 @@ typedef struct {
UINT8 uid[8];
} SBSAQEMU_ACPI_CPU_DEVICE;
-#define SBSAQEMU_L1_D_CACHE_SIZE SIZE_32KB
-#define SBSAQEMU_L1_D_CACHE_SETS 256
-#define SBSAQEMU_L1_D_CACHE_ASSC 2
-
-#define SBSAQEMU_L1_I_CACHE_SIZE SIZE_32KB
-#define SBSAQEMU_L1_I_CACHE_SETS 256
-#define SBSAQEMU_L1_I_CACHE_ASSC 2
-
-#define SBSAQEMU_L2_CACHE_SIZE SIZE_512KB
-#define SBSAQEMU_L2_CACHE_SETS 1024
-#define SBSAQEMU_L2_CACHE_ASSC 8
-
#define CLUSTER_INDEX (sizeof (EFI_ACPI_DESCRIPTION_HEADER))
#define L1_D_CACHE_INDEX (CLUSTER_INDEX + sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_PROCESSOR))
#define L1_I_CACHE_INDEX (L1_D_CACHE_INDEX + sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_CACHE))
@@ -106,9 +94,9 @@ typedef struct {
1, /* CacheIdValid */ \
}, \
0, /* NextLevelOfCache */ \
- SBSAQEMU_L1_D_CACHE_SIZE, /* Size */ \
- SBSAQEMU_L1_D_CACHE_SETS, /* NumberOfSets */ \
- SBSAQEMU_L1_D_CACHE_ASSC, /* Associativity */ \
+ 0, /* Size */ \
+ 0, /* NumberOfSets */ \
+ 0, /* Associativity */ \
{ \
EFI_ACPI_6_5_CACHE_ATTRIBUTES_ALLOCATION_READ_WRITE, \
EFI_ACPI_6_5_CACHE_ATTRIBUTES_CACHE_TYPE_DATA, \
@@ -133,9 +121,9 @@ typedef struct {
1, /* CacheIdValid */ \
}, \
0, /* NextLevelOfCache */ \
- SBSAQEMU_L1_I_CACHE_SIZE, /* Size */ \
- SBSAQEMU_L1_I_CACHE_SETS, /* NumberOfSets */ \
- SBSAQEMU_L1_I_CACHE_ASSC, /* Associativity */ \
+ 0, /* Size */ \
+ 0, /* NumberOfSets */ \
+ 0, /* Associativity */ \
{ \
EFI_ACPI_6_5_CACHE_ATTRIBUTES_ALLOCATION_READ, \
EFI_ACPI_6_5_CACHE_ATTRIBUTES_CACHE_TYPE_INSTRUCTION, \
@@ -159,10 +147,10 @@ typedef struct {
1, /* LineSizeValid */ \
1, /* CacheIdValid */ \
}, \
- 0, /* NextLevelOfCache */ \
- SBSAQEMU_L2_CACHE_SIZE, /* Size */ \
- SBSAQEMU_L2_CACHE_SETS, /* NumberOfSets */ \
- SBSAQEMU_L2_CACHE_ASSC, /* Associativity */ \
+ 0, /* NextLevelOfCache */ \
+ 0, /* Size */ \
+ 0, /* NumberOfSets */ \
+ 0, /* Associativity */ \
{ \
EFI_ACPI_6_5_CACHE_ATTRIBUTES_ALLOCATION_READ_WRITE, \
EFI_ACPI_6_5_CACHE_ATTRIBUTES_CACHE_TYPE_UNIFIED, \
diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c
index 61f9de45d082..49f561e9bc2e 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c
@@ -2,12 +2,14 @@
* This file is an ACPI driver for the Qemu SBSA platform.
*
* Copyright (c) 2020-2024, Linaro Ltd. All rights reserved.
+* Copyright (c) 2020-2021, Ampere Computing LLC. All rights reserved.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*
**/
#include <IndustryStandard/Acpi.h>
#include <IndustryStandard/AcpiAml.h>
+#include <IndustryStandard/ArmCache.h>
#include <IndustryStandard/IoRemappingTable.h>
#include <IndustryStandard/SbsaQemuAcpi.h>
#include <IndustryStandard/SbsaQemuPlatformVersion.h>
@@ -494,6 +496,36 @@ AddSsdtTable (
return Status;
}
+STATIC VOID
+AcpiPpttFillCacheSizeInfo (
+ EFI_ACPI_6_5_PPTT_STRUCTURE_CACHE *Node,
+ UINT32 Level,
+ BOOLEAN DataCache,
+ BOOLEAN UnifiedCache
+ )
+{
+ CSSELR_DATA CsselrData;
+ CCSIDR_DATA CcsidrData;
+
+ CsselrData.Data = 0;
+ CsselrData.Bits.Level = Level - 1;
+ CsselrData.Bits.InD = (!DataCache && !UnifiedCache);
+
+ CcsidrData.Data = ReadCCSIDR (CsselrData.Data);
+
+ Node->Flags.LineSizeValid = 1;
+ Node->Flags.NumberOfSetsValid = 1;
+ Node->Flags.AssociativityValid = 1;
+ Node->Flags.SizePropertyValid = 1;
+ Node->Flags.CacheTypeValid = 1;
+ Node->NumberOfSets = (UINT16)CcsidrData.BitsNonCcidx.NumSets + 1;
+ Node->Associativity = (UINT16)CcsidrData.BitsNonCcidx.Associativity + 1;
+ Node->LineSize = (UINT16)(1 << (CcsidrData.BitsNonCcidx.LineSize + 4));
+ Node->Size = Node->NumberOfSets *
+ Node->Associativity *
+ Node->LineSize;
+}
+
STATIC
UINT32
AddCoresToPpttTable (
@@ -538,6 +570,10 @@ AddCoresToPpttTable (
EFI_ACPI_6_5_PPTT_STRUCTURE_CACHE L1ICache = SBSAQEMU_ACPI_PPTT_L1_I_CACHE_STRUCT;
EFI_ACPI_6_5_PPTT_STRUCTURE_CACHE L2Cache = SBSAQEMU_ACPI_PPTT_L2_CACHE_STRUCT;
+ AcpiPpttFillCacheSizeInfo (&L1DCache, 1, TRUE, FALSE);
+ AcpiPpttFillCacheSizeInfo (&L1ICache, 1, FALSE, FALSE);
+ AcpiPpttFillCacheSizeInfo (&L2Cache, 2, FALSE, TRUE);
+
CoreOffset = ClusterOffset + sizeof (EFI_ACPI_6_5_PPTT_STRUCTURE_PROCESSOR);
Offset = CoreOffset;
--
2.45.2
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#119876): https://edk2.groups.io/g/devel/message/119876
Mute This Topic: https://groups.io/mt/107147594/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
next prev parent reply other threads:[~2024-07-10 17:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-10 17:52 [edk2-devel] [PATCH edk2-platforms v4 0/6] SbsaQemu: Align the PPTT tables with QEMU Marcin Juszkiewicz
2024-07-10 17:52 ` [edk2-devel] [PATCH edk2-platforms v4 1/6] SbsaQemu: get the information of CPU topology via SMC calls Marcin Juszkiewicz
2024-07-10 17:52 ` [edk2-devel] [PATCH edk2-platforms v4 2/6] SbsaQemu: align the PPTT tables with QEMU Marcin Juszkiewicz
2024-07-10 17:52 ` [edk2-devel] [PATCH edk2-platforms v4 3/6] SbsaQemu: update PPTT to ACPI 6.5 Marcin Juszkiewicz
2024-07-10 17:52 ` [edk2-devel] [PATCH edk2-platforms v4 4/6] SbsaQemu: provide cache info per core in PPTT Marcin Juszkiewicz
2024-07-10 17:52 ` [edk2-devel] [PATCH edk2-platforms v4 5/6] SbsaQemu: introduce helper in PPTT generation Marcin Juszkiewicz
2024-07-10 17:52 ` Marcin Juszkiewicz [this message]
[not found] ` <17E0EB7A956FDF20.24858@groups.io>
2024-07-11 10:46 ` [edk2-devel] [PATCH edk2-platforms v4 6/6] SbsaQemu: export proper cache values in PPTT Marcin Juszkiewicz
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=20240710-acpi65-v4-6-bc32224e4be4@linaro.org \
--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