MLK-20450 Fix Linux NO SMP kernel with OPTEE
authorCedric Neveux <cedric.neveux@nxp.com>
Thu, 22 Nov 2018 14:27:09 +0000 (15:27 +0100)
committerLeonard Crestez <leonard.crestez@nxp.com>
Wed, 17 Apr 2019 23:51:34 +0000 (02:51 +0300)
   - Fix busfreq optee mode to not install the linux assembly function
   used to synchronize all CPU in case of SMP mode
   - Fix l2cache OPTEE/Linux share mutex operations

Signed-off-by: Cedric Neveux <cedric.neveux@nxp.com>
(cherry picked from commit 68f47bb3328e56c63d647f855fc654f4736658ce)
Signed-off-by: Arulpandiyan Vadivel <arulpandiyan_vadivel@mentor.com>
arch/arm/mach-imx/busfreq_optee.c
arch/arm/mm/cache-l2x0.c

index 2130052..1b2abd4 100644 (file)
 #include "hardware.h"
 #include "smc_sip.h"
 
+
+extern unsigned int ddr_normal_rate;
+static int curr_ddr_rate;
+
+#ifdef CONFIG_SMP
 /*
  * External declaration
  */
@@ -41,7 +46,6 @@ extern void imx_smp_wfe_optee(u32 cpuid, u32 status_addr);
 extern unsigned long imx_smp_wfe_start asm("imx_smp_wfe_optee");
 extern unsigned long imx_smp_wfe_end asm("imx_smp_wfe_optee_end");
 
-extern unsigned int ddr_normal_rate;
 extern unsigned long ddr_freq_change_iram_base;
 
 
@@ -62,9 +66,6 @@ static void (*wfe_change_freq)(uint32_t *wfe_status, uint32_t *freq_done);
 static uint32_t *irqs_for_wfe;
 static void __iomem *gic_dist_base;
 
-static int curr_ddr_rate;
-
-#ifdef CONFIG_SMP
 /**
  * @brief  Switch all active cores, except the one changing the
  *         bus frequency, in WFE mode until completion of the
@@ -119,7 +120,7 @@ int update_freq_optee(int ddr_rate)
        uint32_t all_cpus    = 0;
 #endif
 
-       pr_debug("\nBusfreq DDR3 OPTEE set from %d to %d start...\n",
+       pr_debug("\nBusfreq OPTEE set from %d to %d start...\n",
                        curr_ddr_rate, ddr_rate);
 
        if (ddr_rate == curr_ddr_rate)
@@ -189,6 +190,7 @@ int update_freq_optee(int ddr_rate)
        return 0;
 }
 
+#ifdef CONFIG_SMP
 static int init_freq_optee_smp(struct platform_device *busfreq_pdev)
 {
        struct device_node *node = 0;
@@ -297,4 +299,11 @@ int init_freq_optee(struct platform_device *busfreq_pdev)
 
        return err;
 }
+#else
+int init_freq_optee(struct platform_device *busfreq_pdev)
+{
+       curr_ddr_rate = ddr_normal_rate;
+       return 0;
+}
+#endif
 
index 7a6fe87..6bd9c65 100644 (file)
@@ -60,6 +60,16 @@ static bool l2x0_bresp_disable;
 static bool l2x0_flz_disable;
 
 #ifdef CONFIG_OPTEE
+
+#ifndef CONFIG_SMP
+/*
+ * Redefine the arch_writelock/unlock functions not present
+ * in NO SMP mode
+ */
+#define arch_write_lock(lock)  raw_spin_lock(lock)
+#define arch_write_unlock(lock)        raw_spin_unlock(lock)
+#endif
+
 struct l2x0_mutex {
        arch_rwlock_t *mutex;
        arch_rwlock_t nomutex;
@@ -81,7 +91,9 @@ static struct l2x0_mutex l2x0_lock;
 static void spinlock_init(struct l2x0_mutex *spinlock)
 {
        spinlock->mutex        = NULL;
+#ifdef CONFIG_SMP
        spinlock->nomutex.lock = 0;
+#endif
 }
 
 static unsigned long local_lock(struct l2x0_mutex *spinlock)