public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Sayanta Pattanayak" <sayanta.pattanayak@arm.com>
To: devel@edk2.groups.io
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>,
	Sami Mujawar <sami.mujawar@arm.com>
Subject: [edk2-devel] [edk2-platforms][PATCH v1 1/4] Platform/Sgi: add remote memory descriptor
Date: Tue, 10 Oct 2023 17:08:26 +0530	[thread overview]
Message-ID: <20231010113829.647426-2-sayanta.pattanayak@arm.com> (raw)
In-Reply-To: <20231010113829.647426-1-sayanta.pattanayak@arm.com>

8GB address region starting at 0x3FE00000000 is reserved for extended
Remote Memory use. One of the use case, for extended remote memory
region, is using it as CXL.Mem region.

Remote memory region, with Normal memory attributes, is included into
the Translation table entries based on the PcdRemoteCxlMemory flag
status.

Resource descriptor for Remote CXL device memory is not created in
PlatformLibMem, it will be added at later execution phase after the
discovery of CXL Mem device.

This patch adds a Pcd, PcdRemoteCxlMemory for identifying a platform
with CXL enabled configuration.

Also marked Local memory block count, for creating SRAT tables in
subsequent patch.

Signed-off-by: Sayanta Pattanayak <sayanta.pattanayak@arm.com>
---
 Platform/ARM/SgiPkg/SgiPlatform.dec                      |  8 ++++++++
 Platform/ARM/SgiPkg/SgiPlatform.dsc.inc                  |  4 ++++
 Platform/ARM/SgiPkg/RdN2Cfg1/RdN2Cfg1.dsc                |  7 +++++++
 Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf  |  4 ++++
 Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c | 19 +++++++++++++++++--
 5 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/Platform/ARM/SgiPkg/SgiPlatform.dec b/Platform/ARM/SgiPkg/SgiPlatform.dec
index 1613cc0198..a147e22f42 100644
--- a/Platform/ARM/SgiPkg/SgiPlatform.dec
+++ b/Platform/ARM/SgiPkg/SgiPlatform.dec
@@ -102,5 +102,13 @@
   gArmSgiTokenSpaceGuid.PcdIoVirtSocExpBlk0Base|0|UINT64|0x0000002B
   gArmSgiTokenSpaceGuid.PcdIoVirtSocExpBlkUartEnable|0|UINT32|0x0000002C
 
+  # Number of Local Memory blocks
+  gArmSgiTokenSpaceGuid.PcdNumLocalMemBlock|1|UINT32|0x00001005
+
+  # Expanded Remote Memory Base and Size
+  gArmSgiTokenSpaceGuid.PcdRemoteCxlMemory|FALSE|BOOLEAN|0x00001006
+  gArmSgiTokenSpaceGuid.PcdRemoteMemoryBase|0|UINT64|0x00001007
+  gArmSgiTokenSpaceGuid.PcdRemoteMemorySize|0|UINT64|0x00001008
+
 [Ppis]
   gNtFwConfigDtInfoPpiGuid     = { 0x6f606eb3, 0x9123, 0x4e15, { 0xa8, 0x9b, 0x0f, 0xac, 0x66, 0xef, 0xd0, 0x17 } }
diff --git a/Platform/ARM/SgiPkg/SgiPlatform.dsc.inc b/Platform/ARM/SgiPkg/SgiPlatform.dsc.inc
index 26ecd9ed59..26b9a11a24 100644
--- a/Platform/ARM/SgiPkg/SgiPlatform.dsc.inc
+++ b/Platform/ARM/SgiPkg/SgiPlatform.dsc.inc
@@ -111,6 +111,10 @@
   gArmSgiTokenSpaceGuid.PcdDramBlock2Base|0x8080000000
   gArmSgiTokenSpaceGuid.PcdDramBlock2Size|0x180000000
 
+!if $(EDK2_ENABLE_REMOTE_CXL_MEM) == TRUE
+  gArmSgiTokenSpaceGuid.PcdRemoteCxlMemory|TRUE
+!endif
+
 !if $(LPI_EN) == TRUE
   # Allow use of LPI in the response to _OSC method call
   gArmSgiTokenSpaceGuid.PcdOscLpiEnable|1
diff --git a/Platform/ARM/SgiPkg/RdN2Cfg1/RdN2Cfg1.dsc b/Platform/ARM/SgiPkg/RdN2Cfg1/RdN2Cfg1.dsc
index c26f652cb9..37bae5c392 100644
--- a/Platform/ARM/SgiPkg/RdN2Cfg1/RdN2Cfg1.dsc
+++ b/Platform/ARM/SgiPkg/RdN2Cfg1/RdN2Cfg1.dsc
@@ -47,6 +47,13 @@
   gArmPlatformTokenSpaceGuid.PcdCoreCount|1
   gArmPlatformTokenSpaceGuid.PcdClusterCount|8
 
+  # Number of local memory blocks
+  gArmSgiTokenSpaceGuid.PcdNumLocalMemBlock|3
+
+  # Expanded Remote Memory Region, used as CXL Memory
+  gArmSgiTokenSpaceGuid.PcdRemoteMemoryBase|0x3FE00000000
+  gArmSgiTokenSpaceGuid.PcdRemoteMemorySize|0x200000000
+
 ################################################################################
 #
 # Components Section - list of all EDK II Modules needed by this Platform
diff --git a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf b/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf
index 020bde0d1f..2cdf9377e9 100644
--- a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf
+++ b/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf
@@ -51,6 +51,10 @@
   gArmTokenSpaceGuid.PcdSystemMemoryBase
   gArmTokenSpaceGuid.PcdSystemMemorySize
 
+  gArmSgiTokenSpaceGuid.PcdRemoteCxlMemory
+  gArmSgiTokenSpaceGuid.PcdRemoteMemoryBase
+  gArmSgiTokenSpaceGuid.PcdRemoteMemorySize
+
   gArmSgiTokenSpaceGuid.PcdChipCount
 
   gArmTokenSpaceGuid.PcdGicDistributorBase
diff --git a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c b/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c
index fa3cfbc730..13ba2a5960 100644
--- a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c
+++ b/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c
@@ -50,6 +50,7 @@ ArmPlatformGetVirtualMemoryMap (
   UINTN                         Index;
   ARM_MEMORY_REGION_DESCRIPTOR  *VirtualMemoryTable;
   EFI_RESOURCE_ATTRIBUTE_TYPE   ResourceAttributes;
+  UINTN                         TotalMemoryMapDescirptors;
 
   ResourceAttributes =
     EFI_RESOURCE_ATTRIBUTE_PRESENT |
@@ -111,9 +112,15 @@ ArmPlatformGetVirtualMemoryMap (
   ASSERT (VirtualMemoryMap != NULL);
   Index = 0;
 
+  TotalMemoryMapDescirptors = MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS;
+
+#if (FixedPcdGetBool (PcdRemoteCxlMemory))
+   TotalMemoryMapDescirptors += 1;
+#endif
+
   VirtualMemoryTable = (ARM_MEMORY_REGION_DESCRIPTOR*)AllocatePages
                        (EFI_SIZE_TO_PAGES (sizeof (ARM_MEMORY_REGION_DESCRIPTOR) *
-                       MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS));
+                       TotalMemoryMapDescirptors));
   if (VirtualMemoryTable == NULL) {
     return;
   }
@@ -221,6 +228,14 @@ ArmPlatformGetVirtualMemoryMap (
   VirtualMemoryTable[Index].Length          = PcdGet64 (PcdDramBlock2Size);
   VirtualMemoryTable[Index].Attributes      = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK;
 
+#if (FixedPcdGetBool (PcdRemoteCxlMemory))
+    // Expanded Remote memory region
+    VirtualMemoryTable[++Index].PhysicalBase  = FixedPcdGet64 (PcdRemoteMemoryBase);
+    VirtualMemoryTable[Index].VirtualBase     = FixedPcdGet64 (PcdRemoteMemoryBase);
+    VirtualMemoryTable[Index].Length          = FixedPcdGet64 (PcdRemoteMemorySize);
+    VirtualMemoryTable[Index].Attributes      = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK;
+#endif
+
 #if (FixedPcdGet32 (PcdChipCount) > 1)
   // Chip 1 DDR Block 1 - (2GB)
   VirtualMemoryTable[++Index].PhysicalBase  = SYSTEM_MEMORY_BASE_REMOTE (1),
@@ -283,6 +298,6 @@ ArmPlatformGetVirtualMemoryMap (
   VirtualMemoryTable[Index].Length          = 0;
   VirtualMemoryTable[Index].Attributes      = (ARM_MEMORY_REGION_ATTRIBUTES)0;
 
-  ASSERT ((Index + 1) <= MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS);
+  ASSERT ((Index + 1) <= TotalMemoryMapDescirptors);
   *VirtualMemoryMap = VirtualMemoryTable;
 }
-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#109489): https://edk2.groups.io/g/devel/message/109489
Mute This Topic: https://groups.io/mt/101872994/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



  reply	other threads:[~2023-10-10 11:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-10 11:38 [edk2-devel] [edk2-platforms][PATCH v1 0/4] add support for enabling cxl-type3 device as memory expander on Arm/RD platform Sayanta Pattanayak
2023-10-10 11:38 ` Sayanta Pattanayak [this message]
2023-10-10 11:38 ` [edk2-devel] [edk2-platforms][PATCH v1 2/4] Platform/Sgi: prepare SRAT, HMAT table Sayanta Pattanayak
2023-10-10 11:38 ` [edk2-devel] [edk2-platforms][PATCH v1 3/4] Platform/ARM: add CXL driver Sayanta Pattanayak
2023-10-10 11:38 ` [edk2-devel] [edk2-platforms][PATCH v1 4/4] Platform/Sgi: add CXL driver support Sayanta Pattanayak

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=20231010113829.647426-2-sayanta.pattanayak@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