aboutsummaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorInochi Amaoto <inochiama@outlook.com>2023-12-10 17:44:54 +0800
committerAnup Patel <anup@brainfault.org>2023-12-11 09:23:24 +0530
commit87aa3069d14b52bf87cb14d8f6b3ed51b45465ea (patch)
tree168979658ae6bf1dcff0a39bfe88c7e9d8d65574 /platform
parenta25fc74699feb9409e44344dff742d525f315e5c (diff)
downloadopensbi-87aa3069d14b52bf87cb14d8f6b3ed51b45465ea.tar.gz
opensbi-87aa3069d14b52bf87cb14d8f6b3ed51b45465ea.tar.bz2
opensbi-87aa3069d14b52bf87cb14d8f6b3ed51b45465ea.zip
platform: recalculate heap size to support new tlb entry number
Previous patch introduced a change that using hart count as the default number of tlb entries in the fifo. This makes the default tlb fifo size grow in square with the number of harts. So the default heap size is not enough to allocate tlb fifo when the hart count is big. Fixes: 52fd64b ("platform: Uses hart count as the default size of tlb info") Signed-off-by: Inochi Amaoto <inochiama@outlook.com> Reviewed-by: Anup Patel <anup@brainfault.org>
Diffstat (limited to 'platform')
-rw-r--r--platform/generic/platform.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/platform/generic/platform.c b/platform/generic/platform.c
index f17e94ed..08ae92ae 100644
--- a/platform/generic/platform.c
+++ b/platform/generic/platform.c
@@ -10,7 +10,9 @@
#include <libfdt.h>
#include <platform_override.h>
#include <sbi/riscv_asm.h>
+#include <sbi/sbi_bitops.h>
#include <sbi/sbi_hartmask.h>
+#include <sbi/sbi_heap.h>
#include <sbi/sbi_platform.h>
#include <sbi/sbi_string.h>
#include <sbi/sbi_system.h>
@@ -54,6 +56,18 @@ static void fw_platform_lookup_special(void *fdt, int root_offset)
}
}
+static u32 fw_platform_calculate_heap_size(u32 hart_count)
+{
+ u32 heap_size;
+
+ heap_size = SBI_PLATFORM_DEFAULT_HEAP_SIZE(hart_count);
+
+ /* For TLB fifo */
+ heap_size += 0x40 * (hart_count) * (hart_count);
+
+ return BIT_ALIGN(heap_size, HEAP_BASE_ALIGN);
+}
+
extern struct sbi_platform platform;
static bool platform_has_mlevel_imsic = false;
static u32 generic_hart_index2id[SBI_HARTMASK_MAX_BITS] = { 0 };
@@ -115,7 +129,7 @@ unsigned long fw_platform_init(unsigned long arg0, unsigned long arg1,
}
platform.hart_count = hart_count;
- platform.heap_size = SBI_PLATFORM_DEFAULT_HEAP_SIZE(hart_count);
+ platform.heap_size = fw_platform_calculate_heap_size(hart_count);
platform_has_mlevel_imsic = fdt_check_imsic_mlevel(fdt);
/* Return original FDT pointer */