We expect start_optee_early() to be called with caches disabled, so there
is no point in calling sync_caches_for_execution inside.

Therefore let's verify the assumption that caches are indeed disabled
and drop the useless call.

Co-authored-by: Fabian Pflug <f.pf...@pengutronix.de>
Signed-off-by: Fabian Pflug <f.pf...@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fat...@pengutronix.de>
---
v1 -> v2:
  - panic instead of retuning error code (Rouven)
---
 arch/arm/lib32/optee-early.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/arm/lib32/optee-early.c b/arch/arm/lib32/optee-early.c
index 735d829c99fb..c9959b5e41b8 100644
--- a/arch/arm/lib32/optee-early.c
+++ b/arch/arm/lib32/optee-early.c
@@ -7,7 +7,9 @@
  */
 #include <asm/cache.h>
 #include <asm/setjmp.h>
+#include <asm/system.h>
 #include <tee/optee.h>
+#include <linux/bug.h>
 #include <debug_ll.h>
 #include <string.h>
 
@@ -19,6 +21,9 @@ int start_optee_early(void *fdt, void *tee)
        struct optee_header *hdr;
        int ret;
 
+       /* We expect this function to be called with data caches disabled */
+       BUG_ON(get_cr() & CR_C);
+
        hdr = tee;
        ret = optee_verify_header(hdr);
        if (ret < 0)
@@ -30,7 +35,6 @@ int start_optee_early(void *fdt, void *tee)
        /* We use setjmp/longjmp here because OP-TEE clobbers most registers */
        ret = setjmp(tee_buf);
        if (ret == 0) {
-               sync_caches_for_execution();
                tee_start(0, 0, fdt);
                longjmp(tee_buf, 1);
        }
-- 
2.39.5


Reply via email to