[PATCH 04/10] init: define new postmem_initcall()
Ahmad Fatoum
a.fatoum at pengutronix.de
Mon Aug 15 08:32:03 PDT 2022
Memory banks are added in mem_initcall() and are used in mmu_initcall()
which directly follows it to set caching attributes for the banks.
Code that requires memory banks to be registered, thus has to use
mmu_initcall(), but this is not possible for code that reliably needs to
run before MMU init: We need to give board code and device tree parsing
code the chance to reserve_sdram_region parts of SDRAM that contain
secure firmware to avoid speculative execution into them once the MMU is
turned on. For this reason, define a new postmem_initcall() level and
already use it for add_mem_devices, which has nothing to do with
mmu_initcall. Another user that can't be mmu_initcall() will follow in a
later commit.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
common/memory.c | 2 +-
include/asm-generic/barebox.lds.h | 1 +
include/init.h | 21 +++++++++++----------
3 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/common/memory.c b/common/memory.c
index 347f83fd4cf8..40c795d2cde1 100644
--- a/common/memory.c
+++ b/common/memory.c
@@ -195,7 +195,7 @@ static int add_mem_devices(void)
return 0;
}
-mmu_initcall(add_mem_devices);
+postmem_initcall(add_mem_devices);
/*
* Request a region from the registered sdram
diff --git a/include/asm-generic/barebox.lds.h b/include/asm-generic/barebox.lds.h
index a22e251c9d64..48c10b173852 100644
--- a/include/asm-generic/barebox.lds.h
+++ b/include/asm-generic/barebox.lds.h
@@ -35,6 +35,7 @@
KEEP(*(.initcall.13)) \
KEEP(*(.initcall.14)) \
KEEP(*(.initcall.15)) \
+ KEEP(*(.initcall.16)) \
__barebox_initcalls_end = .;
#define BAREBOX_EXITCALLS \
diff --git a/include/init.h b/include/init.h
index c695f99867ff..d0343fdf05cc 100644
--- a/include/init.h
+++ b/include/init.h
@@ -58,16 +58,17 @@ typedef void (*exitcall_t)(void);
#define console_initcall(fn) __define_initcall("3",fn,3)
#define postconsole_initcall(fn) __define_initcall("4",fn,4)
#define mem_initcall(fn) __define_initcall("5",fn,5)
-#define mmu_initcall(fn) __define_initcall("6",fn,6)
-#define postmmu_initcall(fn) __define_initcall("7",fn,7)
-#define coredevice_initcall(fn) __define_initcall("8",fn,8)
-#define fs_initcall(fn) __define_initcall("9",fn,9)
-#define device_initcall(fn) __define_initcall("10",fn,10)
-#define crypto_initcall(fn) __define_initcall("11",fn,11)
-#define of_populate_initcall(fn) __define_initcall("12",fn,12)
-#define late_initcall(fn) __define_initcall("13",fn,13)
-#define environment_initcall(fn) __define_initcall("14",fn,14)
-#define postenvironment_initcall(fn) __define_initcall("15",fn,15)
+#define postmem_initcall(fn) __define_initcall("6",fn,6)
+#define mmu_initcall(fn) __define_initcall("7",fn,7)
+#define postmmu_initcall(fn) __define_initcall("8",fn,8)
+#define coredevice_initcall(fn) __define_initcall("9",fn,9)
+#define fs_initcall(fn) __define_initcall("10",fn,10)
+#define device_initcall(fn) __define_initcall("11",fn,11)
+#define crypto_initcall(fn) __define_initcall("12",fn,12)
+#define of_populate_initcall(fn) __define_initcall("13",fn,13)
+#define late_initcall(fn) __define_initcall("14",fn,14)
+#define environment_initcall(fn) __define_initcall("15",fn,15)
+#define postenvironment_initcall(fn) __define_initcall("16",fn,16)
#define early_exitcall(fn) __define_exitcall("0",fn,0)
#define predevshutdown_exitcall(fn) __define_exitcall("1",fn,1)
--
2.30.2
More information about the barebox
mailing list