MALI: utgard: upgrade DDK to r7p0-00rel0
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / arm / mali400 / mali / common / mali_group.c
index b9651a40e5b5dee8ab95b378dbffcc0ed2baa525..19b2ee7e3a5ab6a8c71b9581b0d1bce3e9dc9dbc 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011-2015 ARM Limited. All rights reserved.
+ * Copyright (C) 2011-2016 ARM Limited. All rights reserved.
  * 
  * This program is free software and is provided to you under the terms of the GNU General Public License version 2
  * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
@@ -18,6 +18,7 @@
 #include "mali_broadcast.h"
 #include "mali_scheduler.h"
 #include "mali_osk_profiling.h"
+#include "mali_osk_mali.h"
 #include "mali_pm_domain.h"
 #include "mali_pm.h"
 #include "mali_executor.h"
@@ -47,7 +48,7 @@ static void mali_group_timeout(void *data);
 static void mali_group_reset_pp(struct mali_group *group);
 static void mali_group_reset_mmu(struct mali_group *group);
 
-static void mali_group_activate_page_directory(struct mali_group *group, struct mali_session_data *session);
+static void mali_group_activate_page_directory(struct mali_group *group, struct mali_session_data *session, mali_bool is_reload);
 static void mali_group_recovery_reset(struct mali_group *group);
 
 struct mali_group *mali_group_create(struct mali_l2_cache_core *core,
@@ -786,7 +787,6 @@ void mali_group_reset(struct mali_group *group)
        MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
        MALI_DEBUG_ASSERT(NULL == group->gp_running_job);
        MALI_DEBUG_ASSERT(NULL == group->pp_running_job);
-       MALI_DEBUG_ASSERT(NULL == group->session);
 
        MALI_DEBUG_PRINT(3, ("Group: reset of %s\n",
                             mali_group_core_description(group)));
@@ -811,7 +811,7 @@ void mali_group_reset(struct mali_group *group)
        }
 }
 
-void mali_group_start_gp_job(struct mali_group *group, struct mali_gp_job *job)
+void mali_group_start_gp_job(struct mali_group *group, struct mali_gp_job *job, mali_bool gpu_secure_mode_pre_enabled)
 {
        struct mali_session_data *session;
 
@@ -826,7 +826,23 @@ void mali_group_start_gp_job(struct mali_group *group, struct mali_gp_job *job)
        MALI_DEBUG_ASSERT_POINTER(group->l2_cache_core[0]);
        mali_l2_cache_invalidate_conditional(group->l2_cache_core[0], mali_gp_job_get_cache_order(job));
 
-       mali_group_activate_page_directory(group, session);
+       /* Reset GPU and disable gpu secure mode if needed. */
+       if (MALI_TRUE == _mali_osk_gpu_secure_mode_is_enabled()) {
+               struct mali_pmu_core *pmu = mali_pmu_get_global_pmu_core();
+               _mali_osk_gpu_reset_and_secure_mode_disable();
+               /* Need to disable the pmu interrupt mask register */
+               if (NULL != pmu) {
+                       mali_pmu_reset(pmu);
+               }
+       }
+
+       /* Reload mmu page table if needed */
+       if (MALI_TRUE == gpu_secure_mode_pre_enabled) {
+               mali_group_reset(group);
+               mali_group_activate_page_directory(group, session, MALI_TRUE);
+       } else {
+               mali_group_activate_page_directory(group, session, MALI_FALSE);
+       }
 
        mali_gp_job_start(group->gp_core, job);
 
@@ -874,7 +890,7 @@ void mali_group_start_gp_job(struct mali_group *group, struct mali_gp_job *job)
 /* Used to set all the registers except frame renderer list address and fragment shader stack address
  * It means the caller must set these two registers properly before calling this function
  */
-void mali_group_start_pp_job(struct mali_group *group, struct mali_pp_job *job, u32 sub_job)
+void mali_group_start_pp_job(struct mali_group *group, struct mali_pp_job *job, u32 sub_job, mali_bool gpu_secure_mode_pre_enabled)
 {
        struct mali_session_data *session;
 
@@ -895,7 +911,31 @@ void mali_group_start_pp_job(struct mali_group *group, struct mali_pp_job *job,
                mali_l2_cache_invalidate_conditional(group->l2_cache_core[1], mali_pp_job_get_cache_order(job));
        }
 
-       mali_group_activate_page_directory(group, session);
+       /* Reset GPU and change gpu secure mode if needed. */
+       if (MALI_TRUE == mali_pp_job_is_protected_job(job) && MALI_FALSE == _mali_osk_gpu_secure_mode_is_enabled()) {
+               struct mali_pmu_core *pmu = mali_pmu_get_global_pmu_core();
+               _mali_osk_gpu_reset_and_secure_mode_enable();
+               /* Need to disable the pmu interrupt mask register */
+               if (NULL != pmu) {
+                       mali_pmu_reset(pmu);
+               }
+       } else if (MALI_FALSE == mali_pp_job_is_protected_job(job) && MALI_TRUE == _mali_osk_gpu_secure_mode_is_enabled()) {
+               struct mali_pmu_core *pmu = mali_pmu_get_global_pmu_core();
+               _mali_osk_gpu_reset_and_secure_mode_disable();
+               /* Need to disable the pmu interrupt mask register */
+               if (NULL != pmu) {
+                       mali_pmu_reset(pmu);
+               }
+       }
+
+       /* Reload the mmu page table if needed */
+       if ((MALI_TRUE == mali_pp_job_is_protected_job(job) && MALI_FALSE == gpu_secure_mode_pre_enabled)
+           || (MALI_FALSE == mali_pp_job_is_protected_job(job) && MALI_TRUE == gpu_secure_mode_pre_enabled)) {
+               mali_group_reset(group);
+               mali_group_activate_page_directory(group, session, MALI_TRUE);
+       } else {
+               mali_group_activate_page_directory(group, session, MALI_FALSE);
+       }
 
        if (mali_group_is_virtual(group)) {
                struct mali_group *child;
@@ -1266,7 +1306,7 @@ u32 mali_group_get_glob_num_groups(void)
        return mali_global_num_groups;
 }
 
-static void mali_group_activate_page_directory(struct mali_group *group, struct mali_session_data *session)
+static void mali_group_activate_page_directory(struct mali_group *group, struct mali_session_data *session, mali_bool is_reload)
 {
        MALI_DEBUG_PRINT(5, ("Mali group: Activating page directory 0x%08X from session 0x%08X on group %s\n",
                             mali_session_get_page_directory(session), session,
@@ -1274,7 +1314,7 @@ static void mali_group_activate_page_directory(struct mali_group *group, struct
 
        MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
 
-       if (group->session != session) {
+       if (group->session != session || MALI_TRUE == is_reload) {
                /* Different session than last time, so we need to do some work */
                MALI_DEBUG_PRINT(5, ("Mali group: Activate session: %08x previous: %08x on group %s\n",
                                     session, group->session,