[coreboot-gerrit] Change in coreboot[master]: amd/pi/stoney: Split uma_base_auto function
Marshall Dawson (Code Review)
gerrit at coreboot.org
Mon Apr 3 17:56:36 CEST 2017
Marshall Dawson has uploaded a new change for review. ( https://review.coreboot.org/19083 )
Change subject: amd/pi/stoney: Split uma_base_auto function
......................................................................
amd/pi/stoney: Split uma_base_auto function
Break out the calculations in uma_base_auto() to their own functions.
This also moves setting the uma_memory_size variable back to the
northbridge.c file.
Change-Id: I08330da8c4da9a67a17699f9adec5652195e73ff
Signed-off-by: Marshall Dawson <marshalldawson3rd at gmail.com>
---
M src/northbridge/amd/pi/00670F00/Makefile.inc
M src/northbridge/amd/pi/00670F00/memmap.c
M src/northbridge/amd/pi/00670F00/memmap.h
M src/northbridge/amd/pi/00670F00/northbridge.c
4 files changed, 50 insertions(+), 29 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/83/19083/1
diff --git a/src/northbridge/amd/pi/00670F00/Makefile.inc b/src/northbridge/amd/pi/00670F00/Makefile.inc
index 9364d56..cdbcbb2 100644
--- a/src/northbridge/amd/pi/00670F00/Makefile.inc
+++ b/src/northbridge/amd/pi/00670F00/Makefile.inc
@@ -17,4 +17,5 @@
ramstage-y += northbridge.c
+romstage-y += memmap.c
ramstage-y += memmap.c
diff --git a/src/northbridge/amd/pi/00670F00/memmap.c b/src/northbridge/amd/pi/00670F00/memmap.c
index ca153e1..94bbf8f 100644
--- a/src/northbridge/amd/pi/00670F00/memmap.c
+++ b/src/northbridge/amd/pi/00670F00/memmap.c
@@ -15,8 +15,49 @@
#include <console/console.h>
#include <cpu/amd/mtrr.h>
-#include <device/device.h>
+#include "amdlib.h"
#include "memmap.h"
+
+static uint64_t installed_dram(void)
+{
+ uint64_t topmem;
+ uint64_t topmem2;
+ uint32_t sysmem_mb;
+ AMD_CONFIG_PARAMS StdHeader;
+
+ LibAmdMsrRead(TOP_MEM, &topmem, &StdHeader);
+ LibAmdMsrRead(TOP_MEM2, &topmem2, &StdHeader);
+
+ sysmem_mb = (topmem + (16ull << ONE_MB_SHIFT)) >> ONE_MB_SHIFT; // Ignore 16MB allocated for C6 when finding UMA size
+ sysmem_mb += topmem2 ? ((topmem2 >> ONE_MB_SHIFT) - 4096) : 0;
+ return sysmem_mb >> (ONE_GB_SHIFT - ONE_MB_SHIFT);
+}
+
+/*
+ * Return the size likely assigned to UMA when UMA_AUTO is specified.
+ * This is the only setting the wrapper currently implements. Refer to the
+ * BKDG for Family 15h Model 70h-7Fh Procesors (PID #55072) to find the
+ * following recommended configurations:
+ * Total system memory UMASize
+ * 6G+ 1024M
+ * 4G 512M
+ * 2G 256M
+ */
+uint64_t uma_size_auto(void)
+{
+ uint64_t sysmem_gb = installed_dram();
+
+ if (!CONFIG_GFXUMA) {
+ return 0;
+ } else if (sysmem_gb >= 6) {
+ return 1024 << ONE_MB_SHIFT;
+ } else if (sysmem_gb >= 4) {
+ return 512 << ONE_MB_SHIFT;
+ } else if (sysmem_gb >= 2) {
+ return 256 << ONE_MB_SHIFT;
+ }
+ return 128 << ONE_MB_SHIFT;
+}
/*
* The BinaryPI image is compiled to always assign UMA below 4GB. It will
@@ -24,33 +65,9 @@
*/
uint64_t uma_base_auto(void)
{
- uint64_t topmem = bsp_topmem();
- uint64_t topmem2 = bsp_topmem2();
- uint32_t sysmem_mb, sysmem_gb;
+ uint64_t topmem;
+ AMD_CONFIG_PARAMS StdHeader;
- /* refer to UMA_AUTO size computation in Family15h BKDG. */
- /* Please reference MemNGetUmaSizeML() */
- /*
- * Total system memory UMASize
- * >= 6G 1024M
- * >= 4G 512M
- * >= 2G 256M
- * < 2G 128M
- */
-
- sysmem_mb = (topmem + (16ull << ONE_MB_SHIFT)) >> ONE_MB_SHIFT; // Ignore 16MB allocated for C6 when finding UMA size
- sysmem_mb += topmem2 ? ((topmem2 >> ONE_MB_SHIFT) - 4096) : 0;
- sysmem_gb = sysmem_mb >> (ONE_GB_SHIFT - ONE_MB_SHIFT);
- printk(BIOS_SPEW, "%s: system memory size %luGB, topmem2 size %lluMB, topmem size %lluMB\n",
- __func__, (unsigned long)sysmem_gb, (topmem2 >> ONE_MB_SHIFT), (topmem >> ONE_MB_SHIFT));
- if (sysmem_gb >= 6) {
- uma_memory_size = 1024 << ONE_MB_SHIFT;
- } else if (sysmem_gb >= 4) {
- uma_memory_size = 512 << ONE_MB_SHIFT;
- } else if (sysmem_gb >= 2) {
- uma_memory_size = 256 << ONE_MB_SHIFT;
- } else {
- uma_memory_size = 128 << ONE_MB_SHIFT;
- }
- return topmem - uma_memory_size; /* TOP_MEM1 */
+ LibAmdMsrRead(TOP_MEM, &topmem, &StdHeader);
+ return topmem - uma_size_auto();
}
diff --git a/src/northbridge/amd/pi/00670F00/memmap.h b/src/northbridge/amd/pi/00670F00/memmap.h
index 9381aaa..f846b34 100644
--- a/src/northbridge/amd/pi/00670F00/memmap.h
+++ b/src/northbridge/amd/pi/00670F00/memmap.h
@@ -20,5 +20,6 @@
#define ONE_GB_SHIFT 30
uint64_t uma_base_auto(void);
+uint64_t uma_size_auto(void);
#endif /* NORTHBRIDGE_AMD_MEMMAP_H */
diff --git a/src/northbridge/amd/pi/00670F00/northbridge.c b/src/northbridge/amd/pi/00670F00/northbridge.c
index 953c633..b28ad8e 100644
--- a/src/northbridge/amd/pi/00670F00/northbridge.c
+++ b/src/northbridge/amd/pi/00670F00/northbridge.c
@@ -704,12 +704,14 @@
{
#if CONFIG_GFXUMA
uma_memory_base = uma_base_auto();
+ uma_memory_size = uma_size_auto();
printk(BIOS_INFO, "%s: uma size 0x%08llx, memory start 0x%08llx\n",
__func__, uma_memory_size, uma_memory_base);
#endif
}
+
static void domain_set_resources(device_t dev)
{
unsigned long mmio_basek;
--
To view, visit https://review.coreboot.org/19083
To unsubscribe, visit https://review.coreboot.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I08330da8c4da9a67a17699f9adec5652195e73ff
Gerrit-PatchSet: 1
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Owner: Marshall Dawson <marshalldawson3rd at gmail.com>
More information about the coreboot-gerrit
mailing list