From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.7121.1588683833160095903 for ; Tue, 05 May 2020 06:03:53 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: aditya.angadi@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C99FF30E; Tue, 5 May 2020 06:03:52 -0700 (PDT) Received: from usa.arm.com (a073440-lin.blr.arm.com [10.162.16.34]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id DBE8F3F68F; Tue, 5 May 2020 06:03:50 -0700 (PDT) From: "Aditya Angadi" To: devel@edk2.groups.io Cc: thomas.abraham@arm.com, ard.biesheuvel@arm.com, vijayenthiran.subramaniam@arm.com, leif@nuviainc.com, Aditya Angadi Subject: [PATCH v5][edk2-platforms 11/17] Platform/ARM/SgiPkg: Add support for remote numa memory nodes Date: Tue, 5 May 2020 18:32:08 +0530 Message-Id: <20200505130214.25592-12-aditya.angadi@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200505130214.25592-1-aditya.angadi@arm.com> References: <20200505130214.25592-1-aditya.angadi@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Vijayenthiran Subramaniam On a multi-chip platform, there are memory nodes connected to the remote chips that are usable. Setup memory descriptor HOBs for all the remote memory nodes. Use the remote chip memory offset value to determine the base address for these remote memory nodes. A new PCD 'PcdChipCount' is added in the ArmSgiTokenSpace that a platform can use to define the number of coherently connected chips in a multi-chip package. Signed-off-by: Aditya Angadi --- Platform/ARM/SgiPkg/Include/SgiPlatform.h | 8 ++ Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf | 3 + Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c | 87 ++++++++++= +++++++++- Platform/ARM/SgiPkg/SgiPlatform.dec | 3 + 4 files changed, 100 insertions(+), 1 deletion(-) diff --git a/Platform/ARM/SgiPkg/Include/SgiPlatform.h b/Platform/ARM/Sgi= Pkg/Include/SgiPlatform.h index d87fb2b5409f..728abbea97e8 100644 --- a/Platform/ARM/SgiPkg/Include/SgiPlatform.h +++ b/Platform/ARM/SgiPkg/Include/SgiPlatform.h @@ -80,6 +80,14 @@ // Remote chip address offset (4TB per chip) #define SGI_REMOTE_CHIP_MEM_OFFSET(n) ((1ULL << 42) * (n)) =20 +// Base address of the DRAM1 block in a remote chip +#define SYSTEM_MEMORY_BASE_REMOTE(ChipId) \ + (SGI_REMOTE_CHIP_MEM_OFFSET (ChipId) + FixedPcdGet64 (PcdSyste= mMemoryBase)) + +// Base address of the DRAM2 block in a remote chip +#define DRAM_BLOCK2_BASE_REMOTE(ChipId) \ + (SGI_REMOTE_CHIP_MEM_OFFSET (ChipId) + FixedPcdGet64 (PcdDramB= lock2Base)) + // ARM platform description data. typedef struct { UINTN PlatformId; diff --git a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf b/Pl= atform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf index a918afef5fba..464a7cde4513 100644 --- a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf +++ b/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf @@ -46,6 +46,9 @@ [FixedPcd] =20 gArmTokenSpaceGuid.PcdSystemMemoryBase gArmTokenSpaceGuid.PcdSystemMemorySize + + gArmSgiTokenSpaceGuid.PcdChipCount + gArmTokenSpaceGuid.PcdGicDistributorBase gArmTokenSpaceGuid.PcdGicRedistributorsBase gArmTokenSpaceGuid.PcdFvBaseAddress diff --git a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c b/P= latform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c index 8d0ad4ec9c84..e30819c5cd55 100644 --- a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c +++ b/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLibMem.c @@ -16,7 +16,8 @@ #include =20 // Total number of descriptors, including the final "end-of-table" descr= iptor. -#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS 13 +#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS \ + (11 + (FixedPcdGet32 (PcdChipCount) * 2)) =20 /** Returns the Virtual Memory Map of the platform. @@ -52,6 +53,48 @@ ArmPlatformGetVirtualMemoryMap ( FixedPcdGet64 (PcdDramBlock2Base), FixedPcdGet64 (PcdDramBlock2Size)); =20 +#if (FixedPcdGet32 (PcdChipCount) > 1) + BuildResourceDescriptorHob ( + EFI_RESOURCE_SYSTEM_MEMORY, + ResourceAttributes, + SYSTEM_MEMORY_BASE_REMOTE (1), + PcdGet64 (PcdSystemMemorySize)); + + BuildResourceDescriptorHob ( + EFI_RESOURCE_SYSTEM_MEMORY, + ResourceAttributes, + DRAM_BLOCK2_BASE_REMOTE (1), + FixedPcdGet64 (PcdDramBlock2Size)); + +#if (FixedPcdGet32 (PcdChipCount) > 2) + BuildResourceDescriptorHob ( + EFI_RESOURCE_SYSTEM_MEMORY, + ResourceAttributes, + SYSTEM_MEMORY_BASE_REMOTE (2), + FixedPcdGet64 (PcdSystemMemorySize)); + + BuildResourceDescriptorHob ( + EFI_RESOURCE_SYSTEM_MEMORY, + ResourceAttributes, + DRAM_BLOCK2_BASE_REMOTE (2), + FixedPcdGet64 (PcdDramBlock2Size)); + +#if (FixedPcdGet32 (PcdChipCount) > 3) + BuildResourceDescriptorHob ( + EFI_RESOURCE_SYSTEM_MEMORY, + ResourceAttributes, + SYSTEM_MEMORY_BASE_REMOTE (3), + FixedPcdGet64 (PcdSystemMemorySize)); + + BuildResourceDescriptorHob ( + EFI_RESOURCE_SYSTEM_MEMORY, + ResourceAttributes, + DRAM_BLOCK2_BASE_REMOTE (3), + FixedPcdGet64 (PcdDramBlock2Size)); +#endif +#endif +#endif + ASSERT (VirtualMemoryMap !=3D NULL); Index =3D 0; =20 @@ -122,6 +165,48 @@ ArmPlatformGetVirtualMemoryMap ( VirtualMemoryTable[Index].Length =3D PcdGet64 (PcdDramBlock2S= ize); VirtualMemoryTable[Index].Attributes =3D ARM_MEMORY_REGION_ATTRIB= UTE_WRITE_BACK; =20 +#if (FixedPcdGet32 (PcdChipCount) > 1) + // Chip 1 DDR Block 1 - (2GB) + VirtualMemoryTable[++Index].PhysicalBase =3D SYSTEM_MEMORY_BASE_REMOT= E (1), + VirtualMemoryTable[Index].VirtualBase =3D SYSTEM_MEMORY_BASE_REMOT= E (1), + VirtualMemoryTable[Index].Length =3D PcdGet64 (PcdSystemMemor= ySize); + VirtualMemoryTable[Index].Attributes =3D ARM_MEMORY_REGION_ATTRIB= UTE_WRITE_BACK; + + // Chip 1 DDR Block 2 - (6GB) + VirtualMemoryTable[++Index].PhysicalBase =3D DRAM_BLOCK2_BASE_REMOTE = (1), + VirtualMemoryTable[Index].VirtualBase =3D DRAM_BLOCK2_BASE_REMOTE = (1), + VirtualMemoryTable[Index].Length =3D PcdGet64 (PcdDramBlock2S= ize); + VirtualMemoryTable[Index].Attributes =3D ARM_MEMORY_REGION_ATTRIB= UTE_WRITE_BACK; + +#if (FixedPcdGet32 (PcdChipCount) > 2) + // Chip 2 DDR Block 1 - (2GB) + VirtualMemoryTable[++Index].PhysicalBase =3D SYSTEM_MEMORY_BASE_REMOT= E (2), + VirtualMemoryTable[Index].VirtualBase =3D SYSTEM_MEMORY_BASE_REMOT= E (2), + VirtualMemoryTable[Index].Length =3D PcdGet64 (PcdSystemMemor= ySize); + VirtualMemoryTable[Index].Attributes =3D ARM_MEMORY_REGION_ATTRIB= UTE_WRITE_BACK; + + // Chip 2 DDR Block 2 - (6GB) + VirtualMemoryTable[++Index].PhysicalBase =3D DRAM_BLOCK2_BASE_REMOTE = (2), + VirtualMemoryTable[Index].VirtualBase =3D DRAM_BLOCK2_BASE_REMOTE = (2), + VirtualMemoryTable[Index].Length =3D PcdGet64 (PcdDramBlock2S= ize); + VirtualMemoryTable[Index].Attributes =3D ARM_MEMORY_REGION_ATTRIB= UTE_WRITE_BACK; + +#if (FixedPcdGet32 (PcdChipCount) > 3) + // Chip 3 DDR Block 1 - (2GB) + VirtualMemoryTable[++Index].PhysicalBase =3D SYSTEM_MEMORY_BASE_REMOT= E (3), + VirtualMemoryTable[Index].VirtualBase =3D SYSTEM_MEMORY_BASE_REMOT= E (3), + VirtualMemoryTable[Index].Length =3D PcdGet64 (PcdSystemMemor= ySize); + VirtualMemoryTable[Index].Attributes =3D ARM_MEMORY_REGION_ATTRIB= UTE_WRITE_BACK; + + // Chip 3 DDR Block 2 - (6GB) + VirtualMemoryTable[++Index].PhysicalBase =3D DRAM_BLOCK2_BASE_REMOTE = (3), + VirtualMemoryTable[Index].VirtualBase =3D DRAM_BLOCK2_BASE_REMOTE = (3), + VirtualMemoryTable[Index].Length =3D PcdGet64 (PcdDramBlock2S= ize); + VirtualMemoryTable[Index].Attributes =3D ARM_MEMORY_REGION_ATTRIB= UTE_WRITE_BACK; +#endif +#endif +#endif + // PCI Configuration Space VirtualMemoryTable[++Index].PhysicalBase =3D PcdGet64 (PcdPciExpressB= aseAddress); VirtualMemoryTable[Index].VirtualBase =3D PcdGet64 (PcdPciExpressB= aseAddress); diff --git a/Platform/ARM/SgiPkg/SgiPlatform.dec b/Platform/ARM/SgiPkg/Sg= iPlatform.dec index 97c1e40349ea..dac7fdc308b1 100644 --- a/Platform/ARM/SgiPkg/SgiPlatform.dec +++ b/Platform/ARM/SgiPkg/SgiPlatform.dec @@ -46,6 +46,9 @@ [PcdsFixedAtBuild] gArmSgiTokenSpaceGuid.PcdVirtioNetSize|0x00000000|UINT32|0x00000008 gArmSgiTokenSpaceGuid.PcdVirtioNetInterrupt|0x00000000|UINT32|0x000000= 09 =20 + # Chip count on the platform + gArmSgiTokenSpaceGuid.PcdChipCount|1|UINT32|0x0000000B + # GIC gArmSgiTokenSpaceGuid.PcdGicSize|0|UINT64|0x0000000A =20 --=20 2.17.1