PD#103748 mali r5p0 release
authorJiyu Yang <jiyu.yang@amlogic.com>
Tue, 10 Mar 2015 05:45:19 +0000 (13:45 +0800)
committerJiyu Yang <jiyu.yang@amlogic.com>
Tue, 10 Mar 2015 08:17:39 +0000 (16:17 +0800)
Change-Id: I3521eafa6dcc8da8c143edc96bf35a459c1e2c9b
Signed-off-by: Jiyu Yang <jiyu.yang@amlogic.com>
18 files changed:
mali/Kbuild
mali/Kconfig
mali/Makefile
mali/common/mali_gp_scheduler.c [deleted file]
mali/common/mali_gp_scheduler.h [deleted file]
mali/common/mali_group.c
mali/common/mali_l2_cache.c
mali/linux/mali_kernel_linux.c
mali/linux/mali_pmu_power_up_down.c
mali/platform/mali_clock.c
mali/platform/mali_pm_device.c
mali/platform/meson_m400/platform_mx.c
mali/platform/meson_m450/platform_g9tv.c [deleted file]
mali/platform/meson_m450/platform_m8.c
mali/platform/meson_m450/platform_m8b.c
mali/platform/meson_m450/scaling.c
mali/platform/meson_main.c
mali/platform/meson_main.h

index 053750641a0a5d71c575c4b95f4d74ca17f48b56..3b7a61bc7e31f6d4df51901722c962bb871dc68c 100755 (executable)
@@ -40,7 +40,13 @@ ifneq ($(KBUILD_SRC),)
 endif
 
 OS_MEMORY_KERNEL_BUFFER_SIZE_IN_MB ?= 16
-USING_GPU_UTILIZATION ?= 1
+
+#USING_GPU_UTILIZATION ?= 0
+#PROFILING_SKIP_PP_JOBS ?= 0
+#PROFILING_SKIP_PP_AND_GP_JOBS ?= 0
+
+USING_GPU_UTILIZATION=1
+USING_DVFS=0
 PROFILING_SKIP_PP_JOBS ?= 0
 PROFILING_SKIP_PP_AND_GP_JOBS ?= 0
 ############## Kasin Added, for platform. ################
@@ -50,9 +56,6 @@ else
        BUILD ?= release
        ldflags-y += --strip-debug
 endif
-ifeq ($(CONFIG_CONFIG_MALI_DVFS),y)
-       USING_GPU_UTILIZATION = 1
-endif
 ##################### end Kasin Added. ###################
 
 ############## Kasin Added, useless now. ################
@@ -77,7 +80,27 @@ MALI_ENABLE_CPU_CYCLES ?= 0
 # For customer releases the Linux Device Drivers will be provided as ARM proprietary and GPL releases:
 # The ARM proprietary product will only include the license/proprietary directory
 # The GPL product will only include the license/gpl directory
-ccflags-y += -I$(TOP_KBUILD_SRC)$(DRIVER_DIR)/linux/license/gpl
+ifeq ($(wildcard $(TOP_KBUILD_SRC)$(DRIVER_DIR)/linux/license/gpl/*),)
+    ccflags-y += -I$(TOP_KBUILD_SRC)$(DRIVER_DIR)/linux/license/proprietary
+    ifeq ($(CONFIG_MALI400_PROFILING),y)
+        $(error Profiling is incompatible with non-GPL license)
+    endif
+    ifeq ($(CONFIG_PM_RUNTIME),y)
+        $(error Runtime PM is incompatible with non-GPL license)
+    endif
+    ifeq ($(CONFIG_DMA_SHARED_BUFFER),y)
+        $(error DMA-BUF is incompatible with non-GPL license)
+    endif
+    $(error Linux Device integration is incompatible with non-GPL license)
+else
+    ccflags-y += -I$(TOP_KBUILD_SRC)$(DRIVER_DIR)/linux/license/gpl
+endif
+
+ifeq ($(USING_GPU_UTILIZATION), 1)
+    ifeq ($(USING_DVFS), 1)
+        $(error USING_GPU_UTILIZATION conflict with USING_DVFS you can read the Integration Guide to choose which one do you need)
+    endif
+endif
 
 mali-y += \
        linux/mali_osk_atomics.o \
@@ -174,7 +197,7 @@ mali-$(CONFIG_ARCH_MESON8B) += \
        platform/meson_m450/platform_m8b.o
 
 mali-$(CONFIG_ARCH_MESONG9TV) += \
-       platform/meson_m450/platform_g9tv.o
+       platform/meson_m450/platform_m8.o
 endif
 ##################### end Kasin Added. ###################
 
index fcaef990b0ba2b160d2230ca815bc50e18ad4ae6..ba29d721ad7884f0aa90555a75f87ebdae8d253c 100755 (executable)
@@ -14,6 +14,7 @@ config MALI400
 config MALI400_DEBUG
        bool "Enable debug in Mali driver"
        depends on MALI400
+       default n
        ---help---
          This enabled extra debug checks and messages in the Mali driver.
 
index b89d5f70f6158ff8a53cf0a29561a128a7576161..412e9ce9577695f88e303553da183a4ebf98f880 100755 (executable)
@@ -11,7 +11,7 @@
 USE_UMPV2=0
 USING_PROFILING ?= 1
 USING_INTERNAL_PROFILING ?= 0
-USING_DVFS ?= 0
+USING_DVFS ?= 1
 MALI_HEATMAPS_ENABLED ?= 0
 MALI_DMA_BUF_MAP_ON_ATTACH ?= 1
 MALI_PMU_PARALLEL_POWER_UP ?= 0
diff --git a/mali/common/mali_gp_scheduler.c b/mali/common/mali_gp_scheduler.c
deleted file mode 100755 (executable)
index 4a3e9a4..0000000
+++ /dev/null
@@ -1,695 +0,0 @@
-/*
- * Copyright (C) 2012-2014 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.
- * 
- * A copy of the licence is included with the program, and can also be obtained from Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-#include "mali_gp_scheduler.h"
-#include "mali_kernel_common.h"
-#include "mali_osk.h"
-#include "mali_osk_list.h"
-#include "mali_scheduler.h"
-#include "mali_gp.h"
-#include "mali_gp_job.h"
-#include "mali_group.h"
-#include "mali_timeline.h"
-#include "mali_osk_profiling.h"
-#include "mali_kernel_utilization.h"
-#if defined(CONFIG_GPU_TRACEPOINTS) && defined(CONFIG_TRACEPOINTS)
-#include <linux/sched.h>
-#include <trace/events/gpu.h>
-#endif
-
-enum mali_gp_slot_state {
-       MALI_GP_SLOT_STATE_IDLE,
-       MALI_GP_SLOT_STATE_WORKING,
-       MALI_GP_SLOT_STATE_DISABLED,
-};
-
-/* A render slot is an entity which jobs can be scheduled onto */
-struct mali_gp_slot {
-       struct mali_group *group;
-       /*
-        * We keep track of the state here as well as in the group object
-        * so we don't need to take the group lock so often (and also avoid clutter with the working lock)
-        */
-       enum mali_gp_slot_state state;
-       u32 returned_cookie;
-};
-
-static u32 gp_version = 0;
-static _MALI_OSK_LIST_HEAD_STATIC_INIT(job_queue);      /* List of unscheduled jobs. */
-static _MALI_OSK_LIST_HEAD_STATIC_INIT(job_queue_high); /* List of unscheduled high priority jobs. */
-static struct mali_gp_slot slot;
-
-/* Variables to allow safe pausing of the scheduler */
-static _mali_osk_wait_queue_t *gp_scheduler_working_wait_queue = NULL;
-static u32 pause_count = 0;
-
-static mali_bool mali_gp_scheduler_is_suspended(void *data);
-static void mali_gp_scheduler_job_queued(void);
-static void mali_gp_scheduler_job_completed(void);
-
-#if defined(MALI_UPPER_HALF_SCHEDULING)
-static _mali_osk_spinlock_irq_t *gp_scheduler_lock = NULL;
-#else
-static _mali_osk_spinlock_t *gp_scheduler_lock = NULL;
-#endif /* defined(MALI_UPPER_HALF_SCHEDULING) */
-
-_mali_osk_errcode_t mali_gp_scheduler_initialize(void)
-{
-       u32 num_groups;
-       u32 i;
-       _mali_osk_errcode_t ret = _MALI_OSK_ERR_OK;
-
-#if defined(MALI_UPPER_HALF_SCHEDULING)
-       gp_scheduler_lock = _mali_osk_spinlock_irq_init(_MALI_OSK_LOCKFLAG_ORDERED, _MALI_OSK_LOCK_ORDER_SCHEDULER);
-#else
-       gp_scheduler_lock = _mali_osk_spinlock_init(_MALI_OSK_LOCKFLAG_ORDERED, _MALI_OSK_LOCK_ORDER_SCHEDULER);
-#endif /* defined(MALI_UPPER_HALF_SCHEDULING) */
-       if (NULL == gp_scheduler_lock) {
-               ret = _MALI_OSK_ERR_NOMEM;
-               goto cleanup;
-       }
-
-       gp_scheduler_working_wait_queue = _mali_osk_wait_queue_init();
-       if (NULL == gp_scheduler_working_wait_queue) {
-               ret = _MALI_OSK_ERR_NOMEM;
-               goto cleanup;
-       }
-
-       /* Find all the available GP cores */
-       num_groups = mali_group_get_glob_num_groups();
-       for (i = 0; i < num_groups; i++) {
-               struct mali_group *group = mali_group_get_glob_group(i);
-               MALI_DEBUG_ASSERT(NULL != group);
-               if (NULL != group) {
-                       struct mali_gp_core *gp_core = mali_group_get_gp_core(group);
-                       if (NULL != gp_core) {
-                               if (0 == gp_version) {
-                                       /* Retrieve GP version */
-                                       gp_version = mali_gp_core_get_version(gp_core);
-                               }
-                               slot.group = group;
-                               slot.state = MALI_GP_SLOT_STATE_IDLE;
-                               break; /* There is only one GP, no point in looking for more */
-                       }
-               } else {
-                       ret = _MALI_OSK_ERR_ITEM_NOT_FOUND;
-                       goto cleanup;
-               }
-       }
-
-       return _MALI_OSK_ERR_OK;
-
-cleanup:
-       if (NULL != gp_scheduler_working_wait_queue) {
-               _mali_osk_wait_queue_term(gp_scheduler_working_wait_queue);
-               gp_scheduler_working_wait_queue = NULL;
-       }
-
-       if (NULL != gp_scheduler_lock) {
-#if defined(MALI_UPPER_HALF_SCHEDULING)
-               _mali_osk_spinlock_irq_term(gp_scheduler_lock);
-#else
-               _mali_osk_spinlock_term(gp_scheduler_lock);
-#endif /* defined(MALI_UPPER_HALF_SCHEDULING) */
-               gp_scheduler_lock = NULL;
-       }
-
-       return ret;
-}
-
-void mali_gp_scheduler_terminate(void)
-{
-       MALI_DEBUG_ASSERT(MALI_GP_SLOT_STATE_IDLE     == slot.state
-                         || MALI_GP_SLOT_STATE_DISABLED == slot.state);
-       MALI_DEBUG_ASSERT_POINTER(slot.group);
-       mali_group_delete(slot.group);
-
-       _mali_osk_wait_queue_term(gp_scheduler_working_wait_queue);
-
-#if defined(MALI_UPPER_HALF_SCHEDULING)
-       _mali_osk_spinlock_irq_term(gp_scheduler_lock);
-#else
-       _mali_osk_spinlock_term(gp_scheduler_lock);
-#endif /* defined(MALI_UPPER_HALF_SCHEDULING) */
-}
-
-MALI_STATIC_INLINE void mali_gp_scheduler_lock(void)
-{
-#if defined(MALI_UPPER_HALF_SCHEDULING)
-       _mali_osk_spinlock_irq_lock(gp_scheduler_lock);
-#else
-       _mali_osk_spinlock_lock(gp_scheduler_lock);
-#endif /* defined(MALI_UPPER_HALF_SCHEDULING) */
-       MALI_DEBUG_PRINT(5, ("Mali GP scheduler: GP scheduler lock taken\n"));
-}
-
-MALI_STATIC_INLINE void mali_gp_scheduler_unlock(void)
-{
-       MALI_DEBUG_PRINT(5, ("Mali GP scheduler: Releasing GP scheduler lock\n"));
-#if defined(MALI_UPPER_HALF_SCHEDULING)
-       _mali_osk_spinlock_irq_unlock(gp_scheduler_lock);
-#else
-       _mali_osk_spinlock_unlock(gp_scheduler_lock);
-#endif /* defined(MALI_UPPER_HALF_SCHEDULING) */
-}
-
-#if defined(DEBUG)
-#define MALI_ASSERT_GP_SCHEDULER_LOCKED() MALI_DEBUG_ASSERT_LOCK_HELD(gp_scheduler_lock)
-#else
-#define MALI_ASSERT_GP_SCHEDULER_LOCKED() do {} while (0)
-#endif /* defined(DEBUG) */
-
-/* Group and scheduler must be locked when entering this function.  Both will be unlocked before
- * exiting. */
-static void mali_gp_scheduler_schedule_internal_and_unlock(void)
-{
-       struct mali_gp_job *job = NULL;
-
-       MALI_DEBUG_ASSERT_LOCK_HELD(slot.group->lock);
-       MALI_DEBUG_ASSERT_LOCK_HELD(gp_scheduler_lock);
-
-       if (0 < pause_count || MALI_GP_SLOT_STATE_IDLE != slot.state ||
-           (_mali_osk_list_empty(&job_queue) && _mali_osk_list_empty(&job_queue_high))) {
-               mali_gp_scheduler_unlock();
-               mali_group_unlock(slot.group);
-               MALI_DEBUG_PRINT(4, ("Mali GP scheduler: Nothing to schedule (paused=%u, idle slots=%u)\n",
-                                    pause_count, MALI_GP_SLOT_STATE_IDLE == slot.state ? 1 : 0));
-#if defined(CONFIG_GPU_TRACEPOINTS) && defined(CONFIG_TRACEPOINTS)
-               trace_gpu_sched_switch(mali_gp_get_hw_core_desc(group->gp_core), sched_clock(), 0, 0, 0);
-#endif
-               return; /* Nothing to do, so early out */
-       }
-
-       /* Get next job in queue */
-       if (!_mali_osk_list_empty(&job_queue_high)) {
-               job = _MALI_OSK_LIST_ENTRY(job_queue_high.next, struct mali_gp_job, list);
-       } else {
-               MALI_DEBUG_ASSERT(!_mali_osk_list_empty(&job_queue));
-               job = _MALI_OSK_LIST_ENTRY(job_queue.next, struct mali_gp_job, list);
-       }
-
-       MALI_DEBUG_ASSERT_POINTER(job);
-
-       /* Remove the job from queue */
-       _mali_osk_list_del(&job->list);
-
-       /* Mark slot as busy */
-       slot.state = MALI_GP_SLOT_STATE_WORKING;
-
-       mali_gp_scheduler_unlock();
-
-       MALI_DEBUG_PRINT(3, ("Mali GP scheduler: Starting job %u (0x%08X)\n", mali_gp_job_get_id(job), job));
-
-       mali_group_start_gp_job(slot.group, job);
-       mali_group_unlock(slot.group);
-}
-
-void mali_gp_scheduler_schedule(void)
-{
-       mali_group_lock(slot.group);
-       mali_gp_scheduler_lock();
-
-       mali_gp_scheduler_schedule_internal_and_unlock();
-}
-
-static void mali_gp_scheduler_return_job_to_user(struct mali_gp_job *job, mali_bool success)
-{
-       _mali_uk_gp_job_finished_s *jobres = job->finished_notification->result_buffer;
-       _mali_osk_memset(jobres, 0, sizeof(_mali_uk_gp_job_finished_s)); /* @@@@ can be removed once we initialize all members in this struct */
-       jobres->user_job_ptr = mali_gp_job_get_user_id(job);
-       if (MALI_TRUE == success) {
-               jobres->status = _MALI_UK_JOB_STATUS_END_SUCCESS;
-       } else {
-               jobres->status = _MALI_UK_JOB_STATUS_END_UNKNOWN_ERR;
-       }
-
-       jobres->heap_current_addr = mali_gp_job_get_current_heap_addr(job);
-       jobres->perf_counter0 = mali_gp_job_get_perf_counter_value0(job);
-       jobres->perf_counter1 = mali_gp_job_get_perf_counter_value1(job);
-
-       mali_session_send_notification(mali_gp_job_get_session(job), job->finished_notification);
-       job->finished_notification = NULL;
-
-       mali_gp_job_delete(job);
-       mali_gp_scheduler_job_completed();
-}
-
-/* Group must be locked when entering this function.  Will be unlocked before exiting. */
-void mali_gp_scheduler_job_done(struct mali_group *group, struct mali_gp_job *job, mali_bool success)
-{
-       mali_scheduler_mask schedule_mask = MALI_SCHEDULER_MASK_EMPTY;
-
-       MALI_DEBUG_ASSERT_POINTER(group);
-       MALI_DEBUG_ASSERT_POINTER(job);
-
-       MALI_DEBUG_ASSERT_LOCK_HELD(group->lock);
-       MALI_DEBUG_ASSERT(slot.group == group);
-
-       MALI_DEBUG_PRINT(3, ("Mali GP scheduler: Job %u (0x%08X) completed (%s)\n", mali_gp_job_get_id(job), job, success ? "success" : "failure"));
-
-       /* Release tracker. */
-       schedule_mask |= mali_timeline_tracker_release(&job->tracker);
-
-       /* Signal PP job. */
-       schedule_mask |= mali_gp_job_signal_pp_tracker(job, success);
-
-       mali_gp_scheduler_lock();
-
-       /* Mark slot as idle again */
-       slot.state = MALI_GP_SLOT_STATE_IDLE;
-
-       /* If paused, then this was the last job, so wake up sleeping workers */
-       if (pause_count > 0) {
-               _mali_osk_wait_queue_wake_up(gp_scheduler_working_wait_queue);
-       }
-
-       /* Schedule any queued GP jobs on this group. */
-       mali_gp_scheduler_schedule_internal_and_unlock();
-
-       /* GP is now scheduled, removing it from the mask. */
-       schedule_mask &= ~MALI_SCHEDULER_MASK_GP;
-
-       if (MALI_SCHEDULER_MASK_EMPTY != schedule_mask) {
-               /* Releasing the tracker activated other jobs that need scheduling. */
-               mali_scheduler_schedule_from_mask(schedule_mask, MALI_FALSE);
-       }
-
-       /* Sends the job end message to user space and free the job object */
-       mali_gp_scheduler_return_job_to_user(job, success);
-}
-
-void mali_gp_scheduler_oom(struct mali_group *group, struct mali_gp_job *job)
-{
-       _mali_uk_gp_job_suspended_s *jobres;
-       _mali_osk_notification_t *notification;
-
-       mali_gp_scheduler_lock();
-
-       notification = job->oom_notification;
-       job->oom_notification = NULL;
-       slot.returned_cookie = mali_gp_job_get_id(job);
-
-       jobres = (_mali_uk_gp_job_suspended_s *)notification->result_buffer;
-       jobres->user_job_ptr = mali_gp_job_get_user_id(job);
-       jobres->cookie = mali_gp_job_get_id(job);
-
-       mali_gp_scheduler_unlock();
-
-       mali_session_send_notification(mali_gp_job_get_session(job), notification);
-
-       /*
-       * If this function failed, then we could return the job to user space right away,
-       * but there is a job timer anyway that will do that eventually.
-       * This is not exactly a common case anyway.
-       */
-}
-
-void mali_gp_scheduler_suspend(void)
-{
-       mali_gp_scheduler_lock();
-       pause_count++; /* Increment the pause_count so that no more jobs will be scheduled */
-       mali_gp_scheduler_unlock();
-
-       _mali_osk_wait_queue_wait_event(gp_scheduler_working_wait_queue, mali_gp_scheduler_is_suspended, NULL);
-}
-
-void mali_gp_scheduler_resume(void)
-{
-       mali_gp_scheduler_lock();
-       pause_count--; /* Decrement pause_count to allow scheduling again (if it reaches 0) */
-       mali_gp_scheduler_unlock();
-       if (0 == pause_count) {
-               mali_gp_scheduler_schedule();
-       }
-}
-
-mali_timeline_point mali_gp_scheduler_submit_job(struct mali_session_data *session, struct mali_gp_job *job)
-{
-       mali_timeline_point point;
-
-       MALI_DEBUG_ASSERT_POINTER(session);
-       MALI_DEBUG_ASSERT_POINTER(job);
-
-       /* We hold a PM reference for every job we hold queued (and running) */
-       _mali_osk_pm_dev_ref_add();
-
-       /* Add job to Timeline system. */
-       point = mali_timeline_system_add_tracker(session->timeline_system, &job->tracker, MALI_TIMELINE_GP);
-
-       return point;
-}
-
-_mali_osk_errcode_t _mali_ukk_gp_start_job(void *ctx, _mali_uk_gp_start_job_s *uargs)
-{
-       struct mali_session_data *session;
-       struct mali_gp_job *job;
-       mali_timeline_point point;
-       u32 __user *timeline_point_ptr = NULL;
-
-       MALI_DEBUG_ASSERT_POINTER(uargs);
-       MALI_DEBUG_ASSERT_POINTER(ctx);
-
-       session = (struct mali_session_data *)ctx;
-
-       job = mali_gp_job_create(session, uargs, mali_scheduler_get_new_id(), NULL);
-       if (NULL == job) {
-               MALI_PRINT_ERROR(("Failed to create GP job.\n"));
-               return _MALI_OSK_ERR_NOMEM;
-       }
-
-       timeline_point_ptr = (u32 __user *)(uintptr_t)job->uargs.timeline_point_ptr;
-
-       point = mali_gp_scheduler_submit_job(session, job);
-
-       if (0 != _mali_osk_put_user(((u32) point), timeline_point_ptr)) {
-               /* Let user space know that something failed after the job was started. */
-               return _MALI_OSK_ERR_ITEM_NOT_FOUND;
-       }
-
-       return _MALI_OSK_ERR_OK;
-}
-
-_mali_osk_errcode_t _mali_ukk_get_gp_number_of_cores(_mali_uk_get_gp_number_of_cores_s *args)
-{
-       MALI_DEBUG_ASSERT_POINTER(args);
-       MALI_DEBUG_ASSERT_POINTER((struct mali_session_data *)(uintptr_t)args->ctx);
-
-       args->number_of_cores = 1;
-       return _MALI_OSK_ERR_OK;
-}
-
-_mali_osk_errcode_t _mali_ukk_get_gp_core_version(_mali_uk_get_gp_core_version_s *args)
-{
-       MALI_DEBUG_ASSERT_POINTER(args);
-       MALI_DEBUG_ASSERT_POINTER((struct mali_session_data *)(uintptr_t)args->ctx);
-
-       args->version = gp_version;
-       return _MALI_OSK_ERR_OK;
-}
-
-_mali_osk_errcode_t _mali_ukk_gp_suspend_response(_mali_uk_gp_suspend_response_s *args)
-{
-       struct mali_gp_job *resumed_job;
-       _mali_osk_notification_t *new_notification = NULL;
-
-       MALI_DEBUG_ASSERT_POINTER(args);
-
-       if (_MALIGP_JOB_RESUME_WITH_NEW_HEAP == args->code) {
-               new_notification = _mali_osk_notification_create(_MALI_NOTIFICATION_GP_STALLED, sizeof(_mali_uk_gp_job_suspended_s));
-
-               if (NULL == new_notification) {
-                       MALI_PRINT_ERROR(("Mali GP scheduler: Failed to allocate notification object. Will abort GP job.\n"));
-                       mali_group_lock(slot.group);
-                       mali_group_abort_gp_job(slot.group, args->cookie);
-                       mali_group_unlock(slot.group);
-                       return _MALI_OSK_ERR_FAULT;
-               }
-       }
-
-       mali_group_lock(slot.group);
-
-       if (_MALIGP_JOB_RESUME_WITH_NEW_HEAP == args->code) {
-               MALI_DEBUG_PRINT(3, ("Mali GP scheduler: Resuming job %u with new heap; 0x%08X - 0x%08X\n", args->cookie, args->arguments[0], args->arguments[1]));
-
-               resumed_job = mali_group_resume_gp_with_new_heap(slot.group, args->cookie, args->arguments[0], args->arguments[1]);
-               if (NULL != resumed_job) {
-                       resumed_job->oom_notification = new_notification;
-                       mali_group_unlock(slot.group);
-                       return _MALI_OSK_ERR_OK;
-               } else {
-                       mali_group_unlock(slot.group);
-                       _mali_osk_notification_delete(new_notification);
-                       return _MALI_OSK_ERR_FAULT;
-               }
-       }
-
-       MALI_DEBUG_PRINT(2, ("Mali GP scheduler: Aborting job %u, no new heap provided\n", args->cookie));
-       mali_group_abort_gp_job(slot.group, args->cookie);
-       mali_group_unlock(slot.group);
-       return _MALI_OSK_ERR_OK;
-}
-
-void mali_gp_scheduler_abort_session(struct mali_session_data *session)
-{
-       struct mali_gp_job *job, *tmp;
-       _MALI_OSK_LIST_HEAD_STATIC_INIT(removed_jobs);
-
-       MALI_DEBUG_ASSERT_POINTER(session);
-       MALI_DEBUG_ASSERT(session->is_aborting);
-
-       MALI_DEBUG_PRINT(3, ("Mali GP scheduler: Aborting all jobs from session 0x%08X.\n", session));
-
-       mali_gp_scheduler_lock();
-
-       /* Find all jobs from the aborting session. */
-       _MALI_OSK_LIST_FOREACHENTRY(job, tmp, &job_queue, struct mali_gp_job, list) {
-               if (job->session == session) {
-                       MALI_DEBUG_PRINT(3, ("Mali GP scheduler: Removing job %u (0x%08X) from queue.\n", mali_gp_job_get_id(job), job));
-                       _mali_osk_list_move(&job->list, &removed_jobs);
-               }
-       }
-
-       /* Find all high priority jobs from the aborting session. */
-       _MALI_OSK_LIST_FOREACHENTRY(job, tmp, &job_queue_high, struct mali_gp_job, list) {
-               if (job->session == session) {
-                       MALI_DEBUG_PRINT(3, ("Mali GP scheduler: Removing job %u (0x%08X) from queue.\n", mali_gp_job_get_id(job), job));
-                       _mali_osk_list_move(&job->list, &removed_jobs);
-               }
-       }
-
-       mali_gp_scheduler_unlock();
-
-       /* Release and delete all found jobs from the aborting session. */
-       _MALI_OSK_LIST_FOREACHENTRY(job, tmp, &removed_jobs, struct mali_gp_job, list) {
-               mali_timeline_tracker_release(&job->tracker);
-               mali_gp_job_signal_pp_tracker(job, MALI_FALSE);
-               mali_gp_job_delete(job);
-               mali_gp_scheduler_job_completed();
-       }
-
-       /* Abort any running jobs from the session. */
-       mali_group_abort_session(slot.group, session);
-}
-
-static mali_bool mali_gp_scheduler_is_suspended(void *data)
-{
-       mali_bool ret;
-
-       /* This callback does not use the data pointer. */
-       MALI_IGNORE(data);
-
-       mali_gp_scheduler_lock();
-       ret = pause_count > 0 && (slot.state == MALI_GP_SLOT_STATE_IDLE || slot.state == MALI_GP_SLOT_STATE_DISABLED);
-       mali_gp_scheduler_unlock();
-
-       return ret;
-}
-
-
-#if MALI_STATE_TRACKING
-u32 mali_gp_scheduler_dump_state(char *buf, u32 size)
-{
-       int n = 0;
-
-       n += _mali_osk_snprintf(buf + n, size - n, "GP\n");
-       n += _mali_osk_snprintf(buf + n, size - n, "\tQueue is %s\n", _mali_osk_list_empty(&job_queue) ? "empty" : "not empty");
-       n += _mali_osk_snprintf(buf + n, size - n, "\tHigh priority queue is %s\n", _mali_osk_list_empty(&job_queue_high) ? "empty" : "not empty");
-
-       n += mali_group_dump_state(slot.group, buf + n, size - n);
-       n += _mali_osk_snprintf(buf + n, size - n, "\n");
-
-       return n;
-}
-#endif
-
-void mali_gp_scheduler_reset_all_groups(void)
-{
-       if (NULL != slot.group) {
-               mali_group_lock(slot.group);
-               mali_group_reset(slot.group);
-               mali_group_unlock(slot.group);
-       }
-}
-
-void mali_gp_scheduler_zap_all_active(struct mali_session_data *session)
-{
-       if (NULL != slot.group) {
-               mali_group_zap_session(slot.group, session);
-       }
-}
-
-void mali_gp_scheduler_enable_group(struct mali_group *group)
-{
-       MALI_DEBUG_ASSERT_POINTER(group);
-       MALI_DEBUG_ASSERT(slot.group == group);
-       MALI_DEBUG_PRINT(2, ("Mali GP scheduler: enabling gp group %p\n", group));
-
-       mali_group_lock(group);
-
-       if (MALI_GROUP_STATE_DISABLED != group->state) {
-               mali_group_unlock(group);
-               MALI_DEBUG_PRINT(2, ("Mali GP scheduler: gp group %p already enabled\n", group));
-               return;
-       }
-
-       mali_gp_scheduler_lock();
-
-       MALI_DEBUG_ASSERT(MALI_GROUP_STATE_DISABLED == group->state);
-       MALI_DEBUG_ASSERT(MALI_GP_SLOT_STATE_DISABLED == slot.state);
-       slot.state = MALI_GP_SLOT_STATE_IDLE;
-       group->state = MALI_GROUP_STATE_IDLE;
-
-       mali_group_power_on_group(group);
-       mali_group_reset(group);
-
-       /* Pick up any jobs that might have been queued while the GP group was disabled. */
-       mali_gp_scheduler_schedule_internal_and_unlock();
-}
-
-void mali_gp_scheduler_disable_group(struct mali_group *group)
-{
-       MALI_DEBUG_ASSERT_POINTER(group);
-       MALI_DEBUG_ASSERT(slot.group == group);
-       MALI_DEBUG_PRINT(2, ("Mali GP scheduler: disabling gp group %p\n", group));
-
-       mali_gp_scheduler_suspend();
-       mali_group_lock(group);
-       mali_gp_scheduler_lock();
-
-       MALI_DEBUG_ASSERT(MALI_GROUP_STATE_IDLE     == group->state
-                         || MALI_GROUP_STATE_DISABLED == group->state);
-
-       if (MALI_GROUP_STATE_DISABLED == group->state) {
-               MALI_DEBUG_ASSERT(MALI_GP_SLOT_STATE_DISABLED == slot.state);
-               MALI_DEBUG_PRINT(2, ("Mali GP scheduler: gp group %p already disabled\n", group));
-       } else {
-               MALI_DEBUG_ASSERT(MALI_GP_SLOT_STATE_IDLE == slot.state);
-               slot.state = MALI_GP_SLOT_STATE_DISABLED;
-               group->state = MALI_GROUP_STATE_DISABLED;
-
-               mali_group_power_off_group(group, MALI_TRUE);
-       }
-
-       mali_gp_scheduler_unlock();
-       mali_group_unlock(group);
-       mali_gp_scheduler_resume();
-}
-
-static mali_scheduler_mask mali_gp_scheduler_queue_job(struct mali_gp_job *job)
-{
-       _mali_osk_list_t *queue = NULL;
-       mali_scheduler_mask schedule_mask = MALI_SCHEDULER_MASK_EMPTY;
-       struct mali_gp_job *iter, *tmp;
-
-       MALI_DEBUG_ASSERT_POINTER(job);
-       MALI_DEBUG_ASSERT_POINTER(job->session);
-
-       MALI_DEBUG_ASSERT_LOCK_HELD(gp_scheduler_lock);
-
-       _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE | MALI_PROFILING_EVENT_CHANNEL_SOFTWARE | MALI_PROFILING_EVENT_REASON_SINGLE_SW_GP_ENQUEUE, job->pid, job->tid, job->uargs.frame_builder_id, job->uargs.flush_id, 0);
-
-       job->cache_order = mali_scheduler_get_new_cache_order();
-
-       /* Determine which queue the job should be added to. */
-       if (job->session->use_high_priority_job_queue) {
-               queue = &job_queue_high;
-       } else {
-               queue = &job_queue;
-       }
-
-       /* Find position in queue where job should be added. */
-       _MALI_OSK_LIST_FOREACHENTRY_REVERSE(iter, tmp, queue, struct mali_gp_job, list) {
-               if (mali_gp_job_is_after(job, iter)) {
-                       break;
-               }
-       }
-
-       /* Add job to queue. */
-       _mali_osk_list_add(&job->list, &iter->list);
-
-       /* Set schedule bitmask if the GP core is idle. */
-       if (MALI_GP_SLOT_STATE_IDLE == slot.state) {
-               schedule_mask |= MALI_SCHEDULER_MASK_GP;
-       }
-
-       mali_gp_scheduler_job_queued();
-
-#if defined(CONFIG_GPU_TRACEPOINTS) && defined(CONFIG_TRACEPOINTS)
-       trace_gpu_job_enqueue(mali_gp_job_get_tid(job), mali_gp_job_get_id(job), "GP");
-#endif
-
-       MALI_DEBUG_PRINT(3, ("Mali GP scheduler: Job %u (0x%08X) queued\n", mali_gp_job_get_id(job), job));
-
-       return schedule_mask;
-}
-
-mali_scheduler_mask mali_gp_scheduler_activate_job(struct mali_gp_job *job)
-{
-       mali_scheduler_mask schedule_mask = MALI_SCHEDULER_MASK_EMPTY;
-
-       MALI_DEBUG_ASSERT_POINTER(job);
-       MALI_DEBUG_ASSERT_POINTER(job->session);
-
-       MALI_DEBUG_PRINT(4, ("Mali GP scheduler: Timeline activation for job %u (0x%08X).\n", mali_gp_job_get_id(job), job));
-
-       mali_gp_scheduler_lock();
-
-       if (unlikely(job->session->is_aborting)) {
-               /* Before checking if the session is aborting, the scheduler must be locked. */
-               MALI_DEBUG_ASSERT_LOCK_HELD(gp_scheduler_lock);
-
-               MALI_DEBUG_PRINT(3, ("Mali GP scheduler: Job %u (0x%08X) activated while session is aborting.\n", mali_gp_job_get_id(job), job));
-
-               /* This job should not be on any list. */
-               MALI_DEBUG_ASSERT(_mali_osk_list_empty(&job->list));
-
-               mali_gp_scheduler_unlock();
-
-               /* Release tracker and delete job. */
-               mali_timeline_tracker_release(&job->tracker);
-               mali_gp_job_signal_pp_tracker(job, MALI_FALSE);
-               mali_gp_job_delete(job);
-
-               /* Release the PM ref taken in mali_gp_scheduler_submit_job */
-               _mali_osk_pm_dev_ref_dec();
-
-               /* Since we are aborting we ignore the scheduler mask. */
-               return MALI_SCHEDULER_MASK_EMPTY;
-       }
-
-       /* GP job is ready to run, queue it. */
-       schedule_mask = mali_gp_scheduler_queue_job(job);
-
-       mali_gp_scheduler_unlock();
-
-       return schedule_mask;
-}
-
-static void mali_gp_scheduler_job_queued(void)
-{
-       if (mali_utilization_enabled()) {
-               /*
-                * We cheat a little bit by counting the PP as busy from the time a GP job is queued.
-                * This will be fine because we only loose the tiny idle gap between jobs, but
-                * we will instead get less utilization work to do (less locks taken)
-                */
-               mali_utilization_gp_start();
-       }
-}
-
-static void mali_gp_scheduler_job_completed(void)
-{
-       /* Release the PM reference we got in the mali_gp_scheduler_job_queued() function */
-       _mali_osk_pm_dev_ref_dec();
-
-       if (mali_utilization_enabled()) {
-               mali_utilization_gp_end();
-       }
-}
diff --git a/mali/common/mali_gp_scheduler.h b/mali/common/mali_gp_scheduler.h
deleted file mode 100755 (executable)
index 84a096c..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (C) 2012-2014 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.
- * 
- * A copy of the licence is included with the program, and can also be obtained from Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-#ifndef __MALI_GP_SCHEDULER_H__
-#define __MALI_GP_SCHEDULER_H__
-
-#include "mali_osk.h"
-#include "mali_gp_job.h"
-#include "mali_group.h"
-
-_mali_osk_errcode_t mali_gp_scheduler_initialize(void);
-void mali_gp_scheduler_terminate(void);
-
-void mali_gp_scheduler_job_done(struct mali_group *group, struct mali_gp_job *job, mali_bool success);
-void mali_gp_scheduler_oom(struct mali_group *group, struct mali_gp_job *job);
-u32 mali_gp_scheduler_dump_state(char *buf, u32 size);
-
-void mali_gp_scheduler_suspend(void);
-void mali_gp_scheduler_resume(void);
-
-/**
- * @brief Abort all running and queued GP jobs from session.
- *
-* This functions aborts all GP jobs from the specified session. Queued jobs are removed from the
-* queue and jobs currently running on a core will be aborted.
- *
- * @param session Session that is aborting.
- */
-void mali_gp_scheduler_abort_session(struct mali_session_data *session);
-
-/**
- * @brief Reset all groups
- *
- * This function resets all groups known by the GP scheuduler. This must be
- * called after the Mali HW has been powered on in order to reset the HW.
- */
-void mali_gp_scheduler_reset_all_groups(void);
-
-/**
- * @brief Zap TLB on all groups with \a session active
- *
- * The scheculer will zap the session on all groups it owns.
- */
-void mali_gp_scheduler_zap_all_active(struct mali_session_data *session);
-
-/**
- * @brief Re-enable a group that has been disabled with mali_gp_scheduler_disable_group
- *
- * If a Mali PMU is present, the group will be powered back on and added back
- * into the GP scheduler.
- *
- * @param group Pointer to the group to enable
- */
-void mali_gp_scheduler_enable_group(struct mali_group *group);
-
-/**
- * @brief Disable a group
- *
- * The group will be taken out of the GP scheduler and powered off, if a Mali
- * PMU is present.
- *
- * @param group Pointer to the group to disable
- */
-void mali_gp_scheduler_disable_group(struct mali_group *group);
-
-/**
- * @brief Used by the Timeline system to queue a GP job.
- *
- * @note @ref mali_scheduler_schedule_from_mask() should be called if this function returns non-zero.
- *
- * @param job The GP job that is being activated.
- *
- * @return A scheduling bitmask that can be used to decide if scheduling is necessary after this
- * call.
- */
-mali_scheduler_mask mali_gp_scheduler_activate_job(struct mali_gp_job *job);
-
-/**
- * @brief Schedule queued jobs on idle cores.
- */
-void mali_gp_scheduler_schedule(void);
-
-/**
- * @brief Submit a GP job to the GP scheduler.
- *
- * This will add the GP job to the Timeline system.
- *
- * @param session Session this job belongs to.
- * @param job GP job that will be submitted
- * @return Point on GP timeline for job.
- */
-mali_timeline_point mali_gp_scheduler_submit_job(struct mali_session_data *session, struct mali_gp_job *job);
-
-#endif /* __MALI_GP_SCHEDULER_H__ */
index a127a3dad906fcd61b2ae34e410fd99a9d09e186..810a3060853940b24d0715688360270001b79496 100755 (executable)
@@ -56,598 +56,598 @@ static void mali_group_activate_page_directory(struct mali_group *group, struct
 static void mali_group_recovery_reset(struct mali_group *group);
 
 struct mali_group *mali_group_create(struct mali_l2_cache_core *core,
-                                    struct mali_dlbu_core *dlbu,
-                                    struct mali_bcast_unit *bcast,
-                                    u32 domain_index)
+        struct mali_dlbu_core *dlbu,
+        struct mali_bcast_unit *bcast,
+        u32 domain_index)
 {
-       struct mali_group *group = NULL;
-
-       if (mali_global_num_groups >= MALI_MAX_NUMBER_OF_GROUPS) {
-               MALI_PRINT_ERROR(("Mali group: Too many group objects created\n"));
-               return NULL;
-       }
-
-       group = _mali_osk_calloc(1, sizeof(struct mali_group));
-       if (NULL != group) {
-               group->timeout_timer = _mali_osk_timer_init();
-               if (NULL != group->timeout_timer) {
-                       _mali_osk_timer_setcallback(group->timeout_timer, mali_group_timeout, (void *)group);
-
-                       group->l2_cache_core[0] = core;
-                       _mali_osk_list_init(&group->group_list);
-                       _mali_osk_list_init(&group->executor_list);
-                       _mali_osk_list_init(&group->pm_domain_list);
-                       group->bcast_core = bcast;
-                       group->dlbu_core = dlbu;
-
-                       /* register this object as a part of the correct power domain */
-                       if ((NULL != core) || (NULL != dlbu) || (NULL != bcast))
-                               group->pm_domain = mali_pm_register_group(domain_index, group);
-
-                       mali_global_groups[mali_global_num_groups] = group;
-                       mali_global_num_groups++;
-
-                       return group;
-               }
-               _mali_osk_free(group);
-       }
-
-       return NULL;
+    struct mali_group *group = NULL;
+
+    if (mali_global_num_groups >= MALI_MAX_NUMBER_OF_GROUPS) {
+        MALI_PRINT_ERROR(("Mali group: Too many group objects created\n"));
+        return NULL;
+    }
+
+    group = _mali_osk_calloc(1, sizeof(struct mali_group));
+    if (NULL != group) {
+        group->timeout_timer = _mali_osk_timer_init();
+        if (NULL != group->timeout_timer) {
+            _mali_osk_timer_setcallback(group->timeout_timer, mali_group_timeout, (void *)group);
+
+            group->l2_cache_core[0] = core;
+            _mali_osk_list_init(&group->group_list);
+            _mali_osk_list_init(&group->executor_list);
+            _mali_osk_list_init(&group->pm_domain_list);
+            group->bcast_core = bcast;
+            group->dlbu_core = dlbu;
+
+            /* register this object as a part of the correct power domain */
+            if ((NULL != core) || (NULL != dlbu) || (NULL != bcast))
+                group->pm_domain = mali_pm_register_group(domain_index, group);
+
+            mali_global_groups[mali_global_num_groups] = group;
+            mali_global_num_groups++;
+
+            return group;
+        }
+        _mali_osk_free(group);
+    }
+
+    return NULL;
 }
 
 void mali_group_delete(struct mali_group *group)
 {
-       u32 i;
-
-       MALI_DEBUG_PRINT(4, ("Deleting group %s\n",
-                            mali_group_core_description(group)));
-
-       MALI_DEBUG_ASSERT(NULL == group->parent_group);
-       MALI_DEBUG_ASSERT((MALI_GROUP_STATE_INACTIVE == group->state) || ((MALI_GROUP_STATE_ACTIVATION_PENDING == group->state)));
-
-       /* Delete the resources that this group owns */
-       if (NULL != group->gp_core) {
-               mali_gp_delete(group->gp_core);
-       }
-
-       if (NULL != group->pp_core) {
-               mali_pp_delete(group->pp_core);
-       }
-
-       if (NULL != group->mmu) {
-               mali_mmu_delete(group->mmu);
-       }
-
-       if (mali_group_is_virtual(group)) {
-               /* Remove all groups from virtual group */
-               struct mali_group *child;
-               struct mali_group *temp;
-
-               _MALI_OSK_LIST_FOREACHENTRY(child, temp, &group->group_list, struct mali_group, group_list) {
-                       child->parent_group = NULL;
-                       mali_group_delete(child);
-               }
-
-               mali_dlbu_delete(group->dlbu_core);
-
-               if (NULL != group->bcast_core) {
-                       mali_bcast_unit_delete(group->bcast_core);
-               }
-       }
-
-       for (i = 0; i < mali_global_num_groups; i++) {
-               if (mali_global_groups[i] == group) {
-                       mali_global_groups[i] = NULL;
-                       mali_global_num_groups--;
-
-                       if (i != mali_global_num_groups) {
-                               /* We removed a group from the middle of the array -- move the last
-                                * group to the current position to close the gap */
-                               mali_global_groups[i] = mali_global_groups[mali_global_num_groups];
-                               mali_global_groups[mali_global_num_groups] = NULL;
-                       }
-
-                       break;
-               }
-       }
-
-       if (NULL != group->timeout_timer) {
-               _mali_osk_timer_del(group->timeout_timer);
-               _mali_osk_timer_term(group->timeout_timer);
-       }
-
-       if (NULL != group->bottom_half_work_mmu) {
-               _mali_osk_wq_delete_work(group->bottom_half_work_mmu);
-       }
-
-       if (NULL != group->bottom_half_work_gp) {
-               _mali_osk_wq_delete_work(group->bottom_half_work_gp);
-       }
-
-       if (NULL != group->bottom_half_work_pp) {
-               _mali_osk_wq_delete_work(group->bottom_half_work_pp);
-       }
-
-       _mali_osk_free(group);
+    u32 i;
+
+    MALI_DEBUG_PRINT(4, ("Deleting group %s\n",
+                mali_group_core_description(group)));
+
+    MALI_DEBUG_ASSERT(NULL == group->parent_group);
+    MALI_DEBUG_ASSERT((MALI_GROUP_STATE_INACTIVE == group->state) || ((MALI_GROUP_STATE_ACTIVATION_PENDING == group->state)));
+
+    /* Delete the resources that this group owns */
+    if (NULL != group->gp_core) {
+        mali_gp_delete(group->gp_core);
+    }
+
+    if (NULL != group->pp_core) {
+        mali_pp_delete(group->pp_core);
+    }
+
+    if (NULL != group->mmu) {
+        mali_mmu_delete(group->mmu);
+    }
+
+    if (mali_group_is_virtual(group)) {
+        /* Remove all groups from virtual group */
+        struct mali_group *child;
+        struct mali_group *temp;
+
+        _MALI_OSK_LIST_FOREACHENTRY(child, temp, &group->group_list, struct mali_group, group_list) {
+            child->parent_group = NULL;
+            mali_group_delete(child);
+        }
+
+        mali_dlbu_delete(group->dlbu_core);
+
+        if (NULL != group->bcast_core) {
+            mali_bcast_unit_delete(group->bcast_core);
+        }
+    }
+
+    for (i = 0; i < mali_global_num_groups; i++) {
+        if (mali_global_groups[i] == group) {
+            mali_global_groups[i] = NULL;
+            mali_global_num_groups--;
+
+            if (i != mali_global_num_groups) {
+                /* We removed a group from the middle of the array -- move the last
+                 * group to the current position to close the gap */
+                mali_global_groups[i] = mali_global_groups[mali_global_num_groups];
+                mali_global_groups[mali_global_num_groups] = NULL;
+            }
+
+            break;
+        }
+    }
+
+    if (NULL != group->timeout_timer) {
+        _mali_osk_timer_del(group->timeout_timer);
+        _mali_osk_timer_term(group->timeout_timer);
+    }
+
+    if (NULL != group->bottom_half_work_mmu) {
+        _mali_osk_wq_delete_work(group->bottom_half_work_mmu);
+    }
+
+    if (NULL != group->bottom_half_work_gp) {
+        _mali_osk_wq_delete_work(group->bottom_half_work_gp);
+    }
+
+    if (NULL != group->bottom_half_work_pp) {
+        _mali_osk_wq_delete_work(group->bottom_half_work_pp);
+    }
+
+    _mali_osk_free(group);
 }
 
 _mali_osk_errcode_t mali_group_add_mmu_core(struct mali_group *group, struct mali_mmu_core *mmu_core)
 {
-       /* This group object now owns the MMU core object */
-       group->mmu = mmu_core;
-       group->bottom_half_work_mmu = _mali_osk_wq_create_work(mali_group_bottom_half_mmu, group);
-       if (NULL == group->bottom_half_work_mmu) {
-               return _MALI_OSK_ERR_FAULT;
-       }
-       return _MALI_OSK_ERR_OK;
+    /* This group object now owns the MMU core object */
+    group->mmu = mmu_core;
+    group->bottom_half_work_mmu = _mali_osk_wq_create_work(mali_group_bottom_half_mmu, group);
+    if (NULL == group->bottom_half_work_mmu) {
+        return _MALI_OSK_ERR_FAULT;
+    }
+    return _MALI_OSK_ERR_OK;
 }
 
 void mali_group_remove_mmu_core(struct mali_group *group)
 {
-       /* This group object no longer owns the MMU core object */
-       group->mmu = NULL;
-       if (NULL != group->bottom_half_work_mmu) {
-               _mali_osk_wq_delete_work(group->bottom_half_work_mmu);
-       }
+    /* This group object no longer owns the MMU core object */
+    group->mmu = NULL;
+    if (NULL != group->bottom_half_work_mmu) {
+        _mali_osk_wq_delete_work(group->bottom_half_work_mmu);
+    }
 }
 
 _mali_osk_errcode_t mali_group_add_gp_core(struct mali_group *group, struct mali_gp_core *gp_core)
 {
-       /* This group object now owns the GP core object */
-       group->gp_core = gp_core;
-       group->bottom_half_work_gp = _mali_osk_wq_create_work(mali_group_bottom_half_gp, group);
-       if (NULL == group->bottom_half_work_gp) {
-               return _MALI_OSK_ERR_FAULT;
-       }
-       return _MALI_OSK_ERR_OK;
+    /* This group object now owns the GP core object */
+    group->gp_core = gp_core;
+    group->bottom_half_work_gp = _mali_osk_wq_create_work(mali_group_bottom_half_gp, group);
+    if (NULL == group->bottom_half_work_gp) {
+        return _MALI_OSK_ERR_FAULT;
+    }
+    return _MALI_OSK_ERR_OK;
 }
 
 void mali_group_remove_gp_core(struct mali_group *group)
 {
-       /* This group object no longer owns the GP core object */
-       group->gp_core = NULL;
-       if (NULL != group->bottom_half_work_gp) {
-               _mali_osk_wq_delete_work(group->bottom_half_work_gp);
-       }
+    /* This group object no longer owns the GP core object */
+    group->gp_core = NULL;
+    if (NULL != group->bottom_half_work_gp) {
+        _mali_osk_wq_delete_work(group->bottom_half_work_gp);
+    }
 }
 
 _mali_osk_errcode_t mali_group_add_pp_core(struct mali_group *group, struct mali_pp_core *pp_core)
 {
-       /* This group object now owns the PP core object */
-       group->pp_core = pp_core;
-       group->bottom_half_work_pp = _mali_osk_wq_create_work(mali_group_bottom_half_pp, group);
-       if (NULL == group->bottom_half_work_pp) {
-               return _MALI_OSK_ERR_FAULT;
-       }
-       return _MALI_OSK_ERR_OK;
+    /* This group object now owns the PP core object */
+    group->pp_core = pp_core;
+    group->bottom_half_work_pp = _mali_osk_wq_create_work(mali_group_bottom_half_pp, group);
+    if (NULL == group->bottom_half_work_pp) {
+        return _MALI_OSK_ERR_FAULT;
+    }
+    return _MALI_OSK_ERR_OK;
 }
 
 void mali_group_remove_pp_core(struct mali_group *group)
 {
-       /* This group object no longer owns the PP core object */
-       group->pp_core = NULL;
-       if (NULL != group->bottom_half_work_pp) {
-               _mali_osk_wq_delete_work(group->bottom_half_work_pp);
-       }
+    /* This group object no longer owns the PP core object */
+    group->pp_core = NULL;
+    if (NULL != group->bottom_half_work_pp) {
+        _mali_osk_wq_delete_work(group->bottom_half_work_pp);
+    }
 }
 
 enum mali_group_state mali_group_activate(struct mali_group *group)
 {
-       MALI_DEBUG_ASSERT_POINTER(group);
-       MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
-
-       MALI_DEBUG_PRINT(4, ("Group: Activating group %s\n",
-                            mali_group_core_description(group)));
-
-       if (MALI_GROUP_STATE_INACTIVE == group->state) {
-               /* Group is inactive, get PM refs in order to power up */
-
-               /*
-                * We'll take a maximum of 2 power domain references pr group,
-                * one for the group itself, and one for it's L2 cache.
-                */
-               struct mali_pm_domain *domains[MALI_MAX_NUM_DOMAIN_REFS];
-               struct mali_group *groups[MALI_MAX_NUM_DOMAIN_REFS];
-               u32 num_domains = 0;
-               mali_bool all_groups_on;
-
-               /* Deal with child groups first */
-               if (mali_group_is_virtual(group)) {
-                       /*
-                        * The virtual group might have 0, 1 or 2 L2s in
-                        * its l2_cache_core array, but we ignore these and
-                        * let the child groups take the needed L2 cache ref
-                        * on behalf of the virtual group.
-                        * In other words; The L2 refs are taken in pair with
-                        * the physical group which the L2 is attached to.
-                        */
-                       struct mali_group *child;
-                       struct mali_group *temp;
-
-                       /*
-                        * Child group is inactive, get PM
-                        * refs in order to power up.
-                        */
-                       _MALI_OSK_LIST_FOREACHENTRY(child, temp,
-                                                   &group->group_list,
-                                                   struct mali_group, group_list) {
-                               MALI_DEBUG_ASSERT(MALI_GROUP_STATE_INACTIVE
-                                                 == child->state);
-
-                               child->state = MALI_GROUP_STATE_ACTIVATION_PENDING;
-
-                               MALI_DEBUG_ASSERT_POINTER(
-                                       child->pm_domain);
-                               domains[num_domains] = child->pm_domain;
-                               groups[num_domains] = child;
-                               num_domains++;
-
-                               /*
-                                * Take L2 domain ref for child group.
-                                */
-                               MALI_DEBUG_ASSERT(MALI_MAX_NUM_DOMAIN_REFS
-                                                 > num_domains);
-                               domains[num_domains] = mali_l2_cache_get_pm_domain(
-                                                              child->l2_cache_core[0]);
-                               groups[num_domains] = NULL;
-                               MALI_DEBUG_ASSERT(NULL ==
-                                                 child->l2_cache_core[1]);
-                               num_domains++;
-                       }
-               } else {
-                       /* Take L2 domain ref for physical groups. */
-                       MALI_DEBUG_ASSERT(MALI_MAX_NUM_DOMAIN_REFS >
-                                         num_domains);
-
-                       domains[num_domains] = mali_l2_cache_get_pm_domain(
-                                                      group->l2_cache_core[0]);
-                       groups[num_domains] = NULL;
-                       MALI_DEBUG_ASSERT(NULL == group->l2_cache_core[1]);
-                       num_domains++;
-               }
-
-               /* Do the group itself last (it's dependencies first) */
-
-               group->state = MALI_GROUP_STATE_ACTIVATION_PENDING;
-
-               MALI_DEBUG_ASSERT_POINTER(group->pm_domain);
-               domains[num_domains] = group->pm_domain;
-               groups[num_domains] = group;
-               num_domains++;
-
-               all_groups_on = mali_pm_get_domain_refs(domains, groups,
-                                                       num_domains);
-
-               /*
-                * Complete activation for group, include
-                * virtual group or physical group.
-                */
-               if (MALI_TRUE == all_groups_on) {
-
-                       mali_group_set_active(group);
-               }
-       } else if (MALI_GROUP_STATE_ACTIVE == group->state) {
-               /* Already active */
-               MALI_DEBUG_ASSERT(MALI_TRUE == group->power_is_on);
-       } else {
-               /*
-                * Activation already pending, group->power_is_on could
-                * be both true or false. We need to wait for power up
-                * notification anyway.
-                */
-               MALI_DEBUG_ASSERT(MALI_GROUP_STATE_ACTIVATION_PENDING
-                                 == group->state);
-       }
-
-       MALI_DEBUG_PRINT(4, ("Group: group %s activation result: %s\n",
-                            mali_group_core_description(group),
-                            MALI_GROUP_STATE_ACTIVE == group->state ?
-                            "ACTIVE" : "PENDING"));
-
-       return group->state;
+    MALI_DEBUG_ASSERT_POINTER(group);
+    MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
+
+    MALI_DEBUG_PRINT(4, ("Group: Activating group %s\n",
+                mali_group_core_description(group)));
+
+    if (MALI_GROUP_STATE_INACTIVE == group->state) {
+        /* Group is inactive, get PM refs in order to power up */
+
+        /*
+         * We'll take a maximum of 2 power domain references pr group,
+         * one for the group itself, and one for it's L2 cache.
+         */
+        struct mali_pm_domain *domains[MALI_MAX_NUM_DOMAIN_REFS];
+        struct mali_group *groups[MALI_MAX_NUM_DOMAIN_REFS];
+        u32 num_domains = 0;
+        mali_bool all_groups_on;
+
+        /* Deal with child groups first */
+        if (mali_group_is_virtual(group)) {
+            /*
+             * The virtual group might have 0, 1 or 2 L2s in
+             * its l2_cache_core array, but we ignore these and
+             * let the child groups take the needed L2 cache ref
+             * on behalf of the virtual group.
+             * In other words; The L2 refs are taken in pair with
+             * the physical group which the L2 is attached to.
+             */
+            struct mali_group *child;
+            struct mali_group *temp;
+
+            /*
+             * Child group is inactive, get PM
+             * refs in order to power up.
+             */
+            _MALI_OSK_LIST_FOREACHENTRY(child, temp,
+                    &group->group_list,
+                    struct mali_group, group_list) {
+                MALI_DEBUG_ASSERT(MALI_GROUP_STATE_INACTIVE
+                        == child->state);
+
+                child->state = MALI_GROUP_STATE_ACTIVATION_PENDING;
+
+                MALI_DEBUG_ASSERT_POINTER(
+                        child->pm_domain);
+                domains[num_domains] = child->pm_domain;
+                groups[num_domains] = child;
+                num_domains++;
+
+                /*
+                 * Take L2 domain ref for child group.
+                 */
+                MALI_DEBUG_ASSERT(MALI_MAX_NUM_DOMAIN_REFS
+                        > num_domains);
+                domains[num_domains] = mali_l2_cache_get_pm_domain(
+                        child->l2_cache_core[0]);
+                groups[num_domains] = NULL;
+                MALI_DEBUG_ASSERT(NULL ==
+                        child->l2_cache_core[1]);
+                num_domains++;
+            }
+        } else {
+            /* Take L2 domain ref for physical groups. */
+            MALI_DEBUG_ASSERT(MALI_MAX_NUM_DOMAIN_REFS >
+                    num_domains);
+
+            domains[num_domains] = mali_l2_cache_get_pm_domain(
+                    group->l2_cache_core[0]);
+            groups[num_domains] = NULL;
+            MALI_DEBUG_ASSERT(NULL == group->l2_cache_core[1]);
+            num_domains++;
+        }
+
+        /* Do the group itself last (it's dependencies first) */
+
+        group->state = MALI_GROUP_STATE_ACTIVATION_PENDING;
+
+        MALI_DEBUG_ASSERT_POINTER(group->pm_domain);
+        domains[num_domains] = group->pm_domain;
+        groups[num_domains] = group;
+        num_domains++;
+
+        all_groups_on = mali_pm_get_domain_refs(domains, groups,
+                num_domains);
+
+        /*
+         * Complete activation for group, include
+         * virtual group or physical group.
+         */
+        if (MALI_TRUE == all_groups_on) {
+
+            mali_group_set_active(group);
+        }
+    } else if (MALI_GROUP_STATE_ACTIVE == group->state) {
+        /* Already active */
+        MALI_DEBUG_ASSERT(MALI_TRUE == group->power_is_on);
+    } else {
+        /*
+         * Activation already pending, group->power_is_on could
+         * be both true or false. We need to wait for power up
+         * notification anyway.
+         */
+        MALI_DEBUG_ASSERT(MALI_GROUP_STATE_ACTIVATION_PENDING
+                == group->state);
+    }
+
+    MALI_DEBUG_PRINT(4, ("Group: group %s activation result: %s\n",
+                mali_group_core_description(group),
+                MALI_GROUP_STATE_ACTIVE == group->state ?
+                "ACTIVE" : "PENDING"));
+
+    return group->state;
 }
 
 mali_bool mali_group_set_active(struct mali_group *group)
 {
-       MALI_DEBUG_ASSERT_POINTER(group);
-       MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
-       MALI_DEBUG_ASSERT(MALI_GROUP_STATE_ACTIVATION_PENDING == group->state);
-       MALI_DEBUG_ASSERT(MALI_TRUE == group->power_is_on);
+    MALI_DEBUG_ASSERT_POINTER(group);
+    MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
+    MALI_DEBUG_ASSERT(MALI_GROUP_STATE_ACTIVATION_PENDING == group->state);
+    MALI_DEBUG_ASSERT(MALI_TRUE == group->power_is_on);
 
-       MALI_DEBUG_PRINT(4, ("Group: Activation completed for %s\n",
-                            mali_group_core_description(group)));
+    MALI_DEBUG_PRINT(4, ("Group: Activation completed for %s\n",
+                mali_group_core_description(group)));
 
-       if (mali_group_is_virtual(group)) {
-               struct mali_group *child;
-               struct mali_group *temp;
+    if (mali_group_is_virtual(group)) {
+        struct mali_group *child;
+        struct mali_group *temp;
 
-               _MALI_OSK_LIST_FOREACHENTRY(child, temp, &group->group_list,
-                                           struct mali_group, group_list) {
-                       if (MALI_TRUE != child->power_is_on) {
-                               return MALI_FALSE;
-                       }
+        _MALI_OSK_LIST_FOREACHENTRY(child, temp, &group->group_list,
+                struct mali_group, group_list) {
+            if (MALI_TRUE != child->power_is_on) {
+                return MALI_FALSE;
+            }
 
-                       child->state = MALI_GROUP_STATE_ACTIVE;
-               }
+            child->state = MALI_GROUP_STATE_ACTIVE;
+        }
 
-               mali_group_reset(group);
-       }
+        mali_group_reset(group);
+    }
 
-       /* Go to ACTIVE state */
-       group->state = MALI_GROUP_STATE_ACTIVE;
+    /* Go to ACTIVE state */
+    group->state = MALI_GROUP_STATE_ACTIVE;
 
-       return MALI_TRUE;
+    return MALI_TRUE;
 }
 
 mali_bool mali_group_deactivate(struct mali_group *group)
 {
-       struct mali_pm_domain *domains[MALI_MAX_NUM_DOMAIN_REFS];
-       u32 num_domains = 0;
-       mali_bool power_down = MALI_FALSE;
-
-       MALI_DEBUG_ASSERT_POINTER(group);
-       MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
-       MALI_DEBUG_ASSERT(MALI_GROUP_STATE_INACTIVE != group->state);
-
-       MALI_DEBUG_PRINT(3, ("Group: Deactivating group %s\n",
-                            mali_group_core_description(group)));
-
-       group->state = MALI_GROUP_STATE_INACTIVE;
-
-       MALI_DEBUG_ASSERT_POINTER(group->pm_domain);
-       domains[num_domains] = group->pm_domain;
-       num_domains++;
-
-       if (mali_group_is_virtual(group)) {
-               /* Release refs for all child groups */
-               struct mali_group *child;
-               struct mali_group *temp;
-
-               _MALI_OSK_LIST_FOREACHENTRY(child, temp,
-                                           &group->group_list,
-                                           struct mali_group, group_list) {
-                       child->state = MALI_GROUP_STATE_INACTIVE;
-
-                       MALI_DEBUG_ASSERT_POINTER(child->pm_domain);
-                       domains[num_domains] = child->pm_domain;
-                       num_domains++;
-
-                       /* Release L2 cache domain for child groups */
-                       MALI_DEBUG_ASSERT(MALI_MAX_NUM_DOMAIN_REFS >
-                                         num_domains);
-                       domains[num_domains] = mali_l2_cache_get_pm_domain(
-                                                      child->l2_cache_core[0]);
-                       MALI_DEBUG_ASSERT(NULL == child->l2_cache_core[1]);
-                       num_domains++;
-               }
-
-               /*
-                * Must do mali_group_power_down() steps right here for
-                * virtual group, because virtual group itself is likely to
-                * stay powered on, however child groups are now very likely
-                * to be powered off (and thus lose their state).
-                */
-
-               mali_group_clear_session(group);
-               /*
-                * Disable the broadcast unit (clear it's mask).
-                * This is needed in case the GPU isn't actually
-                * powered down at this point and groups are
-                * removed from an inactive virtual group.
-                * If not, then the broadcast unit will intercept
-                * their interrupts!
-                */
-               mali_bcast_disable(group->bcast_core);
-       } else {
-               /* Release L2 cache domain for physical groups */
-               MALI_DEBUG_ASSERT(MALI_MAX_NUM_DOMAIN_REFS >
-                                 num_domains);
-               domains[num_domains] = mali_l2_cache_get_pm_domain(
-                                              group->l2_cache_core[0]);
-               MALI_DEBUG_ASSERT(NULL == group->l2_cache_core[1]);
-               num_domains++;
-       }
-
-       power_down = mali_pm_put_domain_refs(domains, num_domains);
-
-       return power_down;
+    struct mali_pm_domain *domains[MALI_MAX_NUM_DOMAIN_REFS];
+    u32 num_domains = 0;
+    mali_bool power_down = MALI_FALSE;
+
+    MALI_DEBUG_ASSERT_POINTER(group);
+    MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
+    MALI_DEBUG_ASSERT(MALI_GROUP_STATE_INACTIVE != group->state);
+
+    MALI_DEBUG_PRINT(3, ("Group: Deactivating group %s\n",
+                mali_group_core_description(group)));
+
+    group->state = MALI_GROUP_STATE_INACTIVE;
+
+    MALI_DEBUG_ASSERT_POINTER(group->pm_domain);
+    domains[num_domains] = group->pm_domain;
+    num_domains++;
+
+    if (mali_group_is_virtual(group)) {
+        /* Release refs for all child groups */
+        struct mali_group *child;
+        struct mali_group *temp;
+
+        _MALI_OSK_LIST_FOREACHENTRY(child, temp,
+                &group->group_list,
+                struct mali_group, group_list) {
+            child->state = MALI_GROUP_STATE_INACTIVE;
+
+            MALI_DEBUG_ASSERT_POINTER(child->pm_domain);
+            domains[num_domains] = child->pm_domain;
+            num_domains++;
+
+            /* Release L2 cache domain for child groups */
+            MALI_DEBUG_ASSERT(MALI_MAX_NUM_DOMAIN_REFS >
+                    num_domains);
+            domains[num_domains] = mali_l2_cache_get_pm_domain(
+                    child->l2_cache_core[0]);
+            MALI_DEBUG_ASSERT(NULL == child->l2_cache_core[1]);
+            num_domains++;
+        }
+
+        /*
+         * Must do mali_group_power_down() steps right here for
+         * virtual group, because virtual group itself is likely to
+         * stay powered on, however child groups are now very likely
+         * to be powered off (and thus lose their state).
+         */
+
+        mali_group_clear_session(group);
+        /*
+         * Disable the broadcast unit (clear it's mask).
+         * This is needed in case the GPU isn't actually
+         * powered down at this point and groups are
+         * removed from an inactive virtual group.
+         * If not, then the broadcast unit will intercept
+         * their interrupts!
+         */
+        mali_bcast_disable(group->bcast_core);
+    } else {
+        /* Release L2 cache domain for physical groups */
+        MALI_DEBUG_ASSERT(MALI_MAX_NUM_DOMAIN_REFS >
+                num_domains);
+        domains[num_domains] = mali_l2_cache_get_pm_domain(
+                group->l2_cache_core[0]);
+        MALI_DEBUG_ASSERT(NULL == group->l2_cache_core[1]);
+        num_domains++;
+    }
+
+    power_down = mali_pm_put_domain_refs(domains, num_domains);
+
+    return power_down;
 }
 
 void mali_group_power_up(struct mali_group *group)
 {
-       MALI_DEBUG_ASSERT_POINTER(group);
-       MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
-
-       MALI_DEBUG_PRINT(3, ("Group: Power up for %s\n",
-                            mali_group_core_description(group)));
-
-       group->power_is_on = MALI_TRUE;
-
-       if (MALI_FALSE == mali_group_is_virtual(group)
-                       && MALI_FALSE == mali_group_is_in_virtual(group)) {
-               mali_group_reset(group);
-       }
-
-       /*
-        * When we just acquire only one physical group form virt group,
-        * we should remove the bcast&dlbu mask from virt group and
-        * reset bcast and dlbu core, although part of pp cores in virt
-        * group maybe not be powered on.
-        */
-       if (MALI_TRUE == mali_group_is_virtual(group)) {
-               mali_bcast_reset(group->bcast_core);
-               mali_dlbu_update_mask(group->dlbu_core);
-       }
+    MALI_DEBUG_ASSERT_POINTER(group);
+    MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
+
+    MALI_DEBUG_PRINT(3, ("Group: Power up for %s\n",
+                mali_group_core_description(group)));
+
+    group->power_is_on = MALI_TRUE;
+
+    if (MALI_FALSE == mali_group_is_virtual(group)
+            && MALI_FALSE == mali_group_is_in_virtual(group)) {
+        mali_group_reset(group);
+    }
+
+    /*
+     * When we just acquire only one physical group form virt group,
+     * we should remove the bcast&dlbu mask from virt group and
+     * reset bcast and dlbu core, although part of pp cores in virt
+     * group maybe not be powered on.
+     */
+    if (MALI_TRUE == mali_group_is_virtual(group)) {
+        mali_bcast_reset(group->bcast_core);
+        mali_dlbu_update_mask(group->dlbu_core);
+    }
 }
 
 void mali_group_power_down(struct mali_group *group)
 {
-       MALI_DEBUG_ASSERT_POINTER(group);
-       MALI_DEBUG_ASSERT(MALI_TRUE == group->power_is_on);
-       MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
-
-       MALI_DEBUG_PRINT(3, ("Group: Power down for %s\n",
-                            mali_group_core_description(group)));
-
-       group->power_is_on = MALI_FALSE;
-
-       if (mali_group_is_virtual(group)) {
-               /*
-                * What we do for physical jobs in this function should
-                * already have been done in mali_group_deactivate()
-                * for virtual group.
-                */
-               MALI_DEBUG_ASSERT(NULL == group->session);
-       } else {
-               mali_group_clear_session(group);
-       }
+    MALI_DEBUG_ASSERT_POINTER(group);
+    MALI_DEBUG_ASSERT(MALI_TRUE == group->power_is_on);
+    MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
+
+    MALI_DEBUG_PRINT(3, ("Group: Power down for %s\n",
+                mali_group_core_description(group)));
+
+    group->power_is_on = MALI_FALSE;
+
+    if (mali_group_is_virtual(group)) {
+        /*
+         * What we do for physical jobs in this function should
+         * already have been done in mali_group_deactivate()
+         * for virtual group.
+         */
+        MALI_DEBUG_ASSERT(NULL == group->session);
+    } else {
+        mali_group_clear_session(group);
+    }
 }
 
 MALI_DEBUG_CODE(static void mali_group_print_virtual(struct mali_group *vgroup)
-{
-       u32 i;
-       struct mali_group *group;
-       struct mali_group *temp;
-
-       MALI_DEBUG_PRINT(4, ("Virtual group %s (%p)\n",
-                            mali_group_core_description(vgroup),
-                            vgroup));
-       MALI_DEBUG_PRINT(4, ("l2_cache_core[0] = %p, ref = %d\n", vgroup->l2_cache_core[0], vgroup->l2_cache_core_ref_count[0]));
-       MALI_DEBUG_PRINT(4, ("l2_cache_core[1] = %p, ref = %d\n", vgroup->l2_cache_core[1], vgroup->l2_cache_core_ref_count[1]));
-
-       i = 0;
-       _MALI_OSK_LIST_FOREACHENTRY(group, temp, &vgroup->group_list, struct mali_group, group_list) {
-               MALI_DEBUG_PRINT(4, ("[%d] %s (%p), l2_cache_core[0] = %p\n",
-                                    i, mali_group_core_description(group),
-                                    group, group->l2_cache_core[0]));
-               i++;
-       }
-})
+        {
+        u32 i;
+        struct mali_group *group;
+        struct mali_group *temp;
+
+        MALI_DEBUG_PRINT(4, ("Virtual group %s (%p)\n",
+                mali_group_core_description(vgroup),
+                vgroup));
+        MALI_DEBUG_PRINT(4, ("l2_cache_core[0] = %p, ref = %d\n", vgroup->l2_cache_core[0], vgroup->l2_cache_core_ref_count[0]));
+        MALI_DEBUG_PRINT(4, ("l2_cache_core[1] = %p, ref = %d\n", vgroup->l2_cache_core[1], vgroup->l2_cache_core_ref_count[1]));
+
+        i = 0;
+        _MALI_OSK_LIST_FOREACHENTRY(group, temp, &vgroup->group_list, struct mali_group, group_list) {
+        MALI_DEBUG_PRINT(4, ("[%d] %s (%p), l2_cache_core[0] = %p\n",
+                i, mali_group_core_description(group),
+                group, group->l2_cache_core[0]));
+        i++;
+        }
+        })
 
 /**
  * @brief Add child group to virtual group parent
  */
 void mali_group_add_group(struct mali_group *parent, struct mali_group *child)
 {
-       mali_bool found;
-       u32 i;
-
-       MALI_DEBUG_PRINT(3, ("Adding group %s to virtual group %s\n",
-                            mali_group_core_description(child),
-                            mali_group_core_description(parent)));
-
-       MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
-       MALI_DEBUG_ASSERT(mali_group_is_virtual(parent));
-       MALI_DEBUG_ASSERT(!mali_group_is_virtual(child));
-       MALI_DEBUG_ASSERT(NULL == child->parent_group);
-
-       _mali_osk_list_addtail(&child->group_list, &parent->group_list);
-
-       child->parent_group = parent;
-
-       MALI_DEBUG_ASSERT_POINTER(child->l2_cache_core[0]);
-
-       MALI_DEBUG_PRINT(4, ("parent->l2_cache_core: [0] = %p, [1] = %p\n", parent->l2_cache_core[0], parent->l2_cache_core[1]));
-       MALI_DEBUG_PRINT(4, ("child->l2_cache_core: [0] = %p, [1] = %p\n", child->l2_cache_core[0], child->l2_cache_core[1]));
-
-       /* Keep track of the L2 cache cores of child groups */
-       found = MALI_FALSE;
-       for (i = 0; i < 2; i++) {
-               if (parent->l2_cache_core[i] == child->l2_cache_core[0]) {
-                       MALI_DEBUG_ASSERT(parent->l2_cache_core_ref_count[i] > 0);
-                       parent->l2_cache_core_ref_count[i]++;
-                       found = MALI_TRUE;
-               }
-       }
-
-       if (!found) {
-               /* First time we see this L2 cache, add it to our list */
-               i = (NULL == parent->l2_cache_core[0]) ? 0 : 1;
-
-               MALI_DEBUG_PRINT(4, ("First time we see l2_cache %p. Adding to [%d] = %p\n", child->l2_cache_core[0], i, parent->l2_cache_core[i]));
-
-               MALI_DEBUG_ASSERT(NULL == parent->l2_cache_core[i]);
-
-               parent->l2_cache_core[i] = child->l2_cache_core[0];
-               parent->l2_cache_core_ref_count[i]++;
-       }
-
-       /* Update Broadcast Unit and DLBU */
-       mali_bcast_add_group(parent->bcast_core, child);
-       mali_dlbu_add_group(parent->dlbu_core, child);
-
-       if (MALI_TRUE == parent->power_is_on) {
-               mali_bcast_reset(parent->bcast_core);
-               mali_dlbu_update_mask(parent->dlbu_core);
-       }
-
-       if (MALI_TRUE == child->power_is_on) {
-               if (NULL == parent->session) {
-                       if (NULL != child->session) {
-                               /*
-                                * Parent has no session, so clear
-                                * child session as well.
-                                */
-                               mali_mmu_activate_empty_page_directory(child->mmu);
-                       }
-               } else {
-                       if (parent->session == child->session) {
-                               /* We already have same session as parent,
-                                * so a simple zap should be enough.
-                                */
-                               mali_mmu_zap_tlb(child->mmu);
-                       } else {
-                               /*
-                                * Parent has a different session, so we must
-                                * switch to that sessions page table
-                                */
-                               mali_mmu_activate_page_directory(child->mmu, mali_session_get_page_directory(parent->session));
-                       }
-
-                       /* It is the parent which keeps the session from now on */
-                       child->session = NULL;
-               }
-       } else {
-               /* should have been cleared when child was powered down */
-               MALI_DEBUG_ASSERT(NULL == child->session);
-       }
-
-       /* Start job on child when parent is active */
-       if (NULL != parent->pp_running_job) {
-               struct mali_pp_job *job = parent->pp_running_job;
-
-               MALI_DEBUG_PRINT(3, ("Group %x joining running job %d on virtual group %x\n",
-                                    child, mali_pp_job_get_id(job), parent));
-
-               /* Only allowed to add active child to an active parent */
-               MALI_DEBUG_ASSERT(MALI_GROUP_STATE_ACTIVE == parent->state);
-               MALI_DEBUG_ASSERT(MALI_GROUP_STATE_ACTIVE == child->state);
-
-               mali_pp_job_start(child->pp_core, job, mali_pp_core_get_id(child->pp_core), MALI_TRUE);
-
-               _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
-                                             MALI_PROFILING_MAKE_EVENT_CHANNEL_PP(mali_pp_core_get_id(child->pp_core)) |
-                                             MALI_PROFILING_EVENT_REASON_SINGLE_HW_FLUSH,
-                                             mali_pp_job_get_frame_builder_id(job), mali_pp_job_get_flush_id(job), 0, 0, 0);
-
-               _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START |
-                                             MALI_PROFILING_MAKE_EVENT_CHANNEL_PP(mali_pp_core_get_id(child->pp_core)) |
-                                             MALI_PROFILING_EVENT_REASON_START_STOP_HW_VIRTUAL,
-                                             mali_pp_job_get_pid(job), mali_pp_job_get_tid(job), 0, 0, 0);
+    mali_bool found;
+    u32 i;
+
+    MALI_DEBUG_PRINT(3, ("Adding group %s to virtual group %s\n",
+                mali_group_core_description(child),
+                mali_group_core_description(parent)));
+
+    MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
+    MALI_DEBUG_ASSERT(mali_group_is_virtual(parent));
+    MALI_DEBUG_ASSERT(!mali_group_is_virtual(child));
+    MALI_DEBUG_ASSERT(NULL == child->parent_group);
+
+    _mali_osk_list_addtail(&child->group_list, &parent->group_list);
+
+    child->parent_group = parent;
+
+    MALI_DEBUG_ASSERT_POINTER(child->l2_cache_core[0]);
+
+    MALI_DEBUG_PRINT(4, ("parent->l2_cache_core: [0] = %p, [1] = %p\n", parent->l2_cache_core[0], parent->l2_cache_core[1]));
+    MALI_DEBUG_PRINT(4, ("child->l2_cache_core: [0] = %p, [1] = %p\n", child->l2_cache_core[0], child->l2_cache_core[1]));
+
+    /* Keep track of the L2 cache cores of child groups */
+    found = MALI_FALSE;
+    for (i = 0; i < 2; i++) {
+        if (parent->l2_cache_core[i] == child->l2_cache_core[0]) {
+            MALI_DEBUG_ASSERT(parent->l2_cache_core_ref_count[i] > 0);
+            parent->l2_cache_core_ref_count[i]++;
+            found = MALI_TRUE;
+        }
+    }
+
+    if (!found) {
+        /* First time we see this L2 cache, add it to our list */
+        i = (NULL == parent->l2_cache_core[0]) ? 0 : 1;
+
+        MALI_DEBUG_PRINT(4, ("First time we see l2_cache %p. Adding to [%d] = %p\n", child->l2_cache_core[0], i, parent->l2_cache_core[i]));
+
+        MALI_DEBUG_ASSERT(NULL == parent->l2_cache_core[i]);
+
+        parent->l2_cache_core[i] = child->l2_cache_core[0];
+        parent->l2_cache_core_ref_count[i]++;
+    }
+
+    /* Update Broadcast Unit and DLBU */
+    mali_bcast_add_group(parent->bcast_core, child);
+    mali_dlbu_add_group(parent->dlbu_core, child);
+
+    if (MALI_TRUE == parent->power_is_on) {
+        mali_bcast_reset(parent->bcast_core);
+        mali_dlbu_update_mask(parent->dlbu_core);
+    }
+
+    if (MALI_TRUE == child->power_is_on) {
+        if (NULL == parent->session) {
+            if (NULL != child->session) {
+                /*
+                 * Parent has no session, so clear
+                 * child session as well.
+                 */
+                mali_mmu_activate_empty_page_directory(child->mmu);
+            }
+        } else {
+            if (parent->session == child->session) {
+                /* We already have same session as parent,
+                 * so a simple zap should be enough.
+                 */
+                mali_mmu_zap_tlb(child->mmu);
+            } else {
+                /*
+                 * Parent has a different session, so we must
+                 * switch to that sessions page table
+                 */
+                mali_mmu_activate_page_directory(child->mmu, mali_session_get_page_directory(parent->session));
+            }
+
+            /* It is the parent which keeps the session from now on */
+            child->session = NULL;
+        }
+    } else {
+        /* should have been cleared when child was powered down */
+        MALI_DEBUG_ASSERT(NULL == child->session);
+    }
+
+    /* Start job on child when parent is active */
+    if (NULL != parent->pp_running_job) {
+        struct mali_pp_job *job = parent->pp_running_job;
+
+        MALI_DEBUG_PRINT(3, ("Group %x joining running job %d on virtual group %x\n",
+                    child, mali_pp_job_get_id(job), parent));
+
+        /* Only allowed to add active child to an active parent */
+        MALI_DEBUG_ASSERT(MALI_GROUP_STATE_ACTIVE == parent->state);
+        MALI_DEBUG_ASSERT(MALI_GROUP_STATE_ACTIVE == child->state);
+
+        mali_pp_job_start(child->pp_core, job, mali_pp_core_get_id(child->pp_core), MALI_TRUE);
+
+        _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
+                MALI_PROFILING_MAKE_EVENT_CHANNEL_PP(mali_pp_core_get_id(child->pp_core)) |
+                MALI_PROFILING_EVENT_REASON_SINGLE_HW_FLUSH,
+                mali_pp_job_get_frame_builder_id(job), mali_pp_job_get_flush_id(job), 0, 0, 0);
+
+        _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START |
+                MALI_PROFILING_MAKE_EVENT_CHANNEL_PP(mali_pp_core_get_id(child->pp_core)) |
+                MALI_PROFILING_EVENT_REASON_START_STOP_HW_VIRTUAL,
+                mali_pp_job_get_pid(job), mali_pp_job_get_tid(job), 0, 0, 0);
 #if defined(CONFIG_GPU_TRACEPOINTS) && defined(CONFIG_TRACEPOINTS)
-               trace_gpu_sched_switch(
-                       mali_pp_core_description(group->pp_core),
-                       sched_clock(), mali_pp_job_get_tid(job),
-                       0, mali_pp_job_get_id(job));
+        trace_gpu_sched_switch(
+                mali_pp_core_description(group->pp_core),
+                sched_clock(), mali_pp_job_get_tid(job),
+                0, mali_pp_job_get_id(job));
 #endif
 
 #if defined(CONFIG_MALI400_PROFILING)
-               trace_mali_core_active(mali_pp_job_get_pid(job), 1 /* active */, 0 /* PP */, mali_pp_core_get_id(child->pp_core),
-                                      mali_pp_job_get_frame_builder_id(job), mali_pp_job_get_flush_id(job));
+        trace_mali_core_active(mali_pp_job_get_pid(job), 1 /* active */, 0 /* PP */, mali_pp_core_get_id(child->pp_core),
+                mali_pp_job_get_frame_builder_id(job), mali_pp_job_get_flush_id(job));
 #endif
-       }
+    }
 
-       MALI_DEBUG_CODE(mali_group_print_virtual(parent);)
+    MALI_DEBUG_CODE(mali_group_print_virtual(parent);)
 }
 
 /**
@@ -655,155 +655,155 @@ void mali_group_add_group(struct mali_group *parent, struct mali_group *child)
  */
 void mali_group_remove_group(struct mali_group *parent, struct mali_group *child)
 {
-       u32 i;
+    u32 i;
 
-       MALI_DEBUG_PRINT(3, ("Removing group %s from virtual group %s\n",
-                            mali_group_core_description(child),
-                            mali_group_core_description(parent)));
+    MALI_DEBUG_PRINT(3, ("Removing group %s from virtual group %s\n",
+                mali_group_core_description(child),
+                mali_group_core_description(parent)));
 
-       MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
-       MALI_DEBUG_ASSERT(mali_group_is_virtual(parent));
-       MALI_DEBUG_ASSERT(!mali_group_is_virtual(child));
-       MALI_DEBUG_ASSERT(parent == child->parent_group);
+    MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
+    MALI_DEBUG_ASSERT(mali_group_is_virtual(parent));
+    MALI_DEBUG_ASSERT(!mali_group_is_virtual(child));
+    MALI_DEBUG_ASSERT(parent == child->parent_group);
 
-       /* Update Broadcast Unit and DLBU */
-       mali_bcast_remove_group(parent->bcast_core, child);
-       mali_dlbu_remove_group(parent->dlbu_core, child);
+    /* Update Broadcast Unit and DLBU */
+    mali_bcast_remove_group(parent->bcast_core, child);
+    mali_dlbu_remove_group(parent->dlbu_core, child);
 
-       if (MALI_TRUE == parent->power_is_on) {
-               mali_bcast_reset(parent->bcast_core);
-               mali_dlbu_update_mask(parent->dlbu_core);
-       }
+    if (MALI_TRUE == parent->power_is_on) {
+        mali_bcast_reset(parent->bcast_core);
+        mali_dlbu_update_mask(parent->dlbu_core);
+    }
 
-       child->session = parent->session;
-       child->parent_group = NULL;
+    child->session = parent->session;
+    child->parent_group = NULL;
 
-       _mali_osk_list_delinit(&child->group_list);
-       if (_mali_osk_list_empty(&parent->group_list)) {
-               parent->session = NULL;
-       }
+    _mali_osk_list_delinit(&child->group_list);
+    if (_mali_osk_list_empty(&parent->group_list)) {
+        parent->session = NULL;
+    }
 
-       /* Keep track of the L2 cache cores of child groups */
-       i = (child->l2_cache_core[0] == parent->l2_cache_core[0]) ? 0 : 1;
+    /* Keep track of the L2 cache cores of child groups */
+    i = (child->l2_cache_core[0] == parent->l2_cache_core[0]) ? 0 : 1;
 
-       MALI_DEBUG_ASSERT(child->l2_cache_core[0] == parent->l2_cache_core[i]);
+    MALI_DEBUG_ASSERT(child->l2_cache_core[0] == parent->l2_cache_core[i]);
 
-       parent->l2_cache_core_ref_count[i]--;
-       if (parent->l2_cache_core_ref_count[i] == 0) {
-               parent->l2_cache_core[i] = NULL;
-       }
+    parent->l2_cache_core_ref_count[i]--;
+    if (parent->l2_cache_core_ref_count[i] == 0) {
+        parent->l2_cache_core[i] = NULL;
+    }
 
-       MALI_DEBUG_CODE(mali_group_print_virtual(parent));
+    MALI_DEBUG_CODE(mali_group_print_virtual(parent));
 }
 
 struct mali_group *mali_group_acquire_group(struct mali_group *parent)
 {
-       struct mali_group *child = NULL;
+    struct mali_group *child = NULL;
 
-       MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
-       MALI_DEBUG_ASSERT(mali_group_is_virtual(parent));
+    MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
+    MALI_DEBUG_ASSERT(mali_group_is_virtual(parent));
 
-       if (!_mali_osk_list_empty(&parent->group_list)) {
-               child = _MALI_OSK_LIST_ENTRY(parent->group_list.prev, struct mali_group, group_list);
-               mali_group_remove_group(parent, child);
-       }
+    if (!_mali_osk_list_empty(&parent->group_list)) {
+        child = _MALI_OSK_LIST_ENTRY(parent->group_list.prev, struct mali_group, group_list);
+        mali_group_remove_group(parent, child);
+    }
 
-       if (NULL != child) {
-               if (MALI_GROUP_STATE_ACTIVE != parent->state
-                   && MALI_TRUE == child->power_is_on) {
-                       mali_group_reset(child);
-               }
-       }
+    if (NULL != child) {
+        if (MALI_GROUP_STATE_ACTIVE != parent->state
+                && MALI_TRUE == child->power_is_on) {
+            mali_group_reset(child);
+        }
+    }
 
-       return child;
+    return child;
 }
 
 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)));
-
-       if (NULL != group->dlbu_core) {
-               mali_dlbu_reset(group->dlbu_core);
-       }
-
-       if (NULL != group->bcast_core) {
-               mali_bcast_reset(group->bcast_core);
-       }
-
-       MALI_DEBUG_ASSERT(NULL != group->mmu);
-       mali_group_reset_mmu(group);
-
-       if (NULL != group->gp_core) {
-               MALI_DEBUG_ASSERT(NULL == group->pp_core);
-               mali_gp_reset(group->gp_core);
-       } else {
-               MALI_DEBUG_ASSERT(NULL != group->pp_core);
-               mali_group_reset_pp(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)));
+
+    if (NULL != group->dlbu_core) {
+        mali_dlbu_reset(group->dlbu_core);
+    }
+
+    if (NULL != group->bcast_core) {
+        mali_bcast_reset(group->bcast_core);
+    }
+
+    MALI_DEBUG_ASSERT(NULL != group->mmu);
+    mali_group_reset_mmu(group);
+
+    if (NULL != group->gp_core) {
+        MALI_DEBUG_ASSERT(NULL == group->pp_core);
+        mali_gp_reset(group->gp_core);
+    } else {
+        MALI_DEBUG_ASSERT(NULL != group->pp_core);
+        mali_group_reset_pp(group);
+    }
 }
 
 void mali_group_start_gp_job(struct mali_group *group, struct mali_gp_job *job)
 {
-       struct mali_session_data *session;
+    struct mali_session_data *session;
 
-       MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
+    MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
 
-       MALI_DEBUG_PRINT(3, ("Group: Starting GP job 0x%08X on group %s\n",
-                            job,
-                            mali_group_core_description(group)));
+    MALI_DEBUG_PRINT(3, ("Group: Starting GP job 0x%08X on group %s\n",
+                job,
+                mali_group_core_description(group)));
 
-       session = mali_gp_job_get_session(job);
+    session = mali_gp_job_get_session(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_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);
+    mali_group_activate_page_directory(group, session);
 
-       mali_gp_job_start(group->gp_core, job);
+    mali_gp_job_start(group->gp_core, job);
 
-       _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
-                                     MALI_PROFILING_MAKE_EVENT_CHANNEL_GP(0) |
-                                     MALI_PROFILING_EVENT_REASON_SINGLE_HW_FLUSH,
-                                     mali_gp_job_get_frame_builder_id(job), mali_gp_job_get_flush_id(job), 0, 0, 0);
-       _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START |
-                                     MALI_PROFILING_MAKE_EVENT_CHANNEL_GP(0),
-                                     mali_gp_job_get_pid(job), mali_gp_job_get_tid(job), 0, 0, 0);
+    _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
+            MALI_PROFILING_MAKE_EVENT_CHANNEL_GP(0) |
+            MALI_PROFILING_EVENT_REASON_SINGLE_HW_FLUSH,
+            mali_gp_job_get_frame_builder_id(job), mali_gp_job_get_flush_id(job), 0, 0, 0);
+    _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START |
+            MALI_PROFILING_MAKE_EVENT_CHANNEL_GP(0),
+            mali_gp_job_get_pid(job), mali_gp_job_get_tid(job), 0, 0, 0);
 
 #if defined(CONFIG_MALI400_PROFILING)
-       trace_mali_core_active(mali_gp_job_get_pid(job), 1 /* active */, 1 /* GP */,  0 /* core */,
-                              mali_gp_job_get_frame_builder_id(job), mali_gp_job_get_flush_id(job));
+    trace_mali_core_active(mali_gp_job_get_pid(job), 1 /* active */, 1 /* GP */,  0 /* core */,
+            mali_gp_job_get_frame_builder_id(job), mali_gp_job_get_flush_id(job));
 #endif
 
 #if defined(CONFIG_MALI400_PROFILING)
-       if ((MALI_HW_CORE_NO_COUNTER != mali_l2_cache_core_get_counter_src0(group->l2_cache_core[0])) &&
-           (MALI_HW_CORE_NO_COUNTER != mali_l2_cache_core_get_counter_src1(group->l2_cache_core[0]))) {
-               mali_group_report_l2_cache_counters_per_core(group, 0);
-       }
+    if ((MALI_HW_CORE_NO_COUNTER != mali_l2_cache_core_get_counter_src0(group->l2_cache_core[0])) &&
+            (MALI_HW_CORE_NO_COUNTER != mali_l2_cache_core_get_counter_src1(group->l2_cache_core[0]))) {
+        mali_group_report_l2_cache_counters_per_core(group, 0);
+    }
 #endif /* #if defined(CONFIG_MALI400_PROFILING) */
 
 #if defined(CONFIG_GPU_TRACEPOINTS) && defined(CONFIG_TRACEPOINTS)
-       trace_gpu_sched_switch(mali_gp_core_description(group->gp_core),
-                              sched_clock(), mali_gp_job_get_tid(job),
-                              0, mali_gp_job_get_id(job));
+    trace_gpu_sched_switch(mali_gp_core_description(group->gp_core),
+            sched_clock(), mali_gp_job_get_tid(job),
+            0, mali_gp_job_get_id(job));
 #endif
 
-       group->gp_running_job = job;
-       group->is_working = MALI_TRUE;
+    group->gp_running_job = job;
+    group->is_working = MALI_TRUE;
 
-       /* Setup SW timer and record start time */
-       group->start_time = _mali_osk_time_tickcount();
-       _mali_osk_timer_mod(group->timeout_timer, _mali_osk_time_mstoticks(mali_max_job_runtime));
+    /* Setup SW timer and record start time */
+    group->start_time = _mali_osk_time_tickcount();
+    _mali_osk_timer_mod(group->timeout_timer, _mali_osk_time_mstoticks(mali_max_job_runtime));
 
-       MALI_DEBUG_PRINT(4, ("Group: Started GP job 0x%08X on group %s at %u\n",
-                            job,
-                            mali_group_core_description(group),
-                            group->start_time));
+    MALI_DEBUG_PRINT(4, ("Group: Started GP job 0x%08X on group %s at %u\n",
+                job,
+                mali_group_core_description(group),
+                group->start_time));
 }
 
 /* Used to set all the registers except frame renderer list address and fragment shader stack address
@@ -811,541 +811,541 @@ void mali_group_start_gp_job(struct mali_group *group, struct mali_gp_job *job)
  */
 void mali_group_start_pp_job(struct mali_group *group, struct mali_pp_job *job, u32 sub_job)
 {
-       struct mali_session_data *session;
+    struct mali_session_data *session;
 
-       MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
+    MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
 
-       MALI_DEBUG_PRINT(3, ("Group: Starting PP job 0x%08X part %u/%u on group %s\n",
-                            job, sub_job + 1,
-                            mali_pp_job_get_sub_job_count(job),
-                            mali_group_core_description(group)));
+    MALI_DEBUG_PRINT(3, ("Group: Starting PP job 0x%08X part %u/%u on group %s\n",
+                job, sub_job + 1,
+                mali_pp_job_get_sub_job_count(job),
+                mali_group_core_description(group)));
 
-       session = mali_pp_job_get_session(job);
+    session = mali_pp_job_get_session(job);
 
-       if (NULL != group->l2_cache_core[0]) {
-               mali_l2_cache_invalidate_conditional(group->l2_cache_core[0], mali_pp_job_get_cache_order(job));
-       }
+    if (NULL != group->l2_cache_core[0]) {
+        mali_l2_cache_invalidate_conditional(group->l2_cache_core[0], mali_pp_job_get_cache_order(job));
+    }
 
-       if (NULL != group->l2_cache_core[1]) {
-               mali_l2_cache_invalidate_conditional(group->l2_cache_core[1], mali_pp_job_get_cache_order(job));
-       }
+    if (NULL != group->l2_cache_core[1]) {
+        mali_l2_cache_invalidate_conditional(group->l2_cache_core[1], mali_pp_job_get_cache_order(job));
+    }
 
-       mali_group_activate_page_directory(group, session);
+    mali_group_activate_page_directory(group, session);
 
-       if (mali_group_is_virtual(group)) {
-               struct mali_group *child;
-               struct mali_group *temp;
-               u32 core_num = 0;
+    if (mali_group_is_virtual(group)) {
+        struct mali_group *child;
+        struct mali_group *temp;
+        u32 core_num = 0;
 
-               MALI_DEBUG_ASSERT(mali_pp_job_is_virtual(job));
+        MALI_DEBUG_ASSERT(mali_pp_job_is_virtual(job));
 
-               /* Configure DLBU for the job */
-               mali_dlbu_config_job(group->dlbu_core, job);
+        /* Configure DLBU for the job */
+        mali_dlbu_config_job(group->dlbu_core, job);
 
-               /* Write stack address for each child group */
-               _MALI_OSK_LIST_FOREACHENTRY(child, temp, &group->group_list, struct mali_group, group_list) {
-                       mali_pp_write_addr_stack(child->pp_core, job);
-                       core_num++;
-               }
+        /* Write stack address for each child group */
+        _MALI_OSK_LIST_FOREACHENTRY(child, temp, &group->group_list, struct mali_group, group_list) {
+            mali_pp_write_addr_stack(child->pp_core, job);
+            core_num++;
+        }
 
-               mali_pp_job_start(group->pp_core, job, sub_job, MALI_FALSE);
-       } else {
-               mali_pp_job_start(group->pp_core, job, sub_job, MALI_FALSE);
-       }
+        mali_pp_job_start(group->pp_core, job, sub_job, MALI_FALSE);
+    } else {
+        mali_pp_job_start(group->pp_core, job, sub_job, MALI_FALSE);
+    }
 
-       /* if the group is virtual, loop through physical groups which belong to this group
-        * and call profiling events for its cores as virtual */
-       if (MALI_TRUE == mali_group_is_virtual(group)) {
-               struct mali_group *child;
-               struct mali_group *temp;
+    /* if the group is virtual, loop through physical groups which belong to this group
+     * and call profiling events for its cores as virtual */
+    if (MALI_TRUE == mali_group_is_virtual(group)) {
+        struct mali_group *child;
+        struct mali_group *temp;
 
-               _MALI_OSK_LIST_FOREACHENTRY(child, temp, &group->group_list, struct mali_group, group_list) {
-                       _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
-                                                     MALI_PROFILING_MAKE_EVENT_CHANNEL_PP(mali_pp_core_get_id(child->pp_core)) |
-                                                     MALI_PROFILING_EVENT_REASON_SINGLE_HW_FLUSH,
-                                                     mali_pp_job_get_frame_builder_id(job), mali_pp_job_get_flush_id(job), 0, 0, 0);
+        _MALI_OSK_LIST_FOREACHENTRY(child, temp, &group->group_list, struct mali_group, group_list) {
+            _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
+                    MALI_PROFILING_MAKE_EVENT_CHANNEL_PP(mali_pp_core_get_id(child->pp_core)) |
+                    MALI_PROFILING_EVENT_REASON_SINGLE_HW_FLUSH,
+                    mali_pp_job_get_frame_builder_id(job), mali_pp_job_get_flush_id(job), 0, 0, 0);
 
-                       _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START |
-                                                     MALI_PROFILING_MAKE_EVENT_CHANNEL_PP(mali_pp_core_get_id(child->pp_core)) |
-                                                     MALI_PROFILING_EVENT_REASON_START_STOP_HW_VIRTUAL,
-                                                     mali_pp_job_get_pid(job), mali_pp_job_get_tid(job), 0, 0, 0);
+            _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START |
+                    MALI_PROFILING_MAKE_EVENT_CHANNEL_PP(mali_pp_core_get_id(child->pp_core)) |
+                    MALI_PROFILING_EVENT_REASON_START_STOP_HW_VIRTUAL,
+                    mali_pp_job_get_pid(job), mali_pp_job_get_tid(job), 0, 0, 0);
 
 #if defined(CONFIG_MALI400_PROFILING)
-                       trace_mali_core_active(mali_pp_job_get_pid(job), 1 /* active */, 0 /* PP */, mali_pp_core_get_id(child->pp_core),
-                                              mali_pp_job_get_frame_builder_id(job), mali_pp_job_get_flush_id(job));
+            trace_mali_core_active(mali_pp_job_get_pid(job), 1 /* active */, 0 /* PP */, mali_pp_core_get_id(child->pp_core),
+                    mali_pp_job_get_frame_builder_id(job), mali_pp_job_get_flush_id(job));
 #endif
-               }
+        }
 
 #if defined(CONFIG_MALI400_PROFILING)
-               if (0 != group->l2_cache_core_ref_count[0]) {
-                       if ((MALI_HW_CORE_NO_COUNTER != mali_l2_cache_core_get_counter_src0(group->l2_cache_core[0])) &&
-                           (MALI_HW_CORE_NO_COUNTER != mali_l2_cache_core_get_counter_src1(group->l2_cache_core[0]))) {
-                               mali_group_report_l2_cache_counters_per_core(group, mali_l2_cache_get_id(group->l2_cache_core[0]));
-                       }
-               }
-               if (0 != group->l2_cache_core_ref_count[1]) {
-                       if ((MALI_HW_CORE_NO_COUNTER != mali_l2_cache_core_get_counter_src0(group->l2_cache_core[1])) &&
-                           (MALI_HW_CORE_NO_COUNTER != mali_l2_cache_core_get_counter_src1(group->l2_cache_core[1]))) {
-                               mali_group_report_l2_cache_counters_per_core(group, mali_l2_cache_get_id(group->l2_cache_core[1]));
-                       }
-               }
+        if (0 != group->l2_cache_core_ref_count[0]) {
+            if ((MALI_HW_CORE_NO_COUNTER != mali_l2_cache_core_get_counter_src0(group->l2_cache_core[0])) &&
+                    (MALI_HW_CORE_NO_COUNTER != mali_l2_cache_core_get_counter_src1(group->l2_cache_core[0]))) {
+                mali_group_report_l2_cache_counters_per_core(group, mali_l2_cache_get_id(group->l2_cache_core[0]));
+            }
+        }
+        if (0 != group->l2_cache_core_ref_count[1]) {
+            if ((MALI_HW_CORE_NO_COUNTER != mali_l2_cache_core_get_counter_src0(group->l2_cache_core[1])) &&
+                    (MALI_HW_CORE_NO_COUNTER != mali_l2_cache_core_get_counter_src1(group->l2_cache_core[1]))) {
+                mali_group_report_l2_cache_counters_per_core(group, mali_l2_cache_get_id(group->l2_cache_core[1]));
+            }
+        }
 #endif /* #if defined(CONFIG_MALI400_PROFILING) */
 
-       } else { /* group is physical - call profiling events for physical cores */
-               _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
-                                             MALI_PROFILING_MAKE_EVENT_CHANNEL_PP(mali_pp_core_get_id(group->pp_core)) |
-                                             MALI_PROFILING_EVENT_REASON_SINGLE_HW_FLUSH,
-                                             mali_pp_job_get_frame_builder_id(job), mali_pp_job_get_flush_id(job), 0, 0, 0);
+    } else { /* group is physical - call profiling events for physical cores */
+        _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
+                MALI_PROFILING_MAKE_EVENT_CHANNEL_PP(mali_pp_core_get_id(group->pp_core)) |
+                MALI_PROFILING_EVENT_REASON_SINGLE_HW_FLUSH,
+                mali_pp_job_get_frame_builder_id(job), mali_pp_job_get_flush_id(job), 0, 0, 0);
 
-               _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START |
-                                             MALI_PROFILING_MAKE_EVENT_CHANNEL_PP(mali_pp_core_get_id(group->pp_core)) |
-                                             MALI_PROFILING_EVENT_REASON_START_STOP_HW_PHYSICAL,
-                                             mali_pp_job_get_pid(job), mali_pp_job_get_tid(job), 0, 0, 0);
+        _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START |
+                MALI_PROFILING_MAKE_EVENT_CHANNEL_PP(mali_pp_core_get_id(group->pp_core)) |
+                MALI_PROFILING_EVENT_REASON_START_STOP_HW_PHYSICAL,
+                mali_pp_job_get_pid(job), mali_pp_job_get_tid(job), 0, 0, 0);
 
 #if defined(CONFIG_MALI400_PROFILING)
-               trace_mali_core_active(mali_pp_job_get_pid(job), 1 /* active */, 0 /* PP */, mali_pp_core_get_id(group->pp_core),
-                                      mali_pp_job_get_frame_builder_id(job), mali_pp_job_get_flush_id(job));
+        trace_mali_core_active(mali_pp_job_get_pid(job), 1 /* active */, 0 /* PP */, mali_pp_core_get_id(group->pp_core),
+                mali_pp_job_get_frame_builder_id(job), mali_pp_job_get_flush_id(job));
 #endif
 
 #if defined(CONFIG_MALI400_PROFILING)
-               if ((MALI_HW_CORE_NO_COUNTER != mali_l2_cache_core_get_counter_src0(group->l2_cache_core[0])) &&
-                   (MALI_HW_CORE_NO_COUNTER != mali_l2_cache_core_get_counter_src1(group->l2_cache_core[0]))) {
-                       mali_group_report_l2_cache_counters_per_core(group, mali_l2_cache_get_id(group->l2_cache_core[0]));
-               }
+        if ((MALI_HW_CORE_NO_COUNTER != mali_l2_cache_core_get_counter_src0(group->l2_cache_core[0])) &&
+                (MALI_HW_CORE_NO_COUNTER != mali_l2_cache_core_get_counter_src1(group->l2_cache_core[0]))) {
+            mali_group_report_l2_cache_counters_per_core(group, mali_l2_cache_get_id(group->l2_cache_core[0]));
+        }
 #endif /* #if defined(CONFIG_MALI400_PROFILING) */
-       }
+    }
 
 #if defined(CONFIG_GPU_TRACEPOINTS) && defined(CONFIG_TRACEPOINTS)
-       trace_gpu_sched_switch(mali_pp_core_description(group->pp_core),
-                              sched_clock(), mali_pp_job_get_tid(job),
-                              0, mali_pp_job_get_id(job));
+    trace_gpu_sched_switch(mali_pp_core_description(group->pp_core),
+            sched_clock(), mali_pp_job_get_tid(job),
+            0, mali_pp_job_get_id(job));
 #endif
 
-       group->pp_running_job = job;
-       group->pp_running_sub_job = sub_job;
-       group->is_working = MALI_TRUE;
+    group->pp_running_job = job;
+    group->pp_running_sub_job = sub_job;
+    group->is_working = MALI_TRUE;
 
-       /* Setup SW timer and record start time */
-       group->start_time = _mali_osk_time_tickcount();
-       _mali_osk_timer_mod(group->timeout_timer, _mali_osk_time_mstoticks(mali_max_job_runtime));
+    /* Setup SW timer and record start time */
+    group->start_time = _mali_osk_time_tickcount();
+    _mali_osk_timer_mod(group->timeout_timer, _mali_osk_time_mstoticks(mali_max_job_runtime));
 
-       MALI_DEBUG_PRINT(4, ("Group: Started PP job 0x%08X part %u/%u on group %s at %u\n",
-                            job, sub_job + 1,
-                            mali_pp_job_get_sub_job_count(job),
-                            mali_group_core_description(group),
-                            group->start_time));
+    MALI_DEBUG_PRINT(4, ("Group: Started PP job 0x%08X part %u/%u on group %s at %u\n",
+                job, sub_job + 1,
+                mali_pp_job_get_sub_job_count(job),
+                mali_group_core_description(group),
+                group->start_time));
 
 }
 
 void mali_group_resume_gp_with_new_heap(struct mali_group *group, u32 job_id, u32 start_addr, u32 end_addr)
 {
-       MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
+    MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
 
-       MALI_DEBUG_ASSERT_POINTER(group->l2_cache_core[0]);
-       mali_l2_cache_invalidate(group->l2_cache_core[0]);
+    MALI_DEBUG_ASSERT_POINTER(group->l2_cache_core[0]);
+    mali_l2_cache_invalidate(group->l2_cache_core[0]);
 
-       mali_mmu_zap_tlb_without_stall(group->mmu);
+    mali_mmu_zap_tlb_without_stall(group->mmu);
 
-       mali_gp_resume_with_new_heap(group->gp_core, start_addr, end_addr);
+    mali_gp_resume_with_new_heap(group->gp_core, start_addr, end_addr);
 
-       _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_RESUME |
-                                     MALI_PROFILING_MAKE_EVENT_CHANNEL_GP(0),
-                                     0, 0, 0, 0, 0);
+    _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_RESUME |
+            MALI_PROFILING_MAKE_EVENT_CHANNEL_GP(0),
+            0, 0, 0, 0, 0);
 
 #if defined(CONFIG_MALI400_PROFILING)
-       trace_mali_core_active(mali_gp_job_get_pid(group->gp_running_job), 1 /* active */, 1 /* GP */,  0 /* core */,
-                              mali_gp_job_get_frame_builder_id(group->gp_running_job), mali_gp_job_get_flush_id(group->gp_running_job));
+    trace_mali_core_active(mali_gp_job_get_pid(group->gp_running_job), 1 /* active */, 1 /* GP */,  0 /* core */,
+            mali_gp_job_get_frame_builder_id(group->gp_running_job), mali_gp_job_get_flush_id(group->gp_running_job));
 #endif
 }
 
 static void mali_group_reset_mmu(struct mali_group *group)
 {
-       struct mali_group *child;
-       struct mali_group *temp;
-       _mali_osk_errcode_t err;
-
-       MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
-
-       if (!mali_group_is_virtual(group)) {
-               /* This is a physical group or an idle virtual group -- simply wait for
-                * the reset to complete. */
-               err = mali_mmu_reset(group->mmu);
-               MALI_DEBUG_ASSERT(_MALI_OSK_ERR_OK == err);
-       } else { /* virtual group */
-               /* Loop through all members of this virtual group and wait
-                * until they are done resetting.
-                */
-               _MALI_OSK_LIST_FOREACHENTRY(child, temp, &group->group_list, struct mali_group, group_list) {
-                       err = mali_mmu_reset(child->mmu);
-                       MALI_DEBUG_ASSERT(_MALI_OSK_ERR_OK == err);
-               }
-       }
+    struct mali_group *child;
+    struct mali_group *temp;
+    _mali_osk_errcode_t err;
+
+    MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
+
+    if (!mali_group_is_virtual(group)) {
+        /* This is a physical group or an idle virtual group -- simply wait for
+         * the reset to complete. */
+        err = mali_mmu_reset(group->mmu);
+        MALI_DEBUG_ASSERT(_MALI_OSK_ERR_OK == err);
+    } else { /* virtual group */
+        /* Loop through all members of this virtual group and wait
+         * until they are done resetting.
+         */
+        _MALI_OSK_LIST_FOREACHENTRY(child, temp, &group->group_list, struct mali_group, group_list) {
+            err = mali_mmu_reset(child->mmu);
+            MALI_DEBUG_ASSERT(_MALI_OSK_ERR_OK == err);
+        }
+    }
 }
 
 static void mali_group_reset_pp(struct mali_group *group)
 {
-       struct mali_group *child;
-       struct mali_group *temp;
-
-       MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
-
-       mali_pp_reset_async(group->pp_core);
-
-       if (!mali_group_is_virtual(group) || NULL == group->pp_running_job) {
-               /* This is a physical group or an idle virtual group -- simply wait for
-                * the reset to complete. */
-               mali_pp_reset_wait(group->pp_core);
-       } else {
-               /* Loop through all members of this virtual group and wait until they
-                * are done resetting.
-                */
-               _MALI_OSK_LIST_FOREACHENTRY(child, temp, &group->group_list, struct mali_group, group_list) {
-                       mali_pp_reset_wait(child->pp_core);
-               }
-       }
+    struct mali_group *child;
+    struct mali_group *temp;
+
+    MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
+
+    mali_pp_reset_async(group->pp_core);
+
+    if (!mali_group_is_virtual(group) || NULL == group->pp_running_job) {
+        /* This is a physical group or an idle virtual group -- simply wait for
+         * the reset to complete. */
+        mali_pp_reset_wait(group->pp_core);
+    } else {
+        /* Loop through all members of this virtual group and wait until they
+         * are done resetting.
+         */
+        _MALI_OSK_LIST_FOREACHENTRY(child, temp, &group->group_list, struct mali_group, group_list) {
+            mali_pp_reset_wait(child->pp_core);
+        }
+    }
 }
 
 struct mali_pp_job *mali_group_complete_pp(struct mali_group *group, mali_bool success, u32 *sub_job)
 {
-       struct mali_pp_job *pp_job_to_return;
+    struct mali_pp_job *pp_job_to_return;
 
-       MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
-       MALI_DEBUG_ASSERT_POINTER(group);
-       MALI_DEBUG_ASSERT_POINTER(group->pp_core);
-       MALI_DEBUG_ASSERT_POINTER(group->pp_running_job);
-       MALI_DEBUG_ASSERT_POINTER(sub_job);
-       MALI_DEBUG_ASSERT(MALI_TRUE == group->is_working);
+    MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
+    MALI_DEBUG_ASSERT_POINTER(group);
+    MALI_DEBUG_ASSERT_POINTER(group->pp_core);
+    MALI_DEBUG_ASSERT_POINTER(group->pp_running_job);
+    MALI_DEBUG_ASSERT_POINTER(sub_job);
+    MALI_DEBUG_ASSERT(MALI_TRUE == group->is_working);
 
-       /* Stop/clear the timeout timer. */
-       _mali_osk_timer_del_async(group->timeout_timer);
+    /* Stop/clear the timeout timer. */
+    _mali_osk_timer_del_async(group->timeout_timer);
 
-       if (NULL != group->pp_running_job) {
+    if (NULL != group->pp_running_job) {
 
-               /* Deal with HW counters and profiling */
+        /* Deal with HW counters and profiling */
 
-               if (MALI_TRUE == mali_group_is_virtual(group)) {
-                       struct mali_group *child;
-                       struct mali_group *temp;
+        if (MALI_TRUE == mali_group_is_virtual(group)) {
+            struct mali_group *child;
+            struct mali_group *temp;
 
-                       /* update performance counters from each physical pp core within this virtual group */
-                       _MALI_OSK_LIST_FOREACHENTRY(child, temp, &group->group_list, struct mali_group, group_list) {
-                               mali_pp_update_performance_counters(group->pp_core, child->pp_core, group->pp_running_job, mali_pp_core_get_id(child->pp_core));
-                       }
+            /* update performance counters from each physical pp core within this virtual group */
+            _MALI_OSK_LIST_FOREACHENTRY(child, temp, &group->group_list, struct mali_group, group_list) {
+                mali_pp_update_performance_counters(group->pp_core, child->pp_core, group->pp_running_job, mali_pp_core_get_id(child->pp_core));
+            }
 
 #if defined(CONFIG_MALI400_PROFILING)
-                       /* send profiling data per physical core */
-                       _MALI_OSK_LIST_FOREACHENTRY(child, temp, &group->group_list, struct mali_group, group_list) {
-                               _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP |
-                                                             MALI_PROFILING_MAKE_EVENT_CHANNEL_PP(mali_pp_core_get_id(child->pp_core)) |
-                                                             MALI_PROFILING_EVENT_REASON_START_STOP_HW_VIRTUAL,
-                                                             mali_pp_job_get_perf_counter_value0(group->pp_running_job, mali_pp_core_get_id(child->pp_core)),
-                                                             mali_pp_job_get_perf_counter_value1(group->pp_running_job, mali_pp_core_get_id(child->pp_core)),
-                                                             mali_pp_job_get_perf_counter_src0(group->pp_running_job, group->pp_running_sub_job) | (mali_pp_job_get_perf_counter_src1(group->pp_running_job, group->pp_running_sub_job) << 8),
-                                                             0, 0);
-
-                               trace_mali_core_active(mali_pp_job_get_pid(group->pp_running_job),
-                                                      0 /* active */, 0 /* PP */, mali_pp_core_get_id(child->pp_core),
-                                                      mali_pp_job_get_frame_builder_id(group->pp_running_job),
-                                                      mali_pp_job_get_flush_id(group->pp_running_job));
-                       }
-                       if (0 != group->l2_cache_core_ref_count[0]) {
-                               if ((MALI_HW_CORE_NO_COUNTER != mali_l2_cache_core_get_counter_src0(group->l2_cache_core[0])) &&
-                                   (MALI_HW_CORE_NO_COUNTER != mali_l2_cache_core_get_counter_src1(group->l2_cache_core[0]))) {
-                                       mali_group_report_l2_cache_counters_per_core(group, mali_l2_cache_get_id(group->l2_cache_core[0]));
-                               }
-                       }
-                       if (0 != group->l2_cache_core_ref_count[1]) {
-                               if ((MALI_HW_CORE_NO_COUNTER != mali_l2_cache_core_get_counter_src0(group->l2_cache_core[1])) &&
-                                   (MALI_HW_CORE_NO_COUNTER != mali_l2_cache_core_get_counter_src1(group->l2_cache_core[1]))) {
-                                       mali_group_report_l2_cache_counters_per_core(group, mali_l2_cache_get_id(group->l2_cache_core[1]));
-                               }
-                       }
+            /* send profiling data per physical core */
+            _MALI_OSK_LIST_FOREACHENTRY(child, temp, &group->group_list, struct mali_group, group_list) {
+                _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP |
+                        MALI_PROFILING_MAKE_EVENT_CHANNEL_PP(mali_pp_core_get_id(child->pp_core)) |
+                        MALI_PROFILING_EVENT_REASON_START_STOP_HW_VIRTUAL,
+                        mali_pp_job_get_perf_counter_value0(group->pp_running_job, mali_pp_core_get_id(child->pp_core)),
+                        mali_pp_job_get_perf_counter_value1(group->pp_running_job, mali_pp_core_get_id(child->pp_core)),
+                        mali_pp_job_get_perf_counter_src0(group->pp_running_job, group->pp_running_sub_job) | (mali_pp_job_get_perf_counter_src1(group->pp_running_job, group->pp_running_sub_job) << 8),
+                        0, 0);
+
+                trace_mali_core_active(mali_pp_job_get_pid(group->pp_running_job),
+                        0 /* active */, 0 /* PP */, mali_pp_core_get_id(child->pp_core),
+                        mali_pp_job_get_frame_builder_id(group->pp_running_job),
+                        mali_pp_job_get_flush_id(group->pp_running_job));
+            }
+            if (0 != group->l2_cache_core_ref_count[0]) {
+                if ((MALI_HW_CORE_NO_COUNTER != mali_l2_cache_core_get_counter_src0(group->l2_cache_core[0])) &&
+                        (MALI_HW_CORE_NO_COUNTER != mali_l2_cache_core_get_counter_src1(group->l2_cache_core[0]))) {
+                    mali_group_report_l2_cache_counters_per_core(group, mali_l2_cache_get_id(group->l2_cache_core[0]));
+                }
+            }
+            if (0 != group->l2_cache_core_ref_count[1]) {
+                if ((MALI_HW_CORE_NO_COUNTER != mali_l2_cache_core_get_counter_src0(group->l2_cache_core[1])) &&
+                        (MALI_HW_CORE_NO_COUNTER != mali_l2_cache_core_get_counter_src1(group->l2_cache_core[1]))) {
+                    mali_group_report_l2_cache_counters_per_core(group, mali_l2_cache_get_id(group->l2_cache_core[1]));
+                }
+            }
 
 #endif
-               } else {
-                       /* update performance counters for a physical group's pp core */
-                       mali_pp_update_performance_counters(group->pp_core, group->pp_core, group->pp_running_job, group->pp_running_sub_job);
+        } else {
+            /* update performance counters for a physical group's pp core */
+            mali_pp_update_performance_counters(group->pp_core, group->pp_core, group->pp_running_job, group->pp_running_sub_job);
 
 #if defined(CONFIG_MALI400_PROFILING)
-                       _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP |
-                                                     MALI_PROFILING_MAKE_EVENT_CHANNEL_PP(mali_pp_core_get_id(group->pp_core)) |
-                                                     MALI_PROFILING_EVENT_REASON_START_STOP_HW_PHYSICAL,
-                                                     mali_pp_job_get_perf_counter_value0(group->pp_running_job, group->pp_running_sub_job),
-                                                     mali_pp_job_get_perf_counter_value1(group->pp_running_job, group->pp_running_sub_job),
-                                                     mali_pp_job_get_perf_counter_src0(group->pp_running_job, group->pp_running_sub_job) | (mali_pp_job_get_perf_counter_src1(group->pp_running_job, group->pp_running_sub_job) << 8),
-                                                     0, 0);
-
-                       trace_mali_core_active(mali_pp_job_get_pid(group->pp_running_job),
-                                              0 /* active */, 0 /* PP */, mali_pp_core_get_id(group->pp_core),
-                                              mali_pp_job_get_frame_builder_id(group->pp_running_job),
-                                              mali_pp_job_get_flush_id(group->pp_running_job));
-
-                       if ((MALI_HW_CORE_NO_COUNTER != mali_l2_cache_core_get_counter_src0(group->l2_cache_core[0])) &&
-                           (MALI_HW_CORE_NO_COUNTER != mali_l2_cache_core_get_counter_src1(group->l2_cache_core[0]))) {
-                               mali_group_report_l2_cache_counters_per_core(group, mali_l2_cache_get_id(group->l2_cache_core[0]));
-                       }
+            _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP |
+                    MALI_PROFILING_MAKE_EVENT_CHANNEL_PP(mali_pp_core_get_id(group->pp_core)) |
+                    MALI_PROFILING_EVENT_REASON_START_STOP_HW_PHYSICAL,
+                    mali_pp_job_get_perf_counter_value0(group->pp_running_job, group->pp_running_sub_job),
+                    mali_pp_job_get_perf_counter_value1(group->pp_running_job, group->pp_running_sub_job),
+                    mali_pp_job_get_perf_counter_src0(group->pp_running_job, group->pp_running_sub_job) | (mali_pp_job_get_perf_counter_src1(group->pp_running_job, group->pp_running_sub_job) << 8),
+                    0, 0);
+
+            trace_mali_core_active(mali_pp_job_get_pid(group->pp_running_job),
+                    0 /* active */, 0 /* PP */, mali_pp_core_get_id(group->pp_core),
+                    mali_pp_job_get_frame_builder_id(group->pp_running_job),
+                    mali_pp_job_get_flush_id(group->pp_running_job));
+
+            if ((MALI_HW_CORE_NO_COUNTER != mali_l2_cache_core_get_counter_src0(group->l2_cache_core[0])) &&
+                    (MALI_HW_CORE_NO_COUNTER != mali_l2_cache_core_get_counter_src1(group->l2_cache_core[0]))) {
+                mali_group_report_l2_cache_counters_per_core(group, mali_l2_cache_get_id(group->l2_cache_core[0]));
+            }
 #endif
-               }
+        }
 
 #if defined(CONFIG_GPU_TRACEPOINTS) && defined(CONFIG_TRACEPOINTS)
-               trace_gpu_sched_switch(
-                       mali_gp_core_description(group->gp_core),
-                       sched_clock(), 0, 0, 0);
+        trace_gpu_sched_switch(
+                mali_gp_core_description(group->gp_core),
+                sched_clock(), 0, 0, 0);
 #endif
 
-       }
+    }
 
-       if (success) {
-               /* Only do soft reset for successful jobs, a full recovery
-                * reset will be done for failed jobs. */
-               mali_pp_reset_async(group->pp_core);
-       }
+    if (success) {
+        /* Only do soft reset for successful jobs, a full recovery
+         * reset will be done for failed jobs. */
+        mali_pp_reset_async(group->pp_core);
+    }
 
-       pp_job_to_return = group->pp_running_job;
-       group->pp_running_job = NULL;
-       group->is_working = MALI_FALSE;
-       *sub_job = group->pp_running_sub_job;
+    pp_job_to_return = group->pp_running_job;
+    group->pp_running_job = NULL;
+    group->is_working = MALI_FALSE;
+    *sub_job = group->pp_running_sub_job;
 
-       if (!success) {
-               MALI_DEBUG_PRINT(2, ("Mali group: Executing recovery reset due to job failure\n"));
-               mali_group_recovery_reset(group);
-       } else if (_MALI_OSK_ERR_OK != mali_pp_reset_wait(group->pp_core)) {
-               MALI_PRINT_ERROR(("Mali group: Executing recovery reset due to reset failure\n"));
-               mali_group_recovery_reset(group);
-       }
+    if (!success) {
+        MALI_DEBUG_PRINT(2, ("Mali group: Executing recovery reset due to job failure\n"));
+        mali_group_recovery_reset(group);
+    } else if (_MALI_OSK_ERR_OK != mali_pp_reset_wait(group->pp_core)) {
+        MALI_PRINT_ERROR(("Mali group: Executing recovery reset due to reset failure\n"));
+        mali_group_recovery_reset(group);
+    }
 
-       return pp_job_to_return;
+    return pp_job_to_return;
 }
 
 struct mali_gp_job *mali_group_complete_gp(struct mali_group *group, mali_bool success)
 {
-       struct mali_gp_job *gp_job_to_return;
+    struct mali_gp_job *gp_job_to_return;
 
-       MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
-       MALI_DEBUG_ASSERT_POINTER(group);
-       MALI_DEBUG_ASSERT_POINTER(group->gp_core);
-       MALI_DEBUG_ASSERT_POINTER(group->gp_running_job);
-       MALI_DEBUG_ASSERT(MALI_TRUE == group->is_working);
+    MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
+    MALI_DEBUG_ASSERT_POINTER(group);
+    MALI_DEBUG_ASSERT_POINTER(group->gp_core);
+    MALI_DEBUG_ASSERT_POINTER(group->gp_running_job);
+    MALI_DEBUG_ASSERT(MALI_TRUE == group->is_working);
 
-       /* Stop/clear the timeout timer. */
-       _mali_osk_timer_del_async(group->timeout_timer);
+    /* Stop/clear the timeout timer. */
+    _mali_osk_timer_del_async(group->timeout_timer);
 
-       if (NULL != group->gp_running_job) {
-               mali_gp_update_performance_counters(group->gp_core, group->gp_running_job);
+    if (NULL != group->gp_running_job) {
+        mali_gp_update_performance_counters(group->gp_core, group->gp_running_job);
 
 #if defined(CONFIG_MALI400_PROFILING)
-               _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP | MALI_PROFILING_MAKE_EVENT_CHANNEL_GP(0),
-                                             mali_gp_job_get_perf_counter_value0(group->gp_running_job),
-                                             mali_gp_job_get_perf_counter_value1(group->gp_running_job),
-                                             mali_gp_job_get_perf_counter_src0(group->gp_running_job) | (mali_gp_job_get_perf_counter_src1(group->gp_running_job) << 8),
-                                             0, 0);
-
-               if ((MALI_HW_CORE_NO_COUNTER != mali_l2_cache_core_get_counter_src0(group->l2_cache_core[0])) &&
-                   (MALI_HW_CORE_NO_COUNTER != mali_l2_cache_core_get_counter_src1(group->l2_cache_core[0])))
-                       mali_group_report_l2_cache_counters_per_core(group, 0);
+        _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP | MALI_PROFILING_MAKE_EVENT_CHANNEL_GP(0),
+                mali_gp_job_get_perf_counter_value0(group->gp_running_job),
+                mali_gp_job_get_perf_counter_value1(group->gp_running_job),
+                mali_gp_job_get_perf_counter_src0(group->gp_running_job) | (mali_gp_job_get_perf_counter_src1(group->gp_running_job) << 8),
+                0, 0);
+
+        if ((MALI_HW_CORE_NO_COUNTER != mali_l2_cache_core_get_counter_src0(group->l2_cache_core[0])) &&
+                (MALI_HW_CORE_NO_COUNTER != mali_l2_cache_core_get_counter_src1(group->l2_cache_core[0])))
+            mali_group_report_l2_cache_counters_per_core(group, 0);
 #endif
 
 #if defined(CONFIG_GPU_TRACEPOINTS) && defined(CONFIG_TRACEPOINTS)
-               trace_gpu_sched_switch(
-                       mali_pp_core_description(group->pp_core),
-                       sched_clock(), 0, 0, 0);
+        trace_gpu_sched_switch(
+                mali_pp_core_description(group->pp_core),
+                sched_clock(), 0, 0, 0);
 #endif
 
 #if defined(CONFIG_MALI400_PROFILING)
-               trace_mali_core_active(mali_gp_job_get_pid(group->gp_running_job), 0 /* active */, 1 /* GP */,  0 /* core */,
-                                      mali_gp_job_get_frame_builder_id(group->gp_running_job), mali_gp_job_get_flush_id(group->gp_running_job));
+        trace_mali_core_active(mali_gp_job_get_pid(group->gp_running_job), 0 /* active */, 1 /* GP */,  0 /* core */,
+                mali_gp_job_get_frame_builder_id(group->gp_running_job), mali_gp_job_get_flush_id(group->gp_running_job));
 #endif
 
-               mali_gp_job_set_current_heap_addr(group->gp_running_job,
-                                                 mali_gp_read_plbu_alloc_start_addr(group->gp_core));
-       }
-
-       if (success) {
-               /* Only do soft reset for successful jobs, a full recovery
-                * reset will be done for failed jobs. */
-               mali_gp_reset_async(group->gp_core);
-       }
-
-       gp_job_to_return = group->gp_running_job;
-       group->gp_running_job = NULL;
-       group->is_working = MALI_FALSE;
-
-       if (!success) {
-               MALI_DEBUG_PRINT(2, ("Mali group: Executing recovery reset due to job failure\n"));
-               mali_group_recovery_reset(group);
-       } else if (_MALI_OSK_ERR_OK != mali_gp_reset_wait(group->gp_core)) {
-               MALI_PRINT_ERROR(("Mali group: Executing recovery reset due to reset failure\n"));
-               mali_group_recovery_reset(group);
-       }
-
-       return gp_job_to_return;
+        mali_gp_job_set_current_heap_addr(group->gp_running_job,
+                mali_gp_read_plbu_alloc_start_addr(group->gp_core));
+    }
+
+    if (success) {
+        /* Only do soft reset for successful jobs, a full recovery
+         * reset will be done for failed jobs. */
+        mali_gp_reset_async(group->gp_core);
+    }
+
+    gp_job_to_return = group->gp_running_job;
+    group->gp_running_job = NULL;
+    group->is_working = MALI_FALSE;
+
+    if (!success) {
+        MALI_DEBUG_PRINT(2, ("Mali group: Executing recovery reset due to job failure\n"));
+        mali_group_recovery_reset(group);
+    } else if (_MALI_OSK_ERR_OK != mali_gp_reset_wait(group->gp_core)) {
+        MALI_PRINT_ERROR(("Mali group: Executing recovery reset due to reset failure\n"));
+        mali_group_recovery_reset(group);
+    }
+
+    return gp_job_to_return;
 }
 
 struct mali_group *mali_group_get_glob_group(u32 index)
 {
-       if (mali_global_num_groups > index) {
-               return mali_global_groups[index];
-       }
+    if (mali_global_num_groups > index) {
+        return mali_global_groups[index];
+    }
 
-       return NULL;
+    return NULL;
 }
 
 u32 mali_group_get_glob_num_groups(void)
 {
-       return mali_global_num_groups;
+    return mali_global_num_groups;
 }
 
 static void mali_group_activate_page_directory(struct mali_group *group, struct mali_session_data *session)
 {
-       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,
-                            mali_group_core_description(group)));
-
-       MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
-
-       if (group->session != session) {
-               /* 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,
-                                    mali_group_core_description(group)));
-               mali_mmu_activate_page_directory(group->mmu, mali_session_get_page_directory(session));
-               group->session = session;
-       } else {
-               /* Same session as last time, so no work required */
-               MALI_DEBUG_PRINT(4, ("Mali group: Activate existing session 0x%08X on group %s\n",
-                                    session->page_directory,
-                                    mali_group_core_description(group)));
-               mali_mmu_zap_tlb_without_stall(group->mmu);
-       }
+    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,
+                mali_group_core_description(group)));
+
+    MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
+
+    if (group->session != session) {
+        /* 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,
+                    mali_group_core_description(group)));
+        mali_mmu_activate_page_directory(group->mmu, mali_session_get_page_directory(session));
+        group->session = session;
+    } else {
+        /* Same session as last time, so no work required */
+        MALI_DEBUG_PRINT(4, ("Mali group: Activate existing session 0x%08X on group %s\n",
+                    session->page_directory,
+                    mali_group_core_description(group)));
+        mali_mmu_zap_tlb_without_stall(group->mmu);
+    }
 }
 
 static void mali_group_recovery_reset(struct mali_group *group)
 {
-       _mali_osk_errcode_t err;
-
-       MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
-
-       /* Stop cores, bus stop */
-       if (NULL != group->pp_core) {
-               mali_pp_stop_bus(group->pp_core);
-       } else {
-               mali_gp_stop_bus(group->gp_core);
-       }
-
-       /* Flush MMU and clear page fault (if any) */
-       mali_mmu_activate_fault_flush_page_directory(group->mmu);
-       mali_mmu_page_fault_done(group->mmu);
-
-       /* Wait for cores to stop bus, then do a hard reset on them */
-       if (NULL != group->pp_core) {
-               if (mali_group_is_virtual(group)) {
-                       struct mali_group *child, *temp;
-
-                       /* Disable the broadcast unit while we do reset directly on the member cores. */
-                       mali_bcast_disable(group->bcast_core);
-
-                       _MALI_OSK_LIST_FOREACHENTRY(child, temp, &group->group_list, struct mali_group, group_list) {
-                               mali_pp_stop_bus_wait(child->pp_core);
-                               mali_pp_hard_reset(child->pp_core);
-                       }
-
-                       mali_bcast_enable(group->bcast_core);
-               } else {
-                       mali_pp_stop_bus_wait(group->pp_core);
-                       mali_pp_hard_reset(group->pp_core);
-               }
-       } else {
-               mali_gp_stop_bus_wait(group->gp_core);
-               mali_gp_hard_reset(group->gp_core);
-       }
-
-       /* Reset MMU */
-       err = mali_mmu_reset(group->mmu);
-       MALI_DEBUG_ASSERT(_MALI_OSK_ERR_OK == err);
-       MALI_IGNORE(err);
-
-       group->session = NULL;
+    _mali_osk_errcode_t err;
+
+    MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
+
+    /* Stop cores, bus stop */
+    if (NULL != group->pp_core) {
+        mali_pp_stop_bus(group->pp_core);
+    } else {
+        mali_gp_stop_bus(group->gp_core);
+    }
+
+    /* Flush MMU and clear page fault (if any) */
+    mali_mmu_activate_fault_flush_page_directory(group->mmu);
+    mali_mmu_page_fault_done(group->mmu);
+
+    /* Wait for cores to stop bus, then do a hard reset on them */
+    if (NULL != group->pp_core) {
+        if (mali_group_is_virtual(group)) {
+            struct mali_group *child, *temp;
+
+            /* Disable the broadcast unit while we do reset directly on the member cores. */
+            mali_bcast_disable(group->bcast_core);
+
+            _MALI_OSK_LIST_FOREACHENTRY(child, temp, &group->group_list, struct mali_group, group_list) {
+                mali_pp_stop_bus_wait(child->pp_core);
+                mali_pp_hard_reset(child->pp_core);
+            }
+
+            mali_bcast_enable(group->bcast_core);
+        } else {
+            mali_pp_stop_bus_wait(group->pp_core);
+            mali_pp_hard_reset(group->pp_core);
+        }
+    } else {
+        mali_gp_stop_bus_wait(group->gp_core);
+        mali_gp_hard_reset(group->gp_core);
+    }
+
+    /* Reset MMU */
+    err = mali_mmu_reset(group->mmu);
+    MALI_DEBUG_ASSERT(_MALI_OSK_ERR_OK == err);
+    MALI_IGNORE(err);
+
+    group->session = NULL;
 }
 
 #if MALI_STATE_TRACKING
 u32 mali_group_dump_state(struct mali_group *group, char *buf, u32 size)
 {
-       int n = 0;
-       int i;
-       struct mali_group *child;
-       struct mali_group *temp;
-
-       if (mali_group_is_virtual(group)) {
-               n += _mali_osk_snprintf(buf + n, size - n,
-                                       "Virtual PP Group: %p\n", group);
-       } else if (mali_group_is_in_virtual(group)) {
-               n += _mali_osk_snprintf(buf + n, size - n,
-                                       "Child PP Group: %p\n", group);
-       } else if (NULL != group->pp_core) {
-               n += _mali_osk_snprintf(buf + n, size - n,
-                                       "Physical PP Group: %p\n", group);
-       } else {
-               MALI_DEBUG_ASSERT_POINTER(group->gp_core);
-               n += _mali_osk_snprintf(buf + n, size - n,
-                                       "GP Group: %p\n", group);
-       }
-
-       switch (group->state) {
-       case MALI_GROUP_STATE_INACTIVE:
-               n += _mali_osk_snprintf(buf + n, size - n,
-                                       "\tstate: INACTIVE\n");
-               break;
-       case MALI_GROUP_STATE_ACTIVATION_PENDING:
-               n += _mali_osk_snprintf(buf + n, size - n,
-                                       "\tstate: ACTIVATION_PENDING\n");
-               break;
-       case MALI_GROUP_STATE_ACTIVE:
-               n += _mali_osk_snprintf(buf + n, size - n,
-                                       "\tstate: MALI_GROUP_STATE_ACTIVE\n");
-               break;
-       default:
-               n += _mali_osk_snprintf(buf + n, size - n,
-                                       "\tstate: UNKNOWN (%d)\n", group->state);
-               MALI_DEBUG_ASSERT(0);
-               break;
-       }
-
-       n += _mali_osk_snprintf(buf + n, size - n,
-                               "\tSW power: %s\n",
-                               group->power_is_on ? "On" : "Off");
-
-       n += mali_pm_dump_state_domain(group->pm_domain, buf + n, size - n);
-
-       for (i = 0; i < 2; i++) {
-               if (NULL != group->l2_cache_core[i]) {
-                       struct mali_pm_domain *domain;
-                       domain = mali_l2_cache_get_pm_domain(
-                                        group->l2_cache_core[i]);
-                       n += mali_pm_dump_state_domain(domain,
-                                                      buf + n, size - n);
-               }
-       }
-
-       if (group->gp_core) {
-               n += mali_gp_dump_state(group->gp_core, buf + n, size - n);
-               n += _mali_osk_snprintf(buf + n, size - n,
-                                       "\tGP running job: %p\n", group->gp_running_job);
-       }
-
-       if (group->pp_core) {
-               n += mali_pp_dump_state(group->pp_core, buf + n, size - n);
-               n += _mali_osk_snprintf(buf + n, size - n,
-                                       "\tPP running job: %p, subjob %d \n",
-                                       group->pp_running_job,
-                                       group->pp_running_sub_job);
-       }
-
-       _MALI_OSK_LIST_FOREACHENTRY(child, temp, &group->group_list,
-                                   struct mali_group, group_list) {
-               n += mali_group_dump_state(child, buf + n, size - n);
-       }
-
-       return n;
+    int n = 0;
+    int i;
+    struct mali_group *child;
+    struct mali_group *temp;
+
+    if (mali_group_is_virtual(group)) {
+        n += _mali_osk_snprintf(buf + n, size - n,
+                "Virtual PP Group: %p\n", group);
+    } else if (mali_group_is_in_virtual(group)) {
+        n += _mali_osk_snprintf(buf + n, size - n,
+                "Child PP Group: %p\n", group);
+    } else if (NULL != group->pp_core) {
+        n += _mali_osk_snprintf(buf + n, size - n,
+                "Physical PP Group: %p\n", group);
+    } else {
+        MALI_DEBUG_ASSERT_POINTER(group->gp_core);
+        n += _mali_osk_snprintf(buf + n, size - n,
+                "GP Group: %p\n", group);
+    }
+
+    switch (group->state) {
+        case MALI_GROUP_STATE_INACTIVE:
+            n += _mali_osk_snprintf(buf + n, size - n,
+                    "\tstate: INACTIVE\n");
+            break;
+        case MALI_GROUP_STATE_ACTIVATION_PENDING:
+            n += _mali_osk_snprintf(buf + n, size - n,
+                    "\tstate: ACTIVATION_PENDING\n");
+            break;
+        case MALI_GROUP_STATE_ACTIVE:
+            n += _mali_osk_snprintf(buf + n, size - n,
+                    "\tstate: MALI_GROUP_STATE_ACTIVE\n");
+            break;
+        default:
+            n += _mali_osk_snprintf(buf + n, size - n,
+                    "\tstate: UNKNOWN (%d)\n", group->state);
+            MALI_DEBUG_ASSERT(0);
+            break;
+    }
+
+    n += _mali_osk_snprintf(buf + n, size - n,
+            "\tSW power: %s\n",
+            group->power_is_on ? "On" : "Off");
+
+    n += mali_pm_dump_state_domain(group->pm_domain, buf + n, size - n);
+
+    for (i = 0; i < 2; i++) {
+        if (NULL != group->l2_cache_core[i]) {
+            struct mali_pm_domain *domain;
+            domain = mali_l2_cache_get_pm_domain(
+                    group->l2_cache_core[i]);
+            n += mali_pm_dump_state_domain(domain,
+                    buf + n, size - n);
+        }
+    }
+
+    if (group->gp_core) {
+        n += mali_gp_dump_state(group->gp_core, buf + n, size - n);
+        n += _mali_osk_snprintf(buf + n, size - n,
+                "\tGP running job: %p\n", group->gp_running_job);
+    }
+
+    if (group->pp_core) {
+        n += mali_pp_dump_state(group->pp_core, buf + n, size - n);
+        n += _mali_osk_snprintf(buf + n, size - n,
+                "\tPP running job: %p, subjob %d \n",
+                group->pp_running_job,
+                group->pp_running_sub_job);
+    }
+
+    _MALI_OSK_LIST_FOREACHENTRY(child, temp, &group->group_list,
+            struct mali_group, group_list) {
+        n += mali_group_dump_state(child, buf + n, size - n);
+    }
+
+    return n;
 }
 #endif
 
@@ -1359,188 +1359,194 @@ u32 get_irqnum(struct _mali_osk_irq_t_struct* irq);
 
 _mali_osk_errcode_t mali_group_upper_half_mmu(void *data)
 {
-       struct mali_group *group = (struct mali_group *)data;
-       _mali_osk_errcode_t ret;
+    struct mali_group *group = (struct mali_group *)data;
+#if MESON_CPU_TYPE == MESON_CPU_TYPE_MESON6
+    struct mali_mmu_core *mmu = group->mmu;
+#endif
+    _mali_osk_errcode_t ret;
 
-       MALI_DEBUG_ASSERT_POINTER(group);
-       MALI_DEBUG_ASSERT_POINTER(group->mmu);
+    MALI_DEBUG_ASSERT_POINTER(group);
+    MALI_DEBUG_ASSERT_POINTER(group->mmu);
 
 #if MESON_CPU_TYPE == MESON_CPU_TYPE_MESON6
-       if (MALI_FALSE == group->power_is_on)
-               MALI_SUCCESS;
-       if (get_irqnum(mmu->irq) == INT_MALI_PP2_MMU)
-       {
-               if (group == NULL || group->pp_core == NULL)
-                       MALI_SUCCESS;
-               if (group->pp_core->core_id == 0) {
-                       if (malifix_get_mmu_int_process_state(0) == MMU_INT_HIT)
-                               malifix_set_mmu_int_process_state(0, MMU_INT_TOP);
-                       else
-                               MALI_SUCCESS;
-               }
-               else if (group->pp_core->core_id == 1) {
-                       if (malifix_get_mmu_int_process_state(1) == MMU_INT_HIT)
-                               malifix_set_mmu_int_process_state(1, MMU_INT_TOP);
-                       else
-                               MALI_SUCCESS;
-               } else
-                       MALI_SUCCESS;
-       }
+    if (MALI_FALSE == group->power_is_on)
+        MALI_SUCCESS;
+    if (get_irqnum(mmu->irq) == INT_MALI_PP2_MMU)
+    {
+        if (group == NULL || group->pp_core == NULL)
+            MALI_SUCCESS;
+        if (group->pp_core->core_id == 0) {
+            if (malifix_get_mmu_int_process_state(0) == MMU_INT_HIT)
+                malifix_set_mmu_int_process_state(0, MMU_INT_TOP);
+            else
+                MALI_SUCCESS;
+        }
+        else if (group->pp_core->core_id == 1) {
+            if (malifix_get_mmu_int_process_state(1) == MMU_INT_HIT)
+                malifix_set_mmu_int_process_state(1, MMU_INT_TOP);
+            else
+                MALI_SUCCESS;
+        } else
+            MALI_SUCCESS;
+    }
 #endif
 
-       if (NULL != group->gp_core) {
-               _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START |
-                                             MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
-                                             MALI_PROFILING_EVENT_REASON_START_STOP_SW_UPPER_HALF,
-                                             0, 0, /* No pid and tid for interrupt handler */
-                                             MALI_PROFILING_MAKE_EVENT_DATA_CORE_GP_MMU(0),
-                                             mali_mmu_get_rawstat(group->mmu), 0);
-       } else {
-               MALI_DEBUG_ASSERT_POINTER(group->pp_core);
-               _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START |
-                                             MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
-                                             MALI_PROFILING_EVENT_REASON_START_STOP_SW_UPPER_HALF,
-                                             0, 0, /* No pid and tid for interrupt handler */
-                                             MALI_PROFILING_MAKE_EVENT_DATA_CORE_PP_MMU(
-                                                     mali_pp_core_get_id(group->pp_core)),
-                                             mali_mmu_get_rawstat(group->mmu), 0);
-       }
-
-       ret = mali_executor_interrupt_mmu(group, MALI_TRUE);
-
-       if (NULL != group->gp_core) {
-               _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP |
-                                             MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
-                                             MALI_PROFILING_EVENT_REASON_START_STOP_SW_UPPER_HALF,
-                                             0, 0, /* No pid and tid for interrupt handler */
-                                             MALI_PROFILING_MAKE_EVENT_DATA_CORE_GP_MMU(0),
-                                             mali_mmu_get_rawstat(group->mmu), 0);
-       } else {
-               _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP |
-                                             MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
-                                             MALI_PROFILING_EVENT_REASON_START_STOP_SW_UPPER_HALF,
-                                             0, 0, /* No pid and tid for interrupt handler */
-                                             MALI_PROFILING_MAKE_EVENT_DATA_CORE_PP_MMU(
-                                                     mali_pp_core_get_id(group->pp_core)),
-                                             mali_mmu_get_rawstat(group->mmu), 0);
-       }
-
-       return ret;
+    if (NULL != group->gp_core) {
+        _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START |
+                MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
+                MALI_PROFILING_EVENT_REASON_START_STOP_SW_UPPER_HALF,
+                0, 0, /* No pid and tid for interrupt handler */
+                MALI_PROFILING_MAKE_EVENT_DATA_CORE_GP_MMU(0),
+                mali_mmu_get_rawstat(group->mmu), 0);
+    } else {
+        MALI_DEBUG_ASSERT_POINTER(group->pp_core);
+        _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START |
+                MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
+                MALI_PROFILING_EVENT_REASON_START_STOP_SW_UPPER_HALF,
+                0, 0, /* No pid and tid for interrupt handler */
+                MALI_PROFILING_MAKE_EVENT_DATA_CORE_PP_MMU(
+                    mali_pp_core_get_id(group->pp_core)),
+                mali_mmu_get_rawstat(group->mmu), 0);
+    }
+
+    ret = mali_executor_interrupt_mmu(group, MALI_TRUE);
+
+    if (NULL != group->gp_core) {
+        _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP |
+                MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
+                MALI_PROFILING_EVENT_REASON_START_STOP_SW_UPPER_HALF,
+                0, 0, /* No pid and tid for interrupt handler */
+                MALI_PROFILING_MAKE_EVENT_DATA_CORE_GP_MMU(0),
+                mali_mmu_get_rawstat(group->mmu), 0);
+    } else {
+        _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP |
+                MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
+                MALI_PROFILING_EVENT_REASON_START_STOP_SW_UPPER_HALF,
+                0, 0, /* No pid and tid for interrupt handler */
+                MALI_PROFILING_MAKE_EVENT_DATA_CORE_PP_MMU(
+                    mali_pp_core_get_id(group->pp_core)),
+                mali_mmu_get_rawstat(group->mmu), 0);
+    }
+
+    return ret;
 }
 
 static void mali_group_bottom_half_mmu(void *data)
 {
-       struct mali_group *group = (struct mali_group *)data;
-
-       MALI_DEBUG_ASSERT_POINTER(group);
-       MALI_DEBUG_ASSERT_POINTER(group->mmu);
-
-       if (NULL != group->gp_core) {
-               _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START |
-                                             MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
-                                             MALI_PROFILING_EVENT_REASON_START_STOP_SW_BOTTOM_HALF,
-                                             0, _mali_osk_get_tid(), /* pid and tid */
-                                             MALI_PROFILING_MAKE_EVENT_DATA_CORE_GP_MMU(0),
-                                             mali_mmu_get_rawstat(group->mmu), 0);
-       } else {
-               MALI_DEBUG_ASSERT_POINTER(group->pp_core);
-               _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START |
-                                             MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
-                                             MALI_PROFILING_EVENT_REASON_START_STOP_SW_BOTTOM_HALF,
-                                             0, _mali_osk_get_tid(), /* pid and tid */
-                                             MALI_PROFILING_MAKE_EVENT_DATA_CORE_PP_MMU(
-                                                     mali_pp_core_get_id(group->pp_core)),
-                                             mali_mmu_get_rawstat(group->mmu), 0);
-       }
-
-       mali_executor_interrupt_mmu(group, MALI_FALSE);
-
-       if (NULL != group->gp_core) {
-               _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP |
-                                             MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
-                                             MALI_PROFILING_EVENT_REASON_START_STOP_SW_BOTTOM_HALF,
-                                             0, _mali_osk_get_tid(), /* pid and tid */
-                                             MALI_PROFILING_MAKE_EVENT_DATA_CORE_GP_MMU(0),
-                                             mali_mmu_get_rawstat(group->mmu), 0);
-       } else {
-               _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP |
-                                             MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
-                                             MALI_PROFILING_EVENT_REASON_START_STOP_SW_BOTTOM_HALF,
-                                             0, _mali_osk_get_tid(), /* pid and tid */
-                                             MALI_PROFILING_MAKE_EVENT_DATA_CORE_PP_MMU(
-                                                     mali_pp_core_get_id(group->pp_core)),
-                                             mali_mmu_get_rawstat(group->mmu), 0);
-       }
+    struct mali_group *group = (struct mali_group *)data;
+#if MESON_CPU_TYPE == MESON_CPU_TYPE_MESON6
+    struct mali_mmu_core *mmu = group->mmu;
+#endif
+
+    MALI_DEBUG_ASSERT_POINTER(group);
+    MALI_DEBUG_ASSERT_POINTER(group->mmu);
+
+    if (NULL != group->gp_core) {
+        _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START |
+                MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
+                MALI_PROFILING_EVENT_REASON_START_STOP_SW_BOTTOM_HALF,
+                0, _mali_osk_get_tid(), /* pid and tid */
+                MALI_PROFILING_MAKE_EVENT_DATA_CORE_GP_MMU(0),
+                mali_mmu_get_rawstat(group->mmu), 0);
+    } else {
+        MALI_DEBUG_ASSERT_POINTER(group->pp_core);
+        _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START |
+                MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
+                MALI_PROFILING_EVENT_REASON_START_STOP_SW_BOTTOM_HALF,
+                0, _mali_osk_get_tid(), /* pid and tid */
+                MALI_PROFILING_MAKE_EVENT_DATA_CORE_PP_MMU(
+                    mali_pp_core_get_id(group->pp_core)),
+                mali_mmu_get_rawstat(group->mmu), 0);
+    }
+
+    mali_executor_interrupt_mmu(group, MALI_FALSE);
+
+    if (NULL != group->gp_core) {
+        _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP |
+                MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
+                MALI_PROFILING_EVENT_REASON_START_STOP_SW_BOTTOM_HALF,
+                0, _mali_osk_get_tid(), /* pid and tid */
+                MALI_PROFILING_MAKE_EVENT_DATA_CORE_GP_MMU(0),
+                mali_mmu_get_rawstat(group->mmu), 0);
+    } else {
+        _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP |
+                MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
+                MALI_PROFILING_EVENT_REASON_START_STOP_SW_BOTTOM_HALF,
+                0, _mali_osk_get_tid(), /* pid and tid */
+                MALI_PROFILING_MAKE_EVENT_DATA_CORE_PP_MMU(
+                    mali_pp_core_get_id(group->pp_core)),
+                mali_mmu_get_rawstat(group->mmu), 0);
+    }
 #if MESON_CPU_TYPE == MESON_CPU_TYPE_MESON6
-       if (get_irqnum(mmu->irq) == INT_MALI_PP2_MMU)
-       {
-               if (group->pp_core->core_id == 0) {
-                       if (malifix_get_mmu_int_process_state(0) == MMU_INT_TOP)
-                               malifix_set_mmu_int_process_state(0, MMU_INT_NONE);
-               }
-               else if (group->pp_core->core_id == 1) {
-                       if (malifix_get_mmu_int_process_state(1) == MMU_INT_TOP)
-                               malifix_set_mmu_int_process_state(1, MMU_INT_NONE);
-               }
-       }
+    if (get_irqnum(mmu->irq) == INT_MALI_PP2_MMU)
+    {
+        if (group->pp_core->core_id == 0) {
+            if (malifix_get_mmu_int_process_state(0) == MMU_INT_TOP)
+                malifix_set_mmu_int_process_state(0, MMU_INT_NONE);
+        }
+        else if (group->pp_core->core_id == 1) {
+            if (malifix_get_mmu_int_process_state(1) == MMU_INT_TOP)
+                malifix_set_mmu_int_process_state(1, MMU_INT_NONE);
+        }
+    }
 #endif 
 }
 
 _mali_osk_errcode_t mali_group_upper_half_gp(void *data)
 {
-       struct mali_group *group = (struct mali_group *)data;
-       _mali_osk_errcode_t ret;
-
-       MALI_DEBUG_ASSERT_POINTER(group);
-       MALI_DEBUG_ASSERT_POINTER(group->gp_core);
-       MALI_DEBUG_ASSERT_POINTER(group->mmu);
-
-       _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START |
-                                     MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
-                                     MALI_PROFILING_EVENT_REASON_START_STOP_SW_UPPER_HALF,
-                                     0, 0, /* No pid and tid for interrupt handler */
-                                     MALI_PROFILING_MAKE_EVENT_DATA_CORE_GP(0),
-                                     mali_gp_get_rawstat(group->gp_core), 0);
-
-       MALI_DEBUG_PRINT(4, ("Group: Interrupt 0x%08X from %s\n",
-                            mali_gp_get_rawstat(group->gp_core),
-                            mali_group_core_description(group)));
-
-       ret = mali_executor_interrupt_gp(group, MALI_TRUE);
-
-       _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP |
-                                     MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
-                                     MALI_PROFILING_EVENT_REASON_START_STOP_SW_UPPER_HALF,
-                                     0, 0, /* No pid and tid for interrupt handler */
-                                     MALI_PROFILING_MAKE_EVENT_DATA_CORE_GP(0),
-                                     mali_gp_get_rawstat(group->gp_core), 0);
-
-       return ret;
+    struct mali_group *group = (struct mali_group *)data;
+    _mali_osk_errcode_t ret;
+
+    MALI_DEBUG_ASSERT_POINTER(group);
+    MALI_DEBUG_ASSERT_POINTER(group->gp_core);
+    MALI_DEBUG_ASSERT_POINTER(group->mmu);
+
+    _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START |
+            MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
+            MALI_PROFILING_EVENT_REASON_START_STOP_SW_UPPER_HALF,
+            0, 0, /* No pid and tid for interrupt handler */
+            MALI_PROFILING_MAKE_EVENT_DATA_CORE_GP(0),
+            mali_gp_get_rawstat(group->gp_core), 0);
+
+    MALI_DEBUG_PRINT(4, ("Group: Interrupt 0x%08X from %s\n",
+                mali_gp_get_rawstat(group->gp_core),
+                mali_group_core_description(group)));
+
+    ret = mali_executor_interrupt_gp(group, MALI_TRUE);
+
+    _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP |
+            MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
+            MALI_PROFILING_EVENT_REASON_START_STOP_SW_UPPER_HALF,
+            0, 0, /* No pid and tid for interrupt handler */
+            MALI_PROFILING_MAKE_EVENT_DATA_CORE_GP(0),
+            mali_gp_get_rawstat(group->gp_core), 0);
+
+    return ret;
 }
 
 static void mali_group_bottom_half_gp(void *data)
 {
-       struct mali_group *group = (struct mali_group *)data;
-
-       MALI_DEBUG_ASSERT_POINTER(group);
-       MALI_DEBUG_ASSERT_POINTER(group->gp_core);
-       MALI_DEBUG_ASSERT_POINTER(group->mmu);
-
-       _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START |
-                                     MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
-                                     MALI_PROFILING_EVENT_REASON_START_STOP_SW_BOTTOM_HALF,
-                                     0, _mali_osk_get_tid(), /* pid and tid */
-                                     MALI_PROFILING_MAKE_EVENT_DATA_CORE_GP(0),
-                                     mali_gp_get_rawstat(group->gp_core), 0);
-
-       mali_executor_interrupt_gp(group, MALI_FALSE);
-
-       _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP |
-                                     MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
-                                     MALI_PROFILING_EVENT_REASON_START_STOP_SW_BOTTOM_HALF,
-                                     0, _mali_osk_get_tid(), /* pid and tid */
-                                     MALI_PROFILING_MAKE_EVENT_DATA_CORE_GP(0),
-                                     mali_gp_get_rawstat(group->gp_core), 0);
+    struct mali_group *group = (struct mali_group *)data;
+
+    MALI_DEBUG_ASSERT_POINTER(group);
+    MALI_DEBUG_ASSERT_POINTER(group->gp_core);
+    MALI_DEBUG_ASSERT_POINTER(group->mmu);
+
+    _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START |
+            MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
+            MALI_PROFILING_EVENT_REASON_START_STOP_SW_BOTTOM_HALF,
+            0, _mali_osk_get_tid(), /* pid and tid */
+            MALI_PROFILING_MAKE_EVENT_DATA_CORE_GP(0),
+            mali_gp_get_rawstat(group->gp_core), 0);
+
+    mali_executor_interrupt_gp(group, MALI_FALSE);
+
+    _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP |
+            MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
+            MALI_PROFILING_EVENT_REASON_START_STOP_SW_BOTTOM_HALF,
+            0, _mali_osk_get_tid(), /* pid and tid */
+            MALI_PROFILING_MAKE_EVENT_DATA_CORE_GP(0),
+            mali_gp_get_rawstat(group->gp_core), 0);
 }
 
 #if MESON_CPU_TYPE == MESON_CPU_TYPE_MESON6
@@ -1561,166 +1567,169 @@ EXPORT_SYMBOL(mali_PP1_int_cnt);
 
 _mali_osk_errcode_t mali_group_upper_half_pp(void *data)
 {
-       struct mali_group *group = (struct mali_group *)data;
-       _mali_osk_errcode_t ret;
+    struct mali_group *group = (struct mali_group *)data;
+#if MESON_CPU_TYPE == MESON_CPU_TYPE_MESON6
+    struct mali_pp_core *core = group->pp_core;
+#endif
+    _mali_osk_errcode_t ret;
 
-       MALI_DEBUG_ASSERT_POINTER(group);
-       MALI_DEBUG_ASSERT_POINTER(group->pp_core);
-       MALI_DEBUG_ASSERT_POINTER(group->mmu);
+    MALI_DEBUG_ASSERT_POINTER(group);
+    MALI_DEBUG_ASSERT_POINTER(group->pp_core);
+    MALI_DEBUG_ASSERT_POINTER(group->mmu);
 
-       _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START |
-                                     MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
-                                     MALI_PROFILING_EVENT_REASON_START_STOP_SW_UPPER_HALF,
-                                     0, 0, /* No pid and tid for interrupt handler */
-                                     MALI_PROFILING_MAKE_EVENT_DATA_CORE_PP(
-                                             mali_pp_core_get_id(group->pp_core)),
-                                     mali_pp_get_rawstat(group->pp_core), 0);
+    _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START |
+            MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
+            MALI_PROFILING_EVENT_REASON_START_STOP_SW_UPPER_HALF,
+            0, 0, /* No pid and tid for interrupt handler */
+            MALI_PROFILING_MAKE_EVENT_DATA_CORE_PP(
+                mali_pp_core_get_id(group->pp_core)),
+            mali_pp_get_rawstat(group->pp_core), 0);
 
-       MALI_DEBUG_PRINT(4, ("Group: Interrupt 0x%08X from %s\n",
-                            mali_pp_get_rawstat(group->pp_core),
-                            mali_group_core_description(group)));
+    MALI_DEBUG_PRINT(4, ("Group: Interrupt 0x%08X from %s\n",
+                mali_pp_get_rawstat(group->pp_core),
+                mali_group_core_description(group)));
 
-       ret = mali_executor_interrupt_pp(group, MALI_TRUE);
+    ret = mali_executor_interrupt_pp(group, MALI_TRUE);
 
 #if MESON_CPU_TYPE == MESON_CPU_TYPE_MESON6
-       if (core->core_id == 0)
-               PP0_int_cnt++;
-       else if (core->core_id == 1)
-               PP1_int_cnt++;
+    if (core->core_id == 0)
+        PP0_int_cnt++;
+    else if (core->core_id == 1)
+        PP1_int_cnt++;
 #endif
 
-       _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP |
-                                     MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
-                                     MALI_PROFILING_EVENT_REASON_START_STOP_SW_UPPER_HALF,
-                                     0, 0, /* No pid and tid for interrupt handler */
-                                     MALI_PROFILING_MAKE_EVENT_DATA_CORE_PP(
-                                             mali_pp_core_get_id(group->pp_core)),
-                                     mali_pp_get_rawstat(group->pp_core), 0);
+    _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP |
+            MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
+            MALI_PROFILING_EVENT_REASON_START_STOP_SW_UPPER_HALF,
+            0, 0, /* No pid and tid for interrupt handler */
+            MALI_PROFILING_MAKE_EVENT_DATA_CORE_PP(
+                mali_pp_core_get_id(group->pp_core)),
+            mali_pp_get_rawstat(group->pp_core), 0);
 
-       return ret;
+    return ret;
 }
 
 static void mali_group_bottom_half_pp(void *data)
 {
-       struct mali_group *group = (struct mali_group *)data;
-
-       MALI_DEBUG_ASSERT_POINTER(group);
-       MALI_DEBUG_ASSERT_POINTER(group->pp_core);
-       MALI_DEBUG_ASSERT_POINTER(group->mmu);
-
-       _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START |
-                                     MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
-                                     MALI_PROFILING_EVENT_REASON_START_STOP_SW_BOTTOM_HALF,
-                                     0, _mali_osk_get_tid(), /* pid and tid */
-                                     MALI_PROFILING_MAKE_EVENT_DATA_CORE_PP(
-                                             mali_pp_core_get_id(group->pp_core)),
-                                     mali_pp_get_rawstat(group->pp_core), 0);
-
-       mali_executor_interrupt_pp(group, MALI_FALSE);
-
-       _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP |
-                                     MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
-                                     MALI_PROFILING_EVENT_REASON_START_STOP_SW_BOTTOM_HALF,
-                                     0, _mali_osk_get_tid(), /* pid and tid */
-                                     MALI_PROFILING_MAKE_EVENT_DATA_CORE_PP(
-                                             mali_pp_core_get_id(group->pp_core)),
-                                     mali_pp_get_rawstat(group->pp_core), 0);
+    struct mali_group *group = (struct mali_group *)data;
+
+    MALI_DEBUG_ASSERT_POINTER(group);
+    MALI_DEBUG_ASSERT_POINTER(group->pp_core);
+    MALI_DEBUG_ASSERT_POINTER(group->mmu);
+
+    _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_START |
+            MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
+            MALI_PROFILING_EVENT_REASON_START_STOP_SW_BOTTOM_HALF,
+            0, _mali_osk_get_tid(), /* pid and tid */
+            MALI_PROFILING_MAKE_EVENT_DATA_CORE_PP(
+                mali_pp_core_get_id(group->pp_core)),
+            mali_pp_get_rawstat(group->pp_core), 0);
+
+    mali_executor_interrupt_pp(group, MALI_FALSE);
+
+    _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_STOP |
+            MALI_PROFILING_EVENT_CHANNEL_SOFTWARE |
+            MALI_PROFILING_EVENT_REASON_START_STOP_SW_BOTTOM_HALF,
+            0, _mali_osk_get_tid(), /* pid and tid */
+            MALI_PROFILING_MAKE_EVENT_DATA_CORE_PP(
+                mali_pp_core_get_id(group->pp_core)),
+            mali_pp_get_rawstat(group->pp_core), 0);
 }
 
 static void mali_group_timeout(void *data)
 {
-       struct mali_group *group = (struct mali_group *)data;
-       MALI_DEBUG_ASSERT_POINTER(group);
-
-       MALI_DEBUG_PRINT(2, ("Group: timeout handler for %s at %u\n",
-                            mali_group_core_description(group),
-                            _mali_osk_time_tickcount()));
-
-       if (mali_core_timeout < 65533)
-               mali_core_timeout++;
-       if (NULL != group->gp_core) {
-               mali_group_schedule_bottom_half_gp(group);
-       } else {
-               MALI_DEBUG_ASSERT_POINTER(group->pp_core);
-               mali_group_schedule_bottom_half_pp(group);
-       }
+    struct mali_group *group = (struct mali_group *)data;
+    MALI_DEBUG_ASSERT_POINTER(group);
+
+    MALI_DEBUG_PRINT(2, ("Group: timeout handler for %s at %u\n",
+                mali_group_core_description(group),
+                _mali_osk_time_tickcount()));
+
+    if (mali_core_timeout < 65533)
+        mali_core_timeout++;
+    if (NULL != group->gp_core) {
+        mali_group_schedule_bottom_half_gp(group);
+    } else {
+        MALI_DEBUG_ASSERT_POINTER(group->pp_core);
+        mali_group_schedule_bottom_half_pp(group);
+    }
 }
 
 mali_bool mali_group_zap_session(struct mali_group *group,
-                                struct mali_session_data *session)
+        struct mali_session_data *session)
 {
-       MALI_DEBUG_ASSERT_POINTER(group);
-       MALI_DEBUG_ASSERT_POINTER(session);
-       MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
-
-       if (group->session != session) {
-               /* not running from this session */
-               return MALI_TRUE; /* success */
-       }
-
-       if (group->is_working) {
-               /* The Zap also does the stall and disable_stall */
-               mali_bool zap_success = mali_mmu_zap_tlb(group->mmu);
-               return zap_success;
-       } else {
-               /* Just remove the session instead of zapping */
-               mali_group_clear_session(group);
-               return MALI_TRUE; /* success */
-       }
+    MALI_DEBUG_ASSERT_POINTER(group);
+    MALI_DEBUG_ASSERT_POINTER(session);
+    MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
+
+    if (group->session != session) {
+        /* not running from this session */
+        return MALI_TRUE; /* success */
+    }
+
+    if (group->is_working) {
+        /* The Zap also does the stall and disable_stall */
+        mali_bool zap_success = mali_mmu_zap_tlb(group->mmu);
+        return zap_success;
+    } else {
+        /* Just remove the session instead of zapping */
+        mali_group_clear_session(group);
+        return MALI_TRUE; /* success */
+    }
 }
 
 #if defined(CONFIG_MALI400_PROFILING)
 static void mali_group_report_l2_cache_counters_per_core(struct mali_group *group, u32 core_num)
 {
-       u32 source0 = 0;
-       u32 value0 = 0;
-       u32 source1 = 0;
-       u32 value1 = 0;
-       u32 profiling_channel = 0;
-
-       MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
-
-       switch (core_num) {
-       case 0:
-               profiling_channel = MALI_PROFILING_EVENT_TYPE_SINGLE |
-                                   MALI_PROFILING_EVENT_CHANNEL_GPU |
-                                   MALI_PROFILING_EVENT_REASON_SINGLE_GPU_L20_COUNTERS;
-               break;
-       case 1:
-               profiling_channel = MALI_PROFILING_EVENT_TYPE_SINGLE |
-                                   MALI_PROFILING_EVENT_CHANNEL_GPU |
-                                   MALI_PROFILING_EVENT_REASON_SINGLE_GPU_L21_COUNTERS;
-               break;
-       case 2:
-               profiling_channel = MALI_PROFILING_EVENT_TYPE_SINGLE |
-                                   MALI_PROFILING_EVENT_CHANNEL_GPU |
-                                   MALI_PROFILING_EVENT_REASON_SINGLE_GPU_L22_COUNTERS;
-               break;
-       default:
-               profiling_channel = MALI_PROFILING_EVENT_TYPE_SINGLE |
-                                   MALI_PROFILING_EVENT_CHANNEL_GPU |
-                                   MALI_PROFILING_EVENT_REASON_SINGLE_GPU_L20_COUNTERS;
-               break;
-       }
-
-       if (0 == core_num) {
-               mali_l2_cache_core_get_counter_values(group->l2_cache_core[0], &source0, &value0, &source1, &value1);
-       }
-       if (1 == core_num) {
-               if (1 == mali_l2_cache_get_id(group->l2_cache_core[0])) {
-                       mali_l2_cache_core_get_counter_values(group->l2_cache_core[0], &source0, &value0, &source1, &value1);
-               } else if (1 == mali_l2_cache_get_id(group->l2_cache_core[1])) {
-                       mali_l2_cache_core_get_counter_values(group->l2_cache_core[1], &source0, &value0, &source1, &value1);
-               }
-       }
-       if (2 == core_num) {
-               if (2 == mali_l2_cache_get_id(group->l2_cache_core[0])) {
-                       mali_l2_cache_core_get_counter_values(group->l2_cache_core[0], &source0, &value0, &source1, &value1);
-               } else if (2 == mali_l2_cache_get_id(group->l2_cache_core[1])) {
-                       mali_l2_cache_core_get_counter_values(group->l2_cache_core[1], &source0, &value0, &source1, &value1);
-               }
-       }
-
-       _mali_osk_profiling_add_event(profiling_channel, source1 << 8 | source0, value0, value1, 0, 0);
+    u32 source0 = 0;
+    u32 value0 = 0;
+    u32 source1 = 0;
+    u32 value1 = 0;
+    u32 profiling_channel = 0;
+
+    MALI_DEBUG_ASSERT_EXECUTOR_LOCK_HELD();
+
+    switch (core_num) {
+        case 0:
+            profiling_channel = MALI_PROFILING_EVENT_TYPE_SINGLE |
+                MALI_PROFILING_EVENT_CHANNEL_GPU |
+                MALI_PROFILING_EVENT_REASON_SINGLE_GPU_L20_COUNTERS;
+            break;
+        case 1:
+            profiling_channel = MALI_PROFILING_EVENT_TYPE_SINGLE |
+                MALI_PROFILING_EVENT_CHANNEL_GPU |
+                MALI_PROFILING_EVENT_REASON_SINGLE_GPU_L21_COUNTERS;
+            break;
+        case 2:
+            profiling_channel = MALI_PROFILING_EVENT_TYPE_SINGLE |
+                MALI_PROFILING_EVENT_CHANNEL_GPU |
+                MALI_PROFILING_EVENT_REASON_SINGLE_GPU_L22_COUNTERS;
+            break;
+        default:
+            profiling_channel = MALI_PROFILING_EVENT_TYPE_SINGLE |
+                MALI_PROFILING_EVENT_CHANNEL_GPU |
+                MALI_PROFILING_EVENT_REASON_SINGLE_GPU_L20_COUNTERS;
+            break;
+    }
+
+    if (0 == core_num) {
+        mali_l2_cache_core_get_counter_values(group->l2_cache_core[0], &source0, &value0, &source1, &value1);
+    }
+    if (1 == core_num) {
+        if (1 == mali_l2_cache_get_id(group->l2_cache_core[0])) {
+            mali_l2_cache_core_get_counter_values(group->l2_cache_core[0], &source0, &value0, &source1, &value1);
+        } else if (1 == mali_l2_cache_get_id(group->l2_cache_core[1])) {
+            mali_l2_cache_core_get_counter_values(group->l2_cache_core[1], &source0, &value0, &source1, &value1);
+        }
+    }
+    if (2 == core_num) {
+        if (2 == mali_l2_cache_get_id(group->l2_cache_core[0])) {
+            mali_l2_cache_core_get_counter_values(group->l2_cache_core[0], &source0, &value0, &source1, &value1);
+        } else if (2 == mali_l2_cache_get_id(group->l2_cache_core[1])) {
+            mali_l2_cache_core_get_counter_values(group->l2_cache_core[1], &source0, &value0, &source1, &value1);
+        }
+    }
+
+    _mali_osk_profiling_add_event(profiling_channel, source1 << 8 | source0, value0, value1, 0, 0);
 }
 #endif /* #if defined(CONFIG_MALI400_PROFILING) */
index 7482e78c07e2f518ca5caa8abe295e9818934ec4..954bad92cebe6eba34ed35a609ae1e3a1b1e440b 100755 (executable)
@@ -466,24 +466,24 @@ void mali_l2_cache_invalidate_all_pages(u32 *pages, u32 num_pages)
 
 static void mali_l2_cache_reset(struct mali_l2_cache_core *cache)
 {
-       MALI_DEBUG_ASSERT_POINTER(cache);
-       MALI_DEBUG_ASSERT_LOCK_HELD(cache->lock);
+    MALI_DEBUG_ASSERT_POINTER(cache);
+    MALI_DEBUG_ASSERT_LOCK_HELD(cache->lock);
 
-       /* Kasin Added, skip off power domain. */
-       if (cache && cache->pm_domain && cache->pm_domain->power_is_on == MALI_FALSE) {
-               return;
-       }
-       
+    /* Kasin Added, skip off power domain. */
+    if (cache && cache->pm_domain && cache->pm_domain->power_is_on == MALI_FALSE) {
+        printk("===========%s, %d skip off power domain?\n", __FUNCTION__, __LINE__);
+    }
 
-       /* Invalidate cache (just to keep it in a known state at startup) */
-       mali_l2_cache_send_command(cache, MALI400_L2_CACHE_REGISTER_COMMAND,
-                                  MALI400_L2_CACHE_COMMAND_CLEAR_ALL);
 
-       /* Enable cache */
-       mali_hw_core_register_write(&cache->hw_core,
-                                   MALI400_L2_CACHE_REGISTER_ENABLE,
-                                   (u32)MALI400_L2_CACHE_ENABLE_ACCESS |
-                                   (u32)MALI400_L2_CACHE_ENABLE_READ_ALLOCATE);
+    /* Invalidate cache (just to keep it in a known state at startup) */
+    mali_l2_cache_send_command(cache, MALI400_L2_CACHE_REGISTER_COMMAND,
+            MALI400_L2_CACHE_COMMAND_CLEAR_ALL);
+
+    /* Enable cache */
+    mali_hw_core_register_write(&cache->hw_core,
+            MALI400_L2_CACHE_REGISTER_ENABLE,
+            (u32)MALI400_L2_CACHE_ENABLE_ACCESS |
+            (u32)MALI400_L2_CACHE_ENABLE_READ_ALLOCATE);
 
        if (MALI400_L2_MAX_READS_NOT_SET != mali_l2_max_reads) {
                mali_hw_core_register_write(&cache->hw_core,
index c3d14bd0b3eb33c0f03b716192d462bde237ab6f..38c02d171635a176824d72b8be38873fa76a5aa2 100755 (executable)
@@ -38,7 +38,6 @@
 #include "mali_kernel_license.h"
 #include "mali_memory.h"
 #include "mali_memory_dma_buf.h"
-#include <meson_main.h>
 #if defined(CONFIG_MALI400_INTERNAL_PROFILING)
 #include "mali_profiling_internal.h"
 #endif
@@ -63,6 +62,10 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(mali_sw_counters);
 
 /* from the __malidrv_build_info.c file that is generated during build */
 extern const char *__malidrv_build_info(void);
+extern void mali_post_init(void);
+extern int mali_pdev_dts_init(struct platform_device* mali_gpu_device);
+extern int mpgpu_class_init(void);
+extern void mpgpu_class_exit(void);
 
 /* Module parameter to control log level */
 int mali_debug_level = 2;
@@ -360,9 +363,6 @@ void mali_init_cpu_time_counters_on_all_cpus(int print_only)
 }
 #endif
 
-extern int mpgpu_class_init(void);
-extern void mpgpu_class_exit(void);
-
 int mali_module_init(void)
 {
        int err = 0;
index c8706d28983d5a948ab9c25da54d9c80420160ce..f825fc7f14c2b365b495f350e858eb83b4b103d2 100755 (executable)
 
 int mali_perf_set_num_pp_cores(unsigned int num_cores)
 {
+#ifndef CONFIG_MALI_DVFS
+       return mali_executor_set_perf_level(num_cores, MALI_TRUE);
+#else
        return mali_executor_set_perf_level(num_cores, MALI_FALSE);
+#endif
 }
 
 EXPORT_SYMBOL(mali_perf_set_num_pp_cores);
index a113a394978e7ea6ac45e4534fdd72f1343dc3f2..16ca2e84c5bed4cb418a80623fa2d6ae9b39630a 100755 (executable)
@@ -97,7 +97,7 @@ void enable_clock(void)
 
 u32 get_mali_freq(u32 idx)
 {
-    if (mali_pm_statue) {
+    if (!mali_pm_statue) {
        return pmali_plat->clk_sample[idx];
     } else {
         return 0;    
index eb61630383512529e788cc240d2ad2699c79a2ef..3b177a92bcfe26e30c660520a5871ffc98c44c05 100755 (executable)
@@ -51,16 +51,35 @@ static int mali_os_freeze(struct device *device)
 
        return ret;
 }
+//copy from r4p1 linux/mali_pmu_power_up_down.c
+#if MESON_CPU_TYPE >= MESON_CPU_TYPE_MESON8
+static int mali_pmu_powerup(void)
+{
+       struct mali_pmu_core *pmu = mali_pmu_get_global_pmu_core();
+
+       MALI_DEBUG_PRINT(5, ("Mali PMU: Power up\n"));
+
+       MALI_DEBUG_ASSERT_POINTER(pmu);
+       if (NULL == pmu) {
+               return -ENXIO;
+       }
+
+       mali_pmu_power_up_all(pmu);
+
+       return 0;
+}
+#endif
 
 static int mali_os_thaw(struct device *device)
 {
        int ret = 0;
-       struct mali_pmu_core *pmu;
 
        MALI_DEBUG_PRINT(4, ("mali_os_thaw() called\n"));
+#if MESON_CPU_TYPE >= MESON_CPU_TYPE_MESON8
        enable_clock();
-       pmu = mali_pmu_get_global_pmu_core();
-       mali_pmu_power_up_all(pmu);
+       mali_pmu_powerup();
+#endif
+
        if (NULL != device->driver &&
            NULL != device->driver->pm &&
            NULL != device->driver->pm->thaw)
@@ -75,7 +94,9 @@ static int mali_os_thaw(struct device *device)
 static int mali_os_restore(struct device *device)
 {
        MALI_DEBUG_PRINT(4, ("mali_os_thaw() called\n"));
+#if MESON_CPU_TYPE >= MESON_CPU_TYPE_MESON8
        mali_dev_restore();
+#endif
        return mali_os_resume(device);
 }
 
index 9f523c600738ee41bd2f5e2132d245bd08dcae29..0bc4cebc7e79f1fe4ceb0696333e44cfdb399474 100755 (executable)
@@ -138,6 +138,9 @@ int mali_meson_init_start(struct platform_device* ptr_plt_dev)
        /* for mali platform data. */
        struct mali_gpu_device_data* pdev = ptr_plt_dev->dev.platform_data;
 
+       pdev->control_interval = 1000;
+       pdev->utilization_callback = mali_gpu_utilization_callback;
+
        /* for resource data. */
        ptr_plt_dev->num_resources = ARRAY_SIZE(meson_mali_resources);
        ptr_plt_dev->resource = meson_mali_resources;
diff --git a/mali/platform/meson_m450/platform_g9tv.c b/mali/platform/meson_m450/platform_g9tv.c
deleted file mode 100755 (executable)
index dcfd0e3..0000000
+++ /dev/null
@@ -1,421 +0,0 @@
-/*
- * platform.c
- *
- * clock source setting and resource config
- *
- *  Created on: Dec 4, 2013
- *      Author: amlogic
- */
-
-#include <linux/platform_device.h>
-#include <linux/version.h>
-#include <linux/pm.h>
-#include <linux/of.h>
-#include <linux/module.h>            /* kernel module definitions */
-#include <linux/ioport.h>            /* request_mem_region */
-#include <linux/slab.h>
-#include <mach/register.h>
-#include <mach/irqs.h>
-#include <mach/io.h>
-#include <asm/io.h>
-#include <linux/mali/mali_utgard.h>
-#include <linux/gpu_cooling.h>
-#include <linux/gpucore_cooling.h>
-#include <common/mali_kernel_common.h>
-#include <common/mali_osk_profiling.h>
-#include <common/mali_pmu.h>
-
-#include "meson_main.h"
-
-/*
- *    For Meson 8 M2.
- *
- */
-
-#define CFG_PP 6
-#define CFG_CLOCK 3
-#define CFG_MIN_PP 1
-#define CFG_MIN_CLOCK 0
-
-/* fclk is 2550Mhz. */
-#define FCLK_DEV3 (6 << 9)             /*      850   Mhz  */
-#define FCLK_DEV4 (5 << 9)             /*      637.5 Mhz  */
-#define FCLK_DEV5 (7 << 9)             /*      510   Mhz  */
-#define FCLK_DEV7 (4 << 9)             /*      364.3 Mhz  */
-
-static u32 mali_dvfs_clk[] = {
-       FCLK_DEV7 | 1,     /* 182.1 Mhz */
-       FCLK_DEV4 | 1,     /* 318.7 Mhz */
-       FCLK_DEV3 | 1,     /* 425 Mhz */
-       FCLK_DEV5 | 0,     /* 510 Mhz */
-       FCLK_DEV4 | 0,     /* 637.5 Mhz */
-};
-
-static u32 mali_dvfs_clk_sample[] = {
-       182,     /* 182.1 Mhz */
-       319,     /* 318.7 Mhz */
-       425,     /* 425 Mhz */
-       510,     /* 510 Mhz */
-       637,     /* 637.5 Mhz */
-};
-
-static mali_dvfs_threshold_table mali_dvfs_table[]={
-               { 0, 0, 3,  70, 180}, /* for 182.1  */
-               { 1, 1, 3, 108, 205}, /* for 318.7  */
-               { 2, 2, 3, 150, 215}, /* for 425.0  */
-               { 3, 3, 3, 170, 253}, /* for 510.0  */
-               { 4, 4, 3, 230, 255},  /* for 637.5  */
-               { 0, 0, 3,   0,   0}
-};
-
-static void mali_plat_preheat(void);
-static mali_plat_info_t mali_plat_data = {
-       .cfg_pp = CFG_PP,  /* number of pp. */
-       .cfg_min_pp = CFG_MIN_PP,
-       .turbo_clock = 4, /* reserved clock src. */
-       .def_clock = 2, /* gpu clock used most of time.*/
-       .cfg_clock = CFG_CLOCK, /* max gpu clock. */
-       .cfg_clock_bkup = CFG_CLOCK,
-       .cfg_min_clock = CFG_MIN_CLOCK,
-
-       .sc_mpp = 3, /* number of pp used most of time.*/
-       .bst_gpu = 210, /* threshold for boosting gpu. */
-       .bst_pp = 160, /* threshold for boosting PP. */
-
-       .clk = mali_dvfs_clk, /* clock source table. */
-       .clk_sample = mali_dvfs_clk_sample, /* freqency table for show. */
-       .clk_len = sizeof(mali_dvfs_clk) / sizeof(mali_dvfs_clk[0]),
-       .have_switch = 1,
-
-       .dvfs_table = mali_dvfs_table, /* DVFS table. */
-       .dvfs_table_size = sizeof(mali_dvfs_table) / sizeof(mali_dvfs_threshold_table),
-
-       .scale_info = {
-               CFG_MIN_PP, /* minpp */
-               CFG_PP, /* maxpp, should be same as cfg_pp */
-               CFG_MIN_CLOCK, /* minclk */
-               CFG_CLOCK, /* maxclk should be same as cfg_clock */
-       },
-
-       .limit_on = 1,
-       .plat_preheat = mali_plat_preheat,
-};
-
-static void mali_plat_preheat(void)
-{
-       u32 pre_fs;
-       u32 clk, pp;
-
-       if (get_mali_schel_mode() != MALI_PP_FS_SCALING)
-               return;
-
-       get_mali_rt_clkpp(&clk, &pp);
-       pre_fs = mali_plat_data.def_clock + 1;
-       if (clk < pre_fs)
-               clk = pre_fs;
-       if (pp < mali_plat_data.sc_mpp)
-               pp = mali_plat_data.sc_mpp;
-       set_mali_rt_clkpp(clk, pp, 1);
-}
-
-mali_plat_info_t* get_mali_plat_data(void) {
-       return &mali_plat_data;
-}
-
-int get_mali_freq_level(int freq)
-{
-       int mali_freq_num;
-       int i = 0, level = -1;
-
-       if(freq < 0)
-               return level;
-
-       mali_freq_num = mali_plat_data.dvfs_table_size - 1;
-       if(freq <= mali_plat_data.clk_sample[0])
-               level = mali_freq_num-1;
-       if(freq >= mali_plat_data.clk_sample[mali_freq_num - 1])
-               level = 0;
-       for(i=0; i<mali_freq_num - 1 ;i++) {
-               if(freq >= mali_plat_data.clk_sample[i] && freq<=mali_plat_data.clk_sample[i + 1]) {
-                       level = i;
-                       level = mali_freq_num-level - 1;
-               }
-       }
-       return level;
-}
-
-unsigned int get_mali_max_level(void)
-{
-       return mali_plat_data.dvfs_table_size - 1;
-}
-
-static struct resource mali_gpu_resources[] =
-{
-       MALI_GPU_RESOURCES_MALI450_MP6_PMU(IO_MALI_APB_PHY_BASE, INT_MALI_GP, INT_MALI_GP_MMU,
-                               INT_MALI_PP0, INT_MALI_PP0_MMU,
-                               INT_MALI_PP1, INT_MALI_PP1_MMU,
-                               INT_MALI_PP2, INT_MALI_PP2_MMU,
-                               INT_MALI_PP4, INT_MALI_PP4_MMU,
-                               INT_MALI_PP5, INT_MALI_PP5_MMU,
-                               INT_MALI_PP6, INT_MALI_PP6_MMU,
-                               INT_MALI_PP)
-};
-
-static void set_limit_mali_freq(u32 idx)
-{
-       if (mali_plat_data.limit_on == 0)
-               return;
-       if (idx > mali_plat_data.turbo_clock || idx < mali_plat_data.scale_info.minclk)
-               return;
-       mali_plat_data.scale_info.maxclk= idx;
-       revise_mali_rt();
-}
-
-static u32 get_limit_mali_freq(void)
-{
-       return mali_plat_data.scale_info.maxclk;
-}
-
-static u32 set_limit_pp_num(u32 num)
-{
-       u32 ret = -1;
-       if (mali_plat_data.limit_on == 0)
-               goto quit;
-       if (num > mali_plat_data.cfg_pp ||
-                               num < mali_plat_data.scale_info.minpp)
-               goto quit;
-       mali_plat_data.scale_info.maxpp = num;
-       revise_mali_rt();
-       ret = 0;
-quit:
-       return ret;
-}
-
-#ifdef CONFIG_AM_VDEC_H264_4K2K
-static u32 grd_pp_bk = CFG_PP;
-static void mali_4k2k_enter(void)
-{
-       if (mali_plat_data.limit_on == 0)
-               return;
-       grd_pp_bk = mali_plat_data.scale_info.maxpp;
-       set_limit_pp_num(mali_plat_data.scale_info.minpp);
-}
-
-static void mali_4k2k_exit(void)
-{
-       if (mali_plat_data.limit_on == 0)
-               return;
-       set_limit_pp_num(grd_pp_bk);
-}
-
-void vh264_4k2k_register_module_callback(void(*enter_func)(void), void(*remove_func)(void));
-#endif /* CONFIG_AM_VDEC_H264_4K2K */
-
-int mali_meson_init_start(struct platform_device* ptr_plt_dev)
-{
-       /* for mali platform data. */
-       pdev->utilization_callback = mali_gpu_utilization_callback,
-
-       /* for resource data. */
-       ptr_plt_dev->num_resources = ARRAY_SIZE(mali_gpu_resources);
-       ptr_plt_dev->resource = mali_gpu_resources;
-       return mali_clock_init(&mali_plat_data);
-}
-
-int mali_meson_init_finish(struct platform_device* ptr_plt_dev)
-{
-       if (mali_core_scaling_init(&mali_plat_data) < 0)
-               return -1;
-       return 0;
-}
-
-int mali_meson_uninit(struct platform_device* ptr_plt_dev)
-{
-       return 0;
-}
-
-static int mali_cri_light_suspend(size_t param)
-{
-       int ret;
-       struct device *device;
-       struct mali_pmu_core *pmu;
-
-       ret = 0;
-       mali_pm_statue = 1;
-       device = (struct device *)param;
-       pmu = mali_pmu_get_global_pmu_core();
-
-       if (NULL != device->driver &&
-           NULL != device->driver->pm &&
-           NULL != device->driver->pm->runtime_suspend)
-       {
-               /* Need to notify Mali driver about this event */
-               ret = device->driver->pm->runtime_suspend(device);
-       }
-       mali_pmu_power_down_all(pmu);
-       return ret;
-}
-
-static int mali_cri_light_resume(size_t param)
-{
-       int ret;
-       struct device *device;
-       struct mali_pmu_core *pmu;
-
-       ret = 0;
-       device = (struct device *)param;
-       pmu = mali_pmu_get_global_pmu_core();
-
-       mali_pmu_power_up_all(pmu);
-       if (NULL != device->driver &&
-           NULL != device->driver->pm &&
-           NULL != device->driver->pm->runtime_resume)
-       {
-               /* Need to notify Mali driver about this event */
-               ret = device->driver->pm->runtime_resume(device);
-       }
-       mali_pm_statue = 0;
-       return ret;
-}
-
-static int mali_cri_deep_suspend(size_t param)
-{
-       int ret;
-       struct device *device;
-       struct mali_pmu_core *pmu;
-
-       ret = 0;
-       device = (struct device *)param;
-       pmu = mali_pmu_get_global_pmu_core();
-
-       if (NULL != device->driver &&
-           NULL != device->driver->pm &&
-           NULL != device->driver->pm->suspend)
-       {
-               /* Need to notify Mali driver about this event */
-               ret = device->driver->pm->suspend(device);
-       }
-       mali_pmu_power_down_all(pmu);
-       return ret;
-}
-
-static int mali_cri_deep_resume(size_t param)
-{
-       int ret;
-       struct device *device;
-       struct mali_pmu_core *pmu;
-
-       ret = 0;
-       device = (struct device *)param;
-       pmu = mali_pmu_get_global_pmu_core();
-
-       mali_pmu_power_up_all(pmu);
-       if (NULL != device->driver &&
-           NULL != device->driver->pm &&
-           NULL != device->driver->pm->resume)
-       {
-               /* Need to notify Mali driver about this event */
-               ret = device->driver->pm->resume(device);
-       }
-       return ret;
-
-}
-
-int mali_light_suspend(struct device *device)
-{
-       int ret = 0;
-#ifdef CONFIG_MALI400_PROFILING
-       _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
-                                       MALI_PROFILING_EVENT_CHANNEL_GPU |
-                                       MALI_PROFILING_EVENT_REASON_SINGLE_GPU_FREQ_VOLT_CHANGE,
-                                       0, 0,   0,      0,      0);
-#endif
-
-       /* clock scaling. Kasin..*/
-       ret = mali_clock_critical(mali_cri_light_suspend, (size_t)device);
-       disable_clock();
-       return ret;
-}
-
-int mali_light_resume(struct device *device)
-{
-       int ret = 0;
-       enable_clock();
-       ret = mali_clock_critical(mali_cri_light_resume, (size_t)device);
-#ifdef CONFIG_MALI400_PROFILING
-       _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
-                                       MALI_PROFILING_EVENT_CHANNEL_GPU |
-                                       MALI_PROFILING_EVENT_REASON_SINGLE_GPU_FREQ_VOLT_CHANGE,
-                                       get_current_frequency(), 0,     0,      0,      0);
-#endif
-       return ret;
-}
-
-int mali_deep_suspend(struct device *device)
-{
-       int ret = 0;
-
-       mali_pm_statue = 1;
-       enable_clock();
-       flush_scaling_job();
-
-       /* clock scaling off. Kasin... */
-       ret = mali_clock_critical(mali_cri_deep_suspend, (size_t)device);
-       disable_clock();
-       return ret;
-}
-
-int mali_deep_resume(struct device *device)
-{
-       int ret = 0;
-
-       /* clock scaling up. Kasin.. */
-       enable_clock();
-       ret = mali_clock_critical(mali_cri_deep_resume, (size_t)device);
-       mali_pm_statue = 0;
-       return ret;
-
-}
-
-void mali_post_init(void)
-{
-#ifdef CONFIG_GPU_THERMAL
-       int err;
-       struct gpufreq_cooling_device *gcdev = NULL;
-       struct gpucore_cooling_device *gccdev = NULL;
-
-       gcdev = gpufreq_cooling_alloc();
-       register_gpu_freq_info(get_current_frequency);
-       if(IS_ERR(gcdev))
-               printk("malloc gpu cooling buffer error!!\n");
-       else if(!gcdev)
-               printk("system does not enable thermal driver\n");
-       else {
-               gcdev->get_gpu_freq_level = get_mali_freq_level;
-               gcdev->get_gpu_max_level = get_mali_max_level;
-               gcdev->set_gpu_freq_idx = set_limit_mali_freq;
-               gcdev->get_gpu_current_max_level = get_limit_mali_freq;
-               err = gpufreq_cooling_register(gcdev);
-               if(err < 0)
-                       printk("register GPU  cooling error\n");
-               printk("gpu cooling register okay with err=%d\n",err);
-       }
-
-       gccdev=gpucore_cooling_alloc();
-       if(IS_ERR(gccdev))
-               printk("malloc gpu core cooling buffer error!!\n");
-       else if(!gccdev)
-               printk("system does not enable thermal driver\n");
-       else {
-               gccdev->max_gpu_core_num=mali_plat_data.cfg_pp;
-               gccdev->set_max_pp_num=set_limit_pp_num;
-               err = (int)gpucore_cooling_register(gccdev);
-               if(err < 0)
-                       printk("register GPU  cooling error\n");
-               printk("gpu core cooling register okay with err=%d\n",err);
-       }
-#endif
-#ifdef CONFIG_AM_VDEC_H264_4K2K
-       vh264_4k2k_register_module_callback(mali_4k2k_enter, mali_4k2k_exit);
-#endif /* CONFIG_AM_VDEC_H264_4K2K */
-}
index 94a2d36e87670cae91b14021f5bbb28a3951321b..16376c716e8a550cef0597124a158d70fb03646f 100755 (executable)
 #define CFG_MIN_CLOCK 0
 
 /* fclk is 2550Mhz. */
-#define FCLK_DEV3 (6 << 9)             /*      850   Mhz  */
-#define FCLK_DEV4 (5 << 9)             /*      637.5 Mhz  */
-#define FCLK_DEV5 (7 << 9)             /*      510   Mhz  */
-#define FCLK_DEV7 (4 << 9)             /*      364.3 Mhz  */
+#define FCLK_DEV3 (6 << 9)      /*  850   Mhz  */
+#define FCLK_DEV4 (5 << 9)      /*  637.5 Mhz  */
+#define FCLK_DEV5 (7 << 9)      /*  510   Mhz  */
+#define FCLK_DEV7 (4 << 9)      /*  364.3 Mhz  */
 
 static u32 mali_dvfs_clk[] = {
-       FCLK_DEV7 | 1,     /* 182.1 Mhz */
-       FCLK_DEV4 | 1,     /* 318.7 Mhz */
-       FCLK_DEV3 | 1,     /* 425 Mhz */
-       FCLK_DEV5 | 0,     /* 510 Mhz */
-       FCLK_DEV4 | 0,     /* 637.5 Mhz */
+    FCLK_DEV7 | 1,     /* 182.1 Mhz */
+    FCLK_DEV4 | 1,     /* 318.7 Mhz */
+    FCLK_DEV3 | 1,     /* 425 Mhz */
+    FCLK_DEV5 | 0,     /* 510 Mhz */
+    FCLK_DEV4 | 0,     /* 637.5 Mhz */
 };
 
 static u32 mali_dvfs_clk_sample[] = {
-       182,     /* 182.1 Mhz */
-       319,     /* 318.7 Mhz */
-       425,     /* 425 Mhz */
-       510,     /* 510 Mhz */
-       637,     /* 637.5 Mhz */
+    182,     /* 182.1 Mhz */
+    319,     /* 318.7 Mhz */
+    425,     /* 425 Mhz */
+    510,     /* 510 Mhz */
+    637,     /* 637.5 Mhz */
 };
-
+//////////////////////////////////////
+//for dvfs
+struct mali_gpu_clk_item  meson_gpu_clk[]  = {
+    {182,  1150},   /* 182.1 Mhz, 1150mV */
+    {319,  1150},   /* 318.7 Mhz */
+    {425,  1150},   /* 425 Mhz */
+    {510,  1150},   /* 510 Mhz */
+    {637,  1150},   /* 637.5 Mhz */
+};
+struct mali_gpu_clock meson_gpu_clk_info = {
+    .item = meson_gpu_clk,
+    .num_of_steps = ARRAY_SIZE(meson_gpu_clk),
+};
+static int cur_gpu_clk_index = 0;
+//////////////////////////////////////
 static mali_dvfs_threshold_table mali_dvfs_table[]={
-               { 0, 0, 3,  70, 180}, /* for 182.1  */
-               { 1, 1, 3, 108, 205}, /* for 318.7  */
-               { 2, 2, 3, 150, 215}, /* for 425.0  */
-               { 3, 3, 3, 170, 253}, /* for 510.0  */
-               { 4, 4, 3, 230, 255},  /* for 637.5  */
-               { 0, 0, 3,   0,   0}
+    { 0, 0, 3,  30,  80}, /* for 182.1  */
+    { 1, 1, 3,  40, 205}, /* for 318.7  */
+    { 2, 2, 3, 150, 215}, /* for 425.0  */
+    { 3, 3, 3, 170, 253}, /* for 510.0  */
+    { 4, 4, 3, 230, 255},  /* for 637.5  */
+    { 0, 0, 3,   0,   0}
 };
 
 static void mali_plat_preheat(void);
 static mali_plat_info_t mali_plat_data = {
-       .cfg_pp = CFG_PP,  /* number of pp. */
-       .cfg_min_pp = CFG_MIN_PP,
-       .turbo_clock = 4, /* reserved clock src. */
-       .def_clock = 2, /* gpu clock used most of time.*/
-       .cfg_clock = CFG_CLOCK, /* max gpu clock. */
-       .cfg_clock_bkup = CFG_CLOCK,
-       .cfg_min_clock = CFG_MIN_CLOCK,
-
-       .sc_mpp = 3, /* number of pp used most of time.*/
-       .bst_gpu = 210, /* threshold for boosting gpu. */
-       .bst_pp = 160, /* threshold for boosting PP. */
-
-       .clk = mali_dvfs_clk, /* clock source table. */
-       .clk_sample = mali_dvfs_clk_sample, /* freqency table for show. */
-       .clk_len = sizeof(mali_dvfs_clk) / sizeof(mali_dvfs_clk[0]),
-       .have_switch = 1,
-
-       .dvfs_table = mali_dvfs_table, /* DVFS table. */
-       .dvfs_table_size = sizeof(mali_dvfs_table) / sizeof(mali_dvfs_threshold_table),
-
-       .scale_info = {
-               CFG_MIN_PP, /* minpp */
-               CFG_PP, /* maxpp, should be same as cfg_pp */
-               CFG_MIN_CLOCK, /* minclk */
-               CFG_CLOCK, /* maxclk should be same as cfg_clock */
-       },
-
-       .limit_on = 1,
-       .plat_preheat = mali_plat_preheat,
+    .cfg_pp = CFG_PP,  /* number of pp. */
+    .cfg_min_pp = CFG_MIN_PP,
+    .turbo_clock = 4, /* reserved clock src. */
+    .def_clock = 2, /* gpu clock used most of time.*/
+    .cfg_clock = CFG_CLOCK, /* max gpu clock. */
+    .cfg_clock_bkup = CFG_CLOCK,
+    .cfg_min_clock = CFG_MIN_CLOCK,
+
+    .sc_mpp = 3, /* number of pp used most of time.*/
+    .bst_gpu = 210, /* threshold for boosting gpu. */
+    .bst_pp = 160, /* threshold for boosting PP. */
+
+    .clk = mali_dvfs_clk, /* clock source table. */
+    .clk_sample = mali_dvfs_clk_sample, /* freqency table for show. */
+    .clk_len = sizeof(mali_dvfs_clk) / sizeof(mali_dvfs_clk[0]),
+    .have_switch = 1,
+
+    .dvfs_table = mali_dvfs_table, /* DVFS table. */
+    .dvfs_table_size = sizeof(mali_dvfs_table) / sizeof(mali_dvfs_threshold_table),
+
+    .scale_info = {
+        CFG_MIN_PP, /* minpp */
+        CFG_PP, /* maxpp, should be same as cfg_pp */
+        CFG_MIN_CLOCK, /* minclk */
+        CFG_CLOCK, /* maxclk should be same as cfg_clock */
+    },
+
+    .limit_on = 1,
+    .plat_preheat = mali_plat_preheat,
 };
 
 static void mali_plat_preheat(void)
 {
-       u32 pre_fs;
-       u32 clk, pp;
-
-       if (get_mali_schel_mode() != MALI_PP_FS_SCALING)
-               return;
-
-       get_mali_rt_clkpp(&clk, &pp);
-       pre_fs = mali_plat_data.def_clock + 1;
-       if (clk < pre_fs)
-               clk = pre_fs;
-       if (pp < mali_plat_data.sc_mpp)
-               pp = mali_plat_data.sc_mpp;
-       set_mali_rt_clkpp(clk, pp, 1);
+#ifndef CONFIG_MALI_DVFS
+    u32 pre_fs;
+    u32 clk, pp;
+
+    if (get_mali_schel_mode() != MALI_PP_FS_SCALING)
+        return;
+
+    get_mali_rt_clkpp(&clk, &pp);
+    pre_fs = mali_plat_data.def_clock + 1;
+    if (clk < pre_fs)
+        clk = pre_fs;
+    if (pp < mali_plat_data.sc_mpp)
+        pp = mali_plat_data.sc_mpp;
+    set_mali_rt_clkpp(clk, pp, 1);
+#endif
 }
 
 mali_plat_info_t* get_mali_plat_data(void) {
-       return &mali_plat_data;
+    return &mali_plat_data;
 }
 
 int get_mali_freq_level(int freq)
 {
-       int mali_freq_num;
-       int i = 0, level = -1;
-
-       if(freq < 0)
-               return level;
-
-       mali_freq_num = mali_plat_data.dvfs_table_size - 1;
-       if(freq <= mali_plat_data.clk_sample[0])
-               level = mali_freq_num-1;
-       if(freq >= mali_plat_data.clk_sample[mali_freq_num - 1])
-               level = 0;
-       for(i=0; i<mali_freq_num - 1 ;i++) {
-               if(freq >= mali_plat_data.clk_sample[i] && freq<=mali_plat_data.clk_sample[i + 1]) {
-                       level = i;
-                       level = mali_freq_num-level - 1;
-               }
-       }
-       return level;
+    int i = 0, level = -1;
+    int mali_freq_num;
+
+    if (freq < 0)
+        return level;
+
+    mali_freq_num = mali_plat_data.dvfs_table_size - 1;
+    if (freq <= mali_plat_data.clk_sample[0])
+        level = mali_freq_num-1;
+    if (freq >= mali_plat_data.clk_sample[mali_freq_num - 1])
+        level = 0;
+    for (i=0; i<mali_freq_num - 1 ;i++) {
+        if (freq >= mali_plat_data.clk_sample[i] && freq <= mali_plat_data.clk_sample[i + 1]) {
+            level = i;
+            level = mali_freq_num-level - 1;
+        }
+    }
+    return level;
 }
 
 unsigned int get_mali_max_level(void)
 {
-       return mali_plat_data.dvfs_table_size - 1;
+    return mali_plat_data.dvfs_table_size - 1;
 }
 
 static struct resource mali_gpu_resources[] =
 {
-       MALI_GPU_RESOURCES_MALI450_MP6_PMU(IO_MALI_APB_PHY_BASE, INT_MALI_GP, INT_MALI_GP_MMU,
-                               INT_MALI_PP0, INT_MALI_PP0_MMU,
-                               INT_MALI_PP1, INT_MALI_PP1_MMU,
-                               INT_MALI_PP2, INT_MALI_PP2_MMU,
-                               INT_MALI_PP4, INT_MALI_PP4_MMU,
-                               INT_MALI_PP5, INT_MALI_PP5_MMU,
-                               INT_MALI_PP6, INT_MALI_PP6_MMU,
-                               INT_MALI_PP)
+    MALI_GPU_RESOURCES_MALI450_MP6_PMU(IO_MALI_APB_PHY_BASE, INT_MALI_GP, INT_MALI_GP_MMU,
+            INT_MALI_PP0, INT_MALI_PP0_MMU,
+            INT_MALI_PP1, INT_MALI_PP1_MMU,
+            INT_MALI_PP2, INT_MALI_PP2_MMU,
+            INT_MALI_PP4, INT_MALI_PP4_MMU,
+            INT_MALI_PP5, INT_MALI_PP5_MMU,
+            INT_MALI_PP6, INT_MALI_PP6_MMU,
+            INT_MALI_PP)
 };
 
 static void set_limit_mali_freq(u32 idx)
 {
-       if (mali_plat_data.limit_on == 0)
-               return;
-       if (idx > mali_plat_data.turbo_clock || idx < mali_plat_data.scale_info.minclk)
-               return;
-       mali_plat_data.scale_info.maxclk= idx;
-       revise_mali_rt();
+    if (mali_plat_data.limit_on == 0)
+        return;
+    if (idx > mali_plat_data.turbo_clock || idx < mali_plat_data.scale_info.minclk)
+        return;
+    mali_plat_data.scale_info.maxclk= idx;
+    revise_mali_rt();
 }
 
 static u32 get_limit_mali_freq(void)
 {
-       return mali_plat_data.scale_info.maxclk;
+    return mali_plat_data.scale_info.maxclk;
 }
 
 static u32 set_limit_pp_num(u32 num)
 {
-       u32 ret = -1;
-       if (mali_plat_data.limit_on == 0)
-               goto quit;
-       if (num > mali_plat_data.cfg_pp ||
-                               num < mali_plat_data.scale_info.minpp)
-               goto quit;
-       mali_plat_data.scale_info.maxpp = num;
-       revise_mali_rt();
-       ret = 0;
+    u32 ret = -1;
+    if (mali_plat_data.limit_on == 0)
+        goto quit;
+    if (num > mali_plat_data.cfg_pp ||
+            num < mali_plat_data.scale_info.minpp)
+        goto quit;
+    mali_plat_data.scale_info.maxpp = num;
+    revise_mali_rt();
+    ret = 0;
 quit:
-       return ret;
+    return ret;
 }
 
 #ifdef CONFIG_AM_VDEC_H264_4K2K
 static u32 grd_pp_bk = CFG_PP;
 static void mali_4k2k_enter(void)
 {
-       if (mali_plat_data.limit_on == 0)
-               return;
-       grd_pp_bk = mali_plat_data.scale_info.maxpp;
-       set_limit_pp_num(mali_plat_data.scale_info.minpp);
+    if (mali_plat_data.limit_on == 0)
+        return;
+    grd_pp_bk = mali_plat_data.scale_info.maxpp;
+    set_limit_pp_num(mali_plat_data.scale_info.minpp);
 }
 
 static void mali_4k2k_exit(void)
 {
-       if (mali_plat_data.limit_on == 0)
-               return;
-       set_limit_pp_num(grd_pp_bk);
+    if (mali_plat_data.limit_on == 0)
+        return;
+    set_limit_pp_num(grd_pp_bk);
 }
 
 void vh264_4k2k_register_module_callback(void(*enter_func)(void), void(*remove_func)(void));
 #endif /* CONFIG_AM_VDEC_H264_4K2K */
 
+void mali_gpu_utilization_callback(struct mali_gpu_utilization_data *data);
+
+#if 0
+struct mali_gpu_clk_item {
+    unsigned int clock; /* unit(MHz) */
+    unsigned int vol;
+};
+
+struct mali_gpu_clock {
+    struct mali_gpu_clk_item *item;
+    unsigned int num_of_steps;
+};
+#endif
+
+/* Function that platfrom report it's clock info which driver can set, needed when CONFIG_MALI_DVFS enabled */
+void meson_platform_get_clock_info(struct mali_gpu_clock **data) {
+    *data = &meson_gpu_clk_info;
+}
+
+/* Function that get the current clock info, needed when CONFIG_MALI_DVFS enabled */
+int meson_platform_get_freq(void) {
+    printk("get cur_gpu_clk_index =%d\n", cur_gpu_clk_index);
+    return  cur_gpu_clk_index;
+}
+
+/* Fuction that platform callback for freq setting, needed when CONFIG_MALI_DVFS enabled */
+int meson_platform_set_freq(int setting_clock_step) {
+
+    if (cur_gpu_clk_index == setting_clock_step) {
+        return 0;
+    }
+
+    mali_clock_set(setting_clock_step);
+
+    cur_gpu_clk_index = setting_clock_step;
+    printk("set cur_gpu_clk_index =%d\n", cur_gpu_clk_index);
+
+    return 0;
+}
+
 int mali_meson_init_start(struct platform_device* ptr_plt_dev)
 {
-       /* chip mark detect. */
+    struct mali_gpu_device_data* pdev = ptr_plt_dev->dev.platform_data;
+
+    /* chip mark detect. */
 #ifdef IS_MESON_M8_CPU
-       if(IS_MESON_M8_CPU) {
-               mali_plat_data.have_switch = 0;
-       }
+    if (IS_MESON_M8_CPU) {
+        mali_plat_data.have_switch = 0;
+    }
+#endif
+
+    /* for resource data. */
+    ptr_plt_dev->num_resources = ARRAY_SIZE(mali_gpu_resources);
+    ptr_plt_dev->resource = mali_gpu_resources;
+
+    /*for dvfs*/
+#ifndef CONFIG_MALI_DVFS
+    /* for mali platform data. */
+    pdev->control_interval = 300;
+    pdev->utilization_callback = mali_gpu_utilization_callback;
+#else
+    pdev->get_clock_info = meson_platform_get_clock_info;
+    pdev->get_freq = meson_platform_get_freq;
+    pdev->set_freq = meson_platform_set_freq;
 #endif
 
-       /* for resource data. */
-       ptr_plt_dev->num_resources = ARRAY_SIZE(mali_gpu_resources);
-       ptr_plt_dev->resource = mali_gpu_resources;
-       return mali_clock_init(&mali_plat_data);
+    return mali_clock_init(&mali_plat_data);
 }
 
 int mali_meson_init_finish(struct platform_device* ptr_plt_dev)
 {
-       if (mali_core_scaling_init(&mali_plat_data) < 0)
-               return -1;
-       return 0;
+#ifndef CONFIG_MALI_DVFS
+    if (mali_core_scaling_init(&mali_plat_data) < 0)
+        return -1;
+#else
+    printk("disable meson own dvfs\n");
+#endif
+    return 0;
 }
 
 int mali_meson_uninit(struct platform_device* ptr_plt_dev)
 {
-       return 0;
+    return 0;
 }
 
 static int mali_cri_light_suspend(size_t param)
 {
-       int ret;
-       struct device *device;
-       struct mali_pmu_core *pmu;
-
-       ret = 0;
-       mali_pm_statue = 1;
-       device = (struct device *)param;
-       pmu = mali_pmu_get_global_pmu_core();
-
-       if (NULL != device->driver &&
-           NULL != device->driver->pm &&
-           NULL != device->driver->pm->runtime_suspend)
-       {
-               /* Need to notify Mali driver about this event */
-               ret = device->driver->pm->runtime_suspend(device);
-       }
-       mali_pmu_power_down_all(pmu);
-       return ret;
+    int ret;
+    struct device *device;
+    struct mali_pmu_core *pmu;
+
+    ret = 0;
+    mali_pm_statue = 1;
+    device = (struct device *)param;
+    pmu = mali_pmu_get_global_pmu_core();
+
+    if (NULL != device->driver &&
+            NULL != device->driver->pm &&
+            NULL != device->driver->pm->runtime_suspend)
+    {
+        /* Need to notify Mali driver about this event */
+        ret = device->driver->pm->runtime_suspend(device);
+    }
+    mali_pmu_power_down_all(pmu);
+    return ret;
 }
 
 static int mali_cri_light_resume(size_t param)
 {
-       int ret;
-       struct device *device;
-       struct mali_pmu_core *pmu;
-
-       ret = 0;
-       device = (struct device *)param;
-       pmu = mali_pmu_get_global_pmu_core();
-
-       mali_pmu_power_up_all(pmu);
-       if (NULL != device->driver &&
-           NULL != device->driver->pm &&
-           NULL != device->driver->pm->runtime_resume)
-       {
-               /* Need to notify Mali driver about this event */
-               ret = device->driver->pm->runtime_resume(device);
-       }
-       mali_pm_statue = 0;
-       return ret;
+    int ret;
+    struct device *device;
+    struct mali_pmu_core *pmu;
+
+    ret = 0;
+    device = (struct device *)param;
+    pmu = mali_pmu_get_global_pmu_core();
+
+    mali_pmu_power_up_all(pmu);
+    if (NULL != device->driver &&
+            NULL != device->driver->pm &&
+            NULL != device->driver->pm->runtime_resume)
+    {
+        /* Need to notify Mali driver about this event */
+        ret = device->driver->pm->runtime_resume(device);
+    }
+    mali_pm_statue = 0;
+    return ret;
 }
 
 static int mali_cri_deep_suspend(size_t param)
 {
-       int ret;
-       struct device *device;
-       struct mali_pmu_core *pmu;
-
-       ret = 0;
-       device = (struct device *)param;
-       pmu = mali_pmu_get_global_pmu_core();
-
-       if (NULL != device->driver &&
-           NULL != device->driver->pm &&
-           NULL != device->driver->pm->suspend)
-       {
-               /* Need to notify Mali driver about this event */
-               ret = device->driver->pm->suspend(device);
-       }
-       mali_pmu_power_down_all(pmu);
-       return ret;
+    int ret;
+    struct device *device;
+    struct mali_pmu_core *pmu;
+
+    ret = 0;
+    device = (struct device *)param;
+    pmu = mali_pmu_get_global_pmu_core();
+
+    if (NULL != device->driver &&
+            NULL != device->driver->pm &&
+            NULL != device->driver->pm->suspend)
+    {
+        /* Need to notify Mali driver about this event */
+        ret = device->driver->pm->suspend(device);
+    }
+    mali_pmu_power_down_all(pmu);
+    return ret;
 }
 
 static int mali_cri_deep_resume(size_t param)
 {
-       int ret;
-       struct device *device;
-       struct mali_pmu_core *pmu;
-
-       ret = 0;
-       device = (struct device *)param;
-       pmu = mali_pmu_get_global_pmu_core();
-
-       mali_pmu_power_up_all(pmu);
-       if (NULL != device->driver &&
-           NULL != device->driver->pm &&
-           NULL != device->driver->pm->resume)
-       {
-               /* Need to notify Mali driver about this event */
-               ret = device->driver->pm->resume(device);
-       }
-       return ret;
+    int ret;
+    struct device *device;
+    struct mali_pmu_core *pmu;
+
+    ret = 0;
+    device = (struct device *)param;
+    pmu = mali_pmu_get_global_pmu_core();
+
+    mali_pmu_power_up_all(pmu);
+    if (NULL != device->driver &&
+            NULL != device->driver->pm &&
+            NULL != device->driver->pm->resume)
+    {
+        /* Need to notify Mali driver about this event */
+        ret = device->driver->pm->resume(device);
+    }
+    return ret;
 
 }
 
 int mali_light_suspend(struct device *device)
 {
-       int ret = 0;
+    int ret = 0;
 #ifdef CONFIG_MALI400_PROFILING
-       _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
-                                       MALI_PROFILING_EVENT_CHANNEL_GPU |
-                                       MALI_PROFILING_EVENT_REASON_SINGLE_GPU_FREQ_VOLT_CHANGE,
-                                       0, 0,   0,      0,      0);
+    _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
+            MALI_PROFILING_EVENT_CHANNEL_GPU |
+            MALI_PROFILING_EVENT_REASON_SINGLE_GPU_FREQ_VOLT_CHANGE,
+            0, 0, 0, 0, 0);
 #endif
 
-       /* clock scaling. Kasin..*/
-       ret = mali_clock_critical(mali_cri_light_suspend, (size_t)device);
-       disable_clock();
-       return ret;
+    /* clock scaling. Kasin..*/
+    ret = mali_clock_critical(mali_cri_light_suspend, (size_t)device);
+    disable_clock();
+    return ret;
 }
 
 int mali_light_resume(struct device *device)
 {
-       int ret = 0;
-       enable_clock();
-       ret = mali_clock_critical(mali_cri_light_resume, (size_t)device);
+    int ret = 0;
+    enable_clock();
+    ret = mali_clock_critical(mali_cri_light_resume, (size_t)device);
 #ifdef CONFIG_MALI400_PROFILING
-       _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
-                                       MALI_PROFILING_EVENT_CHANNEL_GPU |
-                                       MALI_PROFILING_EVENT_REASON_SINGLE_GPU_FREQ_VOLT_CHANGE,
-                                       get_current_frequency(), 0,     0,      0,      0);
+    _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
+            MALI_PROFILING_EVENT_CHANNEL_GPU |
+            MALI_PROFILING_EVENT_REASON_SINGLE_GPU_FREQ_VOLT_CHANGE,
+            get_current_frequency(), 0, 0, 0, 0);
 #endif
-       return ret;
+    return ret;
 }
 
 int mali_deep_suspend(struct device *device)
 {
-       int ret = 0;
+    int ret = 0;
 
-       mali_pm_statue = 1;
-       enable_clock();
-       flush_scaling_job();
+    mali_pm_statue = 1;
+    enable_clock();
+#ifndef CONFIG_MALI_DVFS
+    flush_scaling_job();
+#endif
 
-       /* clock scaling off. Kasin... */
-       ret = mali_clock_critical(mali_cri_deep_suspend, (size_t)device);
-       disable_clock();
-       return ret;
+    /* clock scaling off. Kasin... */
+    ret = mali_clock_critical(mali_cri_deep_suspend, (size_t)device);
+    disable_clock();
+    return ret;
 }
 
 int mali_deep_resume(struct device *device)
 {
-       int ret = 0;
+    int ret = 0;
 
-       /* clock scaling up. Kasin.. */
-       enable_clock();
-       ret = mali_clock_critical(mali_cri_deep_resume, (size_t)device);
-       mali_pm_statue = 0;
-       return ret;
+    /* clock scaling up. Kasin.. */
+    enable_clock();
+    ret = mali_clock_critical(mali_cri_deep_resume, (size_t)device);
+    mali_pm_statue = 0;
+    return ret;
 
 }
 
 void mali_post_init(void)
 {
 #ifdef CONFIG_GPU_THERMAL
-       int err;
-       struct gpufreq_cooling_device *gcdev = NULL;
-       struct gpucore_cooling_device *gccdev = NULL;
-
-       gcdev = gpufreq_cooling_alloc();
-       register_gpu_freq_info(get_current_frequency);
-       if(IS_ERR(gcdev))
-               printk("malloc gpu cooling buffer error!!\n");
-       else if(!gcdev)
-               printk("system does not enable thermal driver\n");
-       else {
-               gcdev->get_gpu_freq_level = get_mali_freq_level;
-               gcdev->get_gpu_max_level = get_mali_max_level;
-               gcdev->set_gpu_freq_idx = set_limit_mali_freq;
-               gcdev->get_gpu_current_max_level = get_limit_mali_freq;
-               err = gpufreq_cooling_register(gcdev);
-               if(err < 0)
-                       printk("register GPU  cooling error\n");
-               printk("gpu cooling register okay with err=%d\n",err);
-       }
-
-       gccdev=gpucore_cooling_alloc();
-       if(IS_ERR(gccdev))
-               printk("malloc gpu core cooling buffer error!!\n");
-       else if(!gccdev)
-               printk("system does not enable thermal driver\n");
-       else {
-               gccdev->max_gpu_core_num=mali_plat_data.cfg_pp;
-               gccdev->set_max_pp_num=set_limit_pp_num;
-               err = (int)gpucore_cooling_register(gccdev);
-               if(err < 0)
-                       printk("register GPU  cooling error\n");
-               printk("gpu core cooling register okay with err=%d\n",err);
-       }
+    int err;
+    struct gpufreq_cooling_device *gcdev = NULL;
+    struct gpucore_cooling_device *gccdev = NULL;
+
+    gcdev = gpufreq_cooling_alloc();
+    register_gpu_freq_info(get_current_frequency);
+    if (IS_ERR(gcdev))
+        printk("malloc gpu cooling buffer error!!\n");
+    else if (!gcdev)
+        printk("system does not enable thermal driver\n");
+    else {
+        gcdev->get_gpu_freq_level = get_mali_freq_level;
+        gcdev->get_gpu_max_level = get_mali_max_level;
+        gcdev->set_gpu_freq_idx = set_limit_mali_freq;
+        gcdev->get_gpu_current_max_level = get_limit_mali_freq;
+        err = gpufreq_cooling_register(gcdev);
+        if (err < 0)
+            printk("register GPU  cooling error\n");
+        printk("gpu cooling register okay with err=%d\n",err);
+    }
+
+    gccdev = gpucore_cooling_alloc();
+    if (IS_ERR(gccdev))
+        printk("malloc gpu core cooling buffer error!!\n");
+    else if (!gccdev)
+        printk("system does not enable thermal driver\n");
+    else {
+        gccdev->max_gpu_core_num=mali_plat_data.cfg_pp;
+        gccdev->set_max_pp_num=set_limit_pp_num;
+        err = (int)gpucore_cooling_register(gccdev);
+        if (err < 0)
+            printk("register GPU  cooling error\n");
+        printk("gpu core cooling register okay with err=%d\n",err);
+    }
 #endif
 #ifdef CONFIG_AM_VDEC_H264_4K2K
-       vh264_4k2k_register_module_callback(mali_4k2k_enter, mali_4k2k_exit);
+    vh264_4k2k_register_module_callback(mali_4k2k_enter, mali_4k2k_exit);
 #endif /* CONFIG_AM_VDEC_H264_4K2K */
 }
index 2514a4df9a9249e3253e3404e2efac41d68e472c..c9af127c6b353e9560fa74fb639135da28d941bc 100755 (executable)
 #define CFG_MIN_CLOCK 0
 
 /* fclk is 2550Mhz. */
-#define FCLK_DEV3 (6 << 9)             /*      850   Mhz  */
-#define FCLK_DEV4 (5 << 9)             /*      637.5 Mhz  */
-#define FCLK_DEV5 (7 << 9)             /*      510   Mhz  */
-#define FCLK_DEV7 (4 << 9)             /*      364.3 Mhz  */
+#define FCLK_DEV3 (6 << 9)      /*  850   Mhz  */
+#define FCLK_DEV4 (5 << 9)      /*  637.5 Mhz  */
+#define FCLK_DEV5 (7 << 9)      /*  510   Mhz  */
+#define FCLK_DEV7 (4 << 9)      /*  364.3 Mhz  */
 
 static u32 mali_dvfs_clk[] = {
-       FCLK_DEV5 | 1,     /* 255 Mhz */
-       FCLK_DEV7 | 0,     /* 364 Mhz */
-       FCLK_DEV3 | 1,     /* 425 Mhz */
-       FCLK_DEV5 | 0,     /* 510 Mhz */
-       FCLK_DEV4 | 0,     /* 637.5 Mhz */
+    FCLK_DEV5 | 1,     /* 255 Mhz */
+    FCLK_DEV7 | 0,     /* 364 Mhz */
+    FCLK_DEV3 | 1,     /* 425 Mhz */
+    FCLK_DEV5 | 0,     /* 510 Mhz */
+    FCLK_DEV4 | 0,     /* 637.5 Mhz */
 };
 
 static u32 mali_dvfs_clk_sample[] = {
-       255,     /* 182.1 Mhz */
-       364,     /* 318.7 Mhz */
-       425,     /* 425 Mhz */
-       510,     /* 510 Mhz */
-       637,     /* 637.5 Mhz */
+    255,     /* 182.1 Mhz */
+    364,     /* 318.7 Mhz */
+    425,     /* 425 Mhz */
+    510,     /* 510 Mhz */
+    637,     /* 637.5 Mhz */
 };
 
+//////////////////////////////////////
+//for dvfs
+struct mali_gpu_clk_item  meson_gpu_clk[]  = {
+    {255,  1150},   /* 182.1 Mhz, 1150mV */
+    {364,  1150},   /* 318.7 Mhz */
+    {425,  1150},   /* 425 Mhz */
+    {510,  1150},   /* 510 Mhz */
+    {637,  1150},   /* 637.5 Mhz */
+};
+struct mali_gpu_clock meson_gpu_clk_info = {
+    .item = meson_gpu_clk,
+    .num_of_steps = ARRAY_SIZE(meson_gpu_clk),
+};
+static int cur_gpu_clk_index = 0;
+//////////////////////////////////////
+
 static mali_dvfs_threshold_table mali_dvfs_table[]={
-               { 0, 0, 5, 0  , 180}, /* for 255  */
-               { 1, 1, 5, 152, 205}, /* for 364  */
-               { 2, 2, 5, 180, 212}, /* for 425  */
-               { 3, 3, 5, 205, 236}, /* for 510  */
-               { 4, 4, 5, 230, 255}, /* for 637  */
-               { 0, 0, 5,   0,   0}
+    { 0, 0, 5, 30 , 180}, /* for 255  */
+    { 1, 1, 5, 152, 205}, /* for 364  */
+    { 2, 2, 5, 180, 212}, /* for 425  */
+    { 3, 3, 5, 205, 236}, /* for 510  */
+    { 4, 4, 5, 230, 255}, /* for 637  */
+    { 0, 0, 5,   0,   0}
 };
 
 static void mali_plat_preheat(void);
 static mali_plat_info_t mali_plat_data = {
-       .cfg_pp = CFG_PP,  /* number of pp. */
-       .cfg_min_pp = CFG_MIN_PP,
-       .turbo_clock = 4, /* reserved clock src. */
-       .def_clock = 2, /* gpu clock used most of time.*/
-       .cfg_clock = CFG_CLOCK, /* max gpu clock. */
-       .cfg_clock_bkup = CFG_CLOCK,
-       .cfg_min_clock = CFG_MIN_CLOCK,
-
-       .sc_mpp = 2, /* number of pp used most of time.*/
-       .bst_gpu = 210, /* threshold for boosting gpu. */
-       .bst_pp = 160, /* threshold for boosting PP. */
-
-       .clk = mali_dvfs_clk, /* clock source table. */
-       .clk_sample = mali_dvfs_clk_sample, /* freqency table for show. */
-       .clk_len = sizeof(mali_dvfs_clk) / sizeof(mali_dvfs_clk[0]),
-       .have_switch = 1,
-
-       .dvfs_table = mali_dvfs_table, /* DVFS table. */
-       .dvfs_table_size = sizeof(mali_dvfs_table) / sizeof(mali_dvfs_threshold_table),
-
-       .scale_info = {
-               CFG_MIN_PP, /* minpp */
-               CFG_PP, /* maxpp, should be same as cfg_pp */
-               CFG_MIN_CLOCK, /* minclk */
-               CFG_CLOCK, /* maxclk should be same as cfg_clock */
-       },
-
-       .limit_on = 1,
-       .plat_preheat = mali_plat_preheat,
+    .cfg_pp = CFG_PP,  /* number of pp. */
+    .cfg_min_pp = CFG_MIN_PP,
+    .turbo_clock = 4, /* reserved clock src. */
+    .def_clock = 2, /* gpu clock used most of time.*/
+    .cfg_clock = CFG_CLOCK, /* max gpu clock. */
+    .cfg_clock_bkup = CFG_CLOCK,
+    .cfg_min_clock = CFG_MIN_CLOCK,
+
+    .sc_mpp = 2, /* number of pp used most of time.*/
+    .bst_gpu = 210, /* threshold for boosting gpu. */
+    .bst_pp = 160, /* threshold for boosting PP. */
+
+    .clk = mali_dvfs_clk, /* clock source table. */
+    .clk_sample = mali_dvfs_clk_sample, /* freqency table for show. */
+    .clk_len = sizeof(mali_dvfs_clk) / sizeof(mali_dvfs_clk[0]),
+    .have_switch = 1,
+
+    .dvfs_table = mali_dvfs_table, /* DVFS table. */
+    .dvfs_table_size = sizeof(mali_dvfs_table) / sizeof(mali_dvfs_threshold_table),
+
+    .scale_info = {
+        CFG_MIN_PP, /* minpp */
+        CFG_PP, /* maxpp, should be same as cfg_pp */
+        CFG_MIN_CLOCK, /* minclk */
+        CFG_CLOCK, /* maxclk should be same as cfg_clock */
+    },
+
+    .limit_on = 1,
+    .plat_preheat = mali_plat_preheat,
 };
 
 static void mali_plat_preheat(void)
 {
-       u32 pre_fs;
-       u32 clk, pp;
-
-       if (get_mali_schel_mode() != MALI_PP_FS_SCALING)
-               return;
-
-       get_mali_rt_clkpp(&clk, &pp);
-       pre_fs = mali_plat_data.def_clock + 1;
-       if (clk < pre_fs)
-               clk = pre_fs;
-       if (pp < mali_plat_data.sc_mpp)
-               pp = mali_plat_data.sc_mpp;
-       set_mali_rt_clkpp(clk, pp, 1);
+#ifndef CONFIG_MALI_DVFS
+    u32 pre_fs;
+    u32 clk, pp;
+
+    if (get_mali_schel_mode() != MALI_PP_FS_SCALING)
+        return;
+
+    get_mali_rt_clkpp(&clk, &pp);
+    pre_fs = mali_plat_data.def_clock + 1;
+    if (clk < pre_fs)
+        clk = pre_fs;
+    if (pp < mali_plat_data.sc_mpp)
+        pp = mali_plat_data.sc_mpp;
+    set_mali_rt_clkpp(clk, pp, 1);
+#endif
 }
 
 mali_plat_info_t* get_mali_plat_data(void) {
-       return &mali_plat_data;
+    return &mali_plat_data;
 }
 
 int get_mali_freq_level(int freq)
 {
-       int i = 0, level = -1;
-       int mali_freq_num;
-
-       if(freq < 0)
-               return level;
-       mali_freq_num = mali_plat_data.dvfs_table_size - 1;
-       if(freq <= mali_plat_data.clk_sample[0])
-               level = mali_freq_num-1;
-       if(freq >= mali_plat_data.clk_sample[mali_freq_num - 1])
-               level = 0;
-       for(i=0; i<mali_freq_num - 1 ;i++) {
-               if(freq >= mali_plat_data.clk_sample[i] && freq<=mali_plat_data.clk_sample[i + 1]) {
-                       level = i;
-                       level = mali_freq_num-level - 1;
-               }
-       }
-       return level;
+    int i = 0, level = -1;
+    int mali_freq_num;
+
+    if (freq < 0)
+        return level;
+    mali_freq_num = mali_plat_data.dvfs_table_size - 1;
+    if (freq <= mali_plat_data.clk_sample[0])
+        level = mali_freq_num-1;
+    if (freq >= mali_plat_data.clk_sample[mali_freq_num - 1])
+        level = 0;
+    for (i=0; i<mali_freq_num - 1 ;i++) {
+        if (freq >= mali_plat_data.clk_sample[i] && freq <= mali_plat_data.clk_sample[i + 1]) {
+            level = i;
+            level = mali_freq_num-level - 1;
+        }
+    }
+    return level;
 }
 
 unsigned int get_mali_max_level(void)
 {
-       return mali_plat_data.dvfs_table_size - 1;
+    return mali_plat_data.dvfs_table_size - 1;
 }
 
 static struct resource mali_gpu_resources[] =
 {
-       MALI_GPU_RESOURCES_MALI450_MP2_PMU(IO_MALI_APB_PHY_BASE, INT_MALI_GP, INT_MALI_GP_MMU, 
-                               INT_MALI_PP0, INT_MALI_PP0_MMU,
-                               INT_MALI_PP1, INT_MALI_PP1_MMU,
-                               INT_MALI_PP)
+    MALI_GPU_RESOURCES_MALI450_MP2_PMU(IO_MALI_APB_PHY_BASE, INT_MALI_GP, INT_MALI_GP_MMU,
+            INT_MALI_PP0, INT_MALI_PP0_MMU,
+            INT_MALI_PP1, INT_MALI_PP1_MMU,
+            INT_MALI_PP)
 };
 
 static void set_limit_mali_freq(u32 idx)
 {
-       if (mali_plat_data.limit_on == 0)
-               return;
-       if (idx > mali_plat_data.turbo_clock || idx < mali_plat_data.scale_info.minclk)
-               return;
-       mali_plat_data.scale_info.maxclk= idx;
+    if (mali_plat_data.limit_on == 0)
+        return;
+    if (idx > mali_plat_data.turbo_clock || idx < mali_plat_data.scale_info.minclk)
+        return;
+    mali_plat_data.scale_info.maxclk= idx;
 
-       revise_mali_rt();
+    revise_mali_rt();
 }
 
 static u32 get_limit_mali_freq(void)
 {
-       return mali_plat_data.scale_info.maxclk;
+    return mali_plat_data.scale_info.maxclk;
 }
 
 static u32 set_limit_pp_num(u32 num)
 {
-       u32 ret = -1;
-       if (mali_plat_data.limit_on == 0)
-               goto quit;
-       if (num > mali_plat_data.cfg_pp ||
-                               num < mali_plat_data.scale_info.minpp)
-               goto quit;
-       mali_plat_data.scale_info.maxpp = num;
-       revise_mali_rt();
-       ret = 0;
+    u32 ret = -1;
+    if (mali_plat_data.limit_on == 0)
+        goto quit;
+    if (num > mali_plat_data.cfg_pp ||
+            num < mali_plat_data.scale_info.minpp)
+        goto quit;
+    mali_plat_data.scale_info.maxpp = num;
+    revise_mali_rt();
+    ret = 0;
 quit:
-       return ret;
+    return ret;
+}
+
+void mali_gpu_utilization_callback(struct mali_gpu_utilization_data *data);
+
+#if 0
+struct mali_gpu_clk_item {
+    unsigned int clock; /* unit(MHz) */
+    unsigned int vol;
+};
+
+struct mali_gpu_clock {
+    struct mali_gpu_clk_item *item;
+    unsigned int num_of_steps;
+};
+#endif
+
+/* Function that platfrom report it's clock info which driver can set, needed when CONFIG_MALI_DVFS enabled */
+void meson_platform_get_clock_info(struct mali_gpu_clock **data) {
+    *data = &meson_gpu_clk_info;
 }
 
+/* Function that get the current clock info, needed when CONFIG_MALI_DVFS enabled */
+int meson_platform_get_freq(void) {
+    printk("get cur_gpu_clk_index =%d\n", cur_gpu_clk_index);
+    return  cur_gpu_clk_index;
+}
+
+/* Fuction that platform callback for freq setting, needed when CONFIG_MALI_DVFS enabled */
+int meson_platform_set_freq(int setting_clock_step) {
+
+    if (cur_gpu_clk_index == setting_clock_step) {
+        return 0;
+    }
+
+    mali_clock_set(setting_clock_step);
+
+    cur_gpu_clk_index = setting_clock_step;
+    printk("set cur_gpu_clk_index =%d\n", cur_gpu_clk_index);
+
+    return 0;
+}
 int mali_meson_init_start(struct platform_device* ptr_plt_dev)
 {
-       /* for resource data. */
-       ptr_plt_dev->num_resources = ARRAY_SIZE(mali_gpu_resources);
-       ptr_plt_dev->resource = mali_gpu_resources;
-       return mali_clock_init(&mali_plat_data);
+    struct mali_gpu_device_data* pdev = ptr_plt_dev->dev.platform_data;
+
+
+    /* for resource data. */
+    ptr_plt_dev->num_resources = ARRAY_SIZE(mali_gpu_resources);
+    ptr_plt_dev->resource = mali_gpu_resources;
+
+    /*for dvfs*/
+#ifndef CONFIG_MALI_DVFS
+    /* for mali platform data. */
+    pdev->control_interval = 300;
+    pdev->utilization_callback = mali_gpu_utilization_callback;
+#else
+    pdev->get_clock_info = meson_platform_get_clock_info;
+    pdev->get_freq = meson_platform_get_freq;
+    pdev->set_freq = meson_platform_set_freq;
+#endif
+
+    return mali_clock_init(&mali_plat_data);
 }
 
 int mali_meson_init_finish(struct platform_device* ptr_plt_dev)
 {
-       if (mali_core_scaling_init(&mali_plat_data) < 0)
-               return -1;
-       return 0;
+#ifndef CONFIG_MALI_DVFS
+    if (mali_core_scaling_init(&mali_plat_data) < 0)
+        return -1;
+#endif
+    return 0;
 }
 
 int mali_meson_uninit(struct platform_device* ptr_plt_dev)
 {
-       return 0;
+    return 0;
 }
 
 static int mali_cri_light_suspend(size_t param)
 {
-       int ret;
-       struct device *device;
-       struct mali_pmu_core *pmu;
-
-       ret = 0;
-       mali_pm_statue = 1;
-       device = (struct device *)param;
-       pmu = mali_pmu_get_global_pmu_core();
-
-       if (NULL != device->driver &&
-           NULL != device->driver->pm &&
-           NULL != device->driver->pm->runtime_suspend)
-       {
-               /* Need to notify Mali driver about this event */
-               ret = device->driver->pm->runtime_suspend(device);
-       }
-       mali_pmu_power_down_all(pmu);
-       return ret;
+    int ret;
+    struct device *device;
+    struct mali_pmu_core *pmu;
+
+    ret = 0;
+    mali_pm_statue = 1;
+    device = (struct device *)param;
+    pmu = mali_pmu_get_global_pmu_core();
+
+    if (NULL != device->driver &&
+            NULL != device->driver->pm &&
+            NULL != device->driver->pm->runtime_suspend)
+    {
+        /* Need to notify Mali driver about this event */
+        ret = device->driver->pm->runtime_suspend(device);
+    }
+    mali_pmu_power_down_all(pmu);
+    return ret;
 }
 
 static int mali_cri_light_resume(size_t param)
 {
-       int ret;
-       struct device *device;
-       struct mali_pmu_core *pmu;
-
-       ret = 0;
-       device = (struct device *)param;
-       pmu = mali_pmu_get_global_pmu_core();
-
-       mali_pmu_power_up_all(pmu);
-       if (NULL != device->driver &&
-           NULL != device->driver->pm &&
-           NULL != device->driver->pm->runtime_resume)
-       {
-               /* Need to notify Mali driver about this event */
-               ret = device->driver->pm->runtime_resume(device);
-       }
-       mali_pm_statue = 0;
-       return ret;
+    int ret;
+    struct device *device;
+    struct mali_pmu_core *pmu;
+
+    ret = 0;
+    device = (struct device *)param;
+    pmu = mali_pmu_get_global_pmu_core();
+
+    mali_pmu_power_up_all(pmu);
+    if (NULL != device->driver &&
+            NULL != device->driver->pm &&
+            NULL != device->driver->pm->runtime_resume)
+    {
+        /* Need to notify Mali driver about this event */
+        ret = device->driver->pm->runtime_resume(device);
+    }
+    mali_pm_statue = 0;
+    return ret;
 }
 
 static int mali_cri_deep_suspend(size_t param)
 {
-       int ret;
-       struct device *device;
-       struct mali_pmu_core *pmu;
-
-       ret = 0;
-       device = (struct device *)param;
-       pmu = mali_pmu_get_global_pmu_core();
-
-       if (NULL != device->driver &&
-           NULL != device->driver->pm &&
-           NULL != device->driver->pm->suspend)
-       {
-               /* Need to notify Mali driver about this event */
-               ret = device->driver->pm->suspend(device);
-       }
-       mali_pmu_power_down_all(pmu);
-       return ret;
+    int ret;
+    struct device *device;
+    struct mali_pmu_core *pmu;
+
+    ret = 0;
+    device = (struct device *)param;
+    pmu = mali_pmu_get_global_pmu_core();
+
+    if (NULL != device->driver &&
+            NULL != device->driver->pm &&
+            NULL != device->driver->pm->suspend)
+    {
+        /* Need to notify Mali driver about this event */
+        ret = device->driver->pm->suspend(device);
+    }
+    mali_pmu_power_down_all(pmu);
+    return ret;
 }
 
 static int mali_cri_deep_resume(size_t param)
 {
-       int ret;
-       struct device *device;
-       struct mali_pmu_core *pmu;
-
-       ret = 0;
-       device = (struct device *)param;
-       pmu = mali_pmu_get_global_pmu_core();
-
-       mali_pmu_power_up_all(pmu);
-       if (NULL != device->driver &&
-           NULL != device->driver->pm &&
-           NULL != device->driver->pm->resume)
-       {
-               /* Need to notify Mali driver about this event */
-               ret = device->driver->pm->resume(device);
-       }
-       return ret;
+    int ret;
+    struct device *device;
+    struct mali_pmu_core *pmu;
+
+    ret = 0;
+    device = (struct device *)param;
+    pmu = mali_pmu_get_global_pmu_core();
+
+    mali_pmu_power_up_all(pmu);
+    if (NULL != device->driver &&
+            NULL != device->driver->pm &&
+            NULL != device->driver->pm->resume)
+    {
+        /* Need to notify Mali driver about this event */
+        ret = device->driver->pm->resume(device);
+    }
+    return ret;
 
 }
 
 int mali_light_suspend(struct device *device)
 {
-       int ret = 0;
+    int ret = 0;
 #ifdef CONFIG_MALI400_PROFILING
-       _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
-                                       MALI_PROFILING_EVENT_CHANNEL_GPU |
-                                       MALI_PROFILING_EVENT_REASON_SINGLE_GPU_FREQ_VOLT_CHANGE,
-                                       0, 0,   0,      0,      0);
+    _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
+            MALI_PROFILING_EVENT_CHANNEL_GPU |
+            MALI_PROFILING_EVENT_REASON_SINGLE_GPU_FREQ_VOLT_CHANGE,
+            0, 0, 0, 0, 0);
 #endif
 
-       /* clock scaling. Kasin..*/
-       ret = mali_clock_critical(mali_cri_light_suspend, (size_t)device);
-       disable_clock();
-       return ret;
+    /* clock scaling. Kasin..*/
+    ret = mali_clock_critical(mali_cri_light_suspend, (size_t)device);
+    disable_clock();
+    return ret;
 }
 
 int mali_light_resume(struct device *device)
 {
-       int ret = 0;
-       enable_clock();
-       ret = mali_clock_critical(mali_cri_light_resume, (size_t)device);
+    int ret = 0;
+    enable_clock();
+    ret = mali_clock_critical(mali_cri_light_resume, (size_t)device);
 #ifdef CONFIG_MALI400_PROFILING
-       _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
-                                       MALI_PROFILING_EVENT_CHANNEL_GPU |
-                                       MALI_PROFILING_EVENT_REASON_SINGLE_GPU_FREQ_VOLT_CHANGE,
-                                       get_current_frequency(), 0,     0,      0,      0);
+    _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
+            MALI_PROFILING_EVENT_CHANNEL_GPU |
+            MALI_PROFILING_EVENT_REASON_SINGLE_GPU_FREQ_VOLT_CHANGE,
+            get_current_frequency(), 0, 0, 0, 0);
 #endif
-       return ret;
+    return ret;
 }
 
 int mali_deep_suspend(struct device *device)
 {
-       int ret = 0;
-       struct mali_pmu_core *pmu;
-
-       mali_pm_statue = 1;
-       pmu = mali_pmu_get_global_pmu_core();
-       enable_clock();
-       flush_scaling_job();
-
-       /* clock scaling off. Kasin... */
-       ret = mali_clock_critical(mali_cri_deep_suspend, (size_t)device);
-       disable_clock();
-       return ret;
+    int ret = 0;
+    struct mali_pmu_core *pmu;
+
+    mali_pm_statue = 1;
+    pmu = mali_pmu_get_global_pmu_core();
+    enable_clock();
+#ifndef CONFIG_MALI_DVFS
+    flush_scaling_job();
+#endif
+
+    /* clock scaling off. Kasin... */
+    ret = mali_clock_critical(mali_cri_deep_suspend, (size_t)device);
+    disable_clock();
+    return ret;
 }
 
 int mali_deep_resume(struct device *device)
 {
-       int ret = 0;
+    int ret = 0;
 
-       /* clock scaling up. Kasin.. */
-       enable_clock();
-       ret = mali_clock_critical(mali_cri_deep_resume, (size_t)device);
-       mali_pm_statue = 0;
-       return ret;
+    /* clock scaling up. Kasin.. */
+    enable_clock();
+    ret = mali_clock_critical(mali_cri_deep_resume, (size_t)device);
+    mali_pm_statue = 0;
+    return ret;
 }
 
 void mali_post_init(void)
 {
 #ifdef CONFIG_GPU_THERMAL
-       int err;
-       struct gpufreq_cooling_device *gcdev = NULL;
-       struct gpucore_cooling_device *gccdev = NULL;
-
-       gcdev = gpufreq_cooling_alloc();
-       register_gpu_freq_info(get_current_frequency);
-       if(IS_ERR(gcdev))
-               printk("malloc gpu cooling buffer error!!\n");
-       else if(!gcdev)
-               printk("system does not enable thermal driver\n");
-       else {
-               gcdev->get_gpu_freq_level = get_mali_freq_level;
-               gcdev->get_gpu_max_level = get_mali_max_level;
-               gcdev->set_gpu_freq_idx = set_limit_mali_freq;
-               gcdev->get_gpu_current_max_level = get_limit_mali_freq;
-               err = gpufreq_cooling_register(gcdev);
-               if(err < 0)
-                       printk("register GPU  cooling error\n");
-               printk("gpu cooling register okay with err=%d\n",err);
-       }
-
-       gccdev=gpucore_cooling_alloc();
-       if(IS_ERR(gccdev))
-               printk("malloc gpu core cooling buffer error!!\n");
-       else if(!gccdev)
-               printk("system does not enable thermal driver\n");
-       else {
-               gccdev->max_gpu_core_num=mali_plat_data.cfg_pp;
-               gccdev->set_max_pp_num=set_limit_pp_num;
-               err = (int)gpucore_cooling_register(gccdev);
-               if(err < 0)
-                       printk("register GPU  cooling error\n");
-               printk("gpu core cooling register okay with err=%d\n",err);
-       }
+    int err;
+    struct gpufreq_cooling_device *gcdev = NULL;
+    struct gpucore_cooling_device *gccdev = NULL;
+
+    gcdev = gpufreq_cooling_alloc();
+    register_gpu_freq_info(get_current_frequency);
+    if (IS_ERR(gcdev))
+        printk("malloc gpu cooling buffer error!!\n");
+    else if (!gcdev)
+        printk("system does not enable thermal driver\n");
+    else {
+        gcdev->get_gpu_freq_level = get_mali_freq_level;
+        gcdev->get_gpu_max_level = get_mali_max_level;
+        gcdev->set_gpu_freq_idx = set_limit_mali_freq;
+        gcdev->get_gpu_current_max_level = get_limit_mali_freq;
+        err = gpufreq_cooling_register(gcdev);
+        if (err < 0)
+            printk("register GPU  cooling error\n");
+        printk("gpu cooling register okay with err=%d\n",err);
+    }
+
+    gccdev = gpucore_cooling_alloc();
+    if (IS_ERR(gccdev))
+        printk("malloc gpu core cooling buffer error!!\n");
+    else if (!gccdev)
+        printk("system does not enable thermal driver\n");
+    else {
+        gccdev->max_gpu_core_num=mali_plat_data.cfg_pp;
+        gccdev->set_max_pp_num=set_limit_pp_num;
+        err = (int)gpucore_cooling_register(gccdev);
+        if (err < 0)
+            printk("register GPU  cooling error\n");
+        printk("gpu core cooling register okay with err=%d\n",err);
+    }
 #endif
 }
index ff0dbc696de83d9061242d1f5d4e21ad39f8f704..1cb2f9dfacdd9a2b1862d4691b76b415bdb92e3a 100755 (executable)
 
 #define LOG_MALI_SCALING 0
 
-static int num_cores_enabled;
+
 static int currentStep;
+#ifndef CONFIG_MALI_DVFS
+static int num_cores_enabled;
 static int lastStep;
 static struct work_struct wq_work;
 static mali_plat_info_t* pmali_plat = NULL;
+#endif
 static int  scaling_mode = MALI_PP_FS_SCALING;
 
+
+static unsigned scaling_dbg_level = 1;
+module_param(scaling_dbg_level, uint, 0644);
+MODULE_PARM_DESC(scaling_dbg_level , "scaling debug level");
+
+#define scalingdbg(level, fmt, arg...)                      \
+    do {                                                    \
+        if (scaling_dbg_level >= (level))                   \
+        printk(fmt , ## arg);                           \
+    } while (0)
+
+#ifndef CONFIG_MALI_DVFS
 static void do_scaling(struct work_struct *work)
 {
-       mali_dvfs_threshold_table * pdvfs = pmali_plat->dvfs_table;
-       int err = mali_perf_set_num_pp_cores(num_cores_enabled);
-       MALI_DEBUG_ASSERT(0 == err);
-       MALI_IGNORE(err);
-       if (pdvfs[currentStep].freq_index != pdvfs[lastStep].freq_index) {
-               mali_dev_pause();
-               mali_clock_set(pdvfs[currentStep].freq_index);
-               mali_dev_resume();
-               lastStep = currentStep;
-       }
+    mali_dvfs_threshold_table * pdvfs = pmali_plat->dvfs_table;
+    int err = mali_perf_set_num_pp_cores(num_cores_enabled);
+    scalingdbg(1, "set pp cores to %d\n", num_cores_enabled);
+    MALI_DEBUG_ASSERT(0 == err);
+    MALI_IGNORE(err);
+    if (pdvfs[currentStep].freq_index != pdvfs[lastStep].freq_index) {
+        mali_dev_pause();
+        mali_clock_set(pdvfs[currentStep].freq_index);
+        mali_dev_resume();
+        lastStep = currentStep;
+    }
 #ifdef CONFIG_MALI400_PROFILING
-       _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
-                                       MALI_PROFILING_EVENT_CHANNEL_GPU |
-                                       MALI_PROFILING_EVENT_REASON_SINGLE_GPU_FREQ_VOLT_CHANGE,
-                                       get_current_frequency(),
-                                       0,      0,      0,      0);
+    _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
+            MALI_PROFILING_EVENT_CHANNEL_GPU |
+            MALI_PROFILING_EVENT_REASON_SINGLE_GPU_FREQ_VOLT_CHANGE,
+            get_current_frequency(),
+            0, 0,      0,      0);
 #endif
 }
+#endif
 
 u32 revise_set_clk(u32 val, u32 flush)
 {
-       mali_scale_info_t* pinfo;
-       u32 ret = 0;
-
-       pinfo = &pmali_plat->scale_info;
-
-       if (val < pinfo->minclk)
-               val = pinfo->minclk;
-       else if (val >  pinfo->maxclk)
-               val =  pinfo->maxclk;
-
-       if (val != currentStep) {
-               currentStep = val;
-               if (flush)
-                       schedule_work(&wq_work);
-               else
-                       ret = 1;
-       }
-
-       return ret;
+    u32 ret = 0;
+#ifndef CONFIG_MALI_DVFS
+    mali_scale_info_t* pinfo;
+
+    pinfo = &pmali_plat->scale_info;
+
+    if (val < pinfo->minclk)
+        val = pinfo->minclk;
+    else if (val >  pinfo->maxclk)
+        val =  pinfo->maxclk;
+
+    if (val != currentStep) {
+        currentStep = val;
+        if (flush)
+            schedule_work(&wq_work);
+        else
+            ret = 1;
+    }
+#endif
+    return ret;
 }
 
 void get_mali_rt_clkpp(u32* clk, u32* pp)
 {
-       *clk = currentStep;
-       *pp = num_cores_enabled;
+#ifndef CONFIG_MALI_DVFS
+    *clk = currentStep;
+    *pp = num_cores_enabled;
+#endif
 }
 
 u32 set_mali_rt_clkpp(u32 clk, u32 pp, u32 flush)
 {
-       mali_scale_info_t* pinfo;
-       u32 ret = 0;
-       u32 flush_work = 0;
-
-       pinfo = &pmali_plat->scale_info;
-       if (clk < pinfo->minclk)
-               clk = pinfo->minclk;
-       else if (clk >  pinfo->maxclk)
-               clk =  pinfo->maxclk;
-
-       if (clk != currentStep) {
-               currentStep = clk;
-               if (flush)
-                       flush_work++;
-               else
-                       ret = 1;
-       }
-       if (pp < pinfo->minpp)
-               pp = pinfo->minpp;
-       else if (pp > pinfo->maxpp)
-               pp = pinfo->maxpp;
-
-       if (pp != num_cores_enabled) {
-               num_cores_enabled = pp;
-               if (flush)
-                       flush_work++;
-               else
-                       ret = 1;
-       }
-
-       if (flush_work)
-               schedule_work(&wq_work);
-       return ret;
+    u32 ret = 0;
+#ifndef CONFIG_MALI_DVFS
+    mali_scale_info_t* pinfo;
+    u32 flush_work = 0;
+
+    pinfo = &pmali_plat->scale_info;
+    if (clk < pinfo->minclk)
+        clk = pinfo->minclk;
+    else if (clk >  pinfo->maxclk)
+        clk =  pinfo->maxclk;
+
+    if (clk != currentStep) {
+        currentStep = clk;
+        if (flush)
+            flush_work++;
+        else
+            ret = 1;
+    }
+    if (pp < pinfo->minpp)
+        pp = pinfo->minpp;
+    else if (pp > pinfo->maxpp)
+        pp = pinfo->maxpp;
+
+    if (pp != num_cores_enabled) {
+        num_cores_enabled = pp;
+        if (flush)
+            flush_work++;
+        else
+            ret = 1;
+    }
+
+    if (flush_work)
+        schedule_work(&wq_work);
+#endif
+    return ret;
 }
 
 void revise_mali_rt(void)
 {
-       set_mali_rt_clkpp(currentStep, num_cores_enabled, 1);
+#ifndef CONFIG_MALI_DVFS
+    set_mali_rt_clkpp(currentStep, num_cores_enabled, 1);
+#endif
 }
 
 void flush_scaling_job(void)
 {
-       cancel_work_sync(&wq_work);
+#ifndef CONFIG_MALI_DVFS
+    cancel_work_sync(&wq_work);
+#endif
 }
 
+#ifndef CONFIG_MALI_DVFS
 static u32 enable_one_core(void)
 {
-       return set_mali_rt_clkpp(currentStep, num_cores_enabled + 1, 0);
+    printk("meson:     one more pp, curent has %d pp cores\n",  num_cores_enabled + 1);
+    return set_mali_rt_clkpp(currentStep, num_cores_enabled + 1, 0);
 }
 
 static u32 disable_one_core(void)
 {
-       return set_mali_rt_clkpp(currentStep, num_cores_enabled - 1, 0);
+    printk("meson: disable one pp, current has %d pp cores\n",  num_cores_enabled - 1);
+    return set_mali_rt_clkpp(currentStep, num_cores_enabled - 1, 0);
 }
 
 static u32 enable_max_num_cores(void)
 {
-       return set_mali_rt_clkpp(currentStep, pmali_plat->scale_info.maxpp, 0);
+    return set_mali_rt_clkpp(currentStep, pmali_plat->scale_info.maxpp, 0);
 }
 
 static u32 enable_pp_cores(u32 val)
 {
-       return set_mali_rt_clkpp(currentStep, val, 0);
+    printk("meson: enable %d pp cores\n", val);
+    return set_mali_rt_clkpp(currentStep, val, 0);
 }
+#endif
 
 int mali_core_scaling_init(mali_plat_info_t *mali_plat)
 {
-       if (mali_plat == NULL) {
-               printk(" Mali platform data is NULL!!!\n");
-               return -1;
-       }
-
-       pmali_plat = mali_plat;
-       num_cores_enabled = pmali_plat->sc_mpp;
-
-       currentStep = pmali_plat->def_clock;
-       lastStep = currentStep;
-       INIT_WORK(&wq_work, do_scaling);
-
-       return 0;
-       /* NOTE: Mali is not fully initialized at this point. */
+#ifndef CONFIG_MALI_DVFS
+    if (mali_plat == NULL) {
+        printk(" Mali platform data is NULL!!!\n");
+        return -1;
+    }
+
+    pmali_plat = mali_plat;
+    num_cores_enabled = pmali_plat->sc_mpp;
+
+    currentStep = pmali_plat->def_clock;
+    lastStep = currentStep;
+    INIT_WORK(&wq_work, do_scaling);
+#endif
+    return 0;
+    /* NOTE: Mali is not fully initialized at this point. */
 }
 
 void mali_core_scaling_term(void)
 {
-       flush_scheduled_work();
+#ifndef CONFIG_MALI_DVFS
+    flush_scheduled_work();
+#endif
 }
 
+#ifndef CONFIG_MALI_DVFS
 static u32 mali_threshold [] = {
-       102, /* 40% */
-       128, /* 50% */
-       230, /* 90% */
+    102, /* 40% */
+    128, /* 50% */
+    230, /* 90% */
 };
+#endif
 
 void mali_pp_scaling_update(struct mali_gpu_utilization_data *data)
 {
-       int ret = 0;
-
-       if (mali_threshold[2] < data->utilization_pp)
-               ret = enable_max_num_cores();
-       else if (mali_threshold[1]< data->utilization_pp)
-               ret = enable_one_core();
-       else if (0 < data->utilization_pp)
-               ret = disable_one_core();
-       if (ret == 1)
-               schedule_work(&wq_work);
+#ifndef CONFIG_MALI_DVFS
+    int ret = 0;
+
+    if (mali_threshold[2] < data->utilization_pp)
+        ret = enable_max_num_cores();
+    else if (mali_threshold[1]< data->utilization_pp)
+        ret = enable_one_core();
+    else if (0 < data->utilization_pp)
+        ret = disable_one_core();
+    if (ret == 1)
+        schedule_work(&wq_work);
+#endif
 }
 
 #if LOG_MALI_SCALING
 void trace_utilization(struct mali_gpu_utilization_data *data, u32 current_idx, u32 next,
-       u32 current_pp, u32 next_pp)
+        u32 current_pp, u32 next_pp)
 {
-       char direction;
-       if (next > current_idx)
-               direction = '>';
-       else if ((current_idx > pmali_plat->scale_info.minpp) && (next < current_idx))
-               direction = '<';
-       else
-               direction = '~';
-
-       printk("[SCALING]%c (%3d-->%3d)@%3d{%3d - %3d}. pp:(%d-->%d)\n",
-                               direction,
-                               get_mali_freq(current_idx),
-                               get_mali_freq(next),
-                               data->utilization_gpu,
-                               pmali_plat->dvfs_table[current_idx].downthreshold,
-                               pmali_plat->dvfs_table[current_idx].upthreshold,
-                               current_pp, next_pp);
+    char direction;
+    if (next > current_idx)
+        direction = '>';
+    else if ((current_idx > pmali_plat->scale_info.minpp) && (next < current_idx))
+        direction = '<';
+    else
+        direction = '~';
+
+    printk("[SCALING]%c (%3d-->%3d)@%3d{%3d - %3d}. pp:(%d-->%d)\n",
+            direction,
+            get_mali_freq(current_idx),
+            get_mali_freq(next),
+            data->utilization_gpu,
+            pmali_plat->dvfs_table[current_idx].downthreshold,
+            pmali_plat->dvfs_table[current_idx].upthreshold,
+            current_pp, next_pp);
 }
 #endif
 
+#ifndef CONFIG_MALI_DVFS
 static int mali_stay_count = 0;
 static void mali_decide_next_status(struct mali_gpu_utilization_data *data, int* next_fs_idx,
-                                                               int* pp_change_flag)
+        int* pp_change_flag)
 {
-       u32 utilization, mali_up_limit, decided_fs_idx;
-       u32 ld_left, ld_right;
-       u32 ld_up, ld_down;
-       u32 change_mode;
-
-       *pp_change_flag = 0;
-       change_mode = 0;
-       utilization = data->utilization_gpu;
-
-       mali_up_limit = (scaling_mode ==  MALI_TURBO_MODE) ?
-                               pmali_plat->turbo_clock : pmali_plat->scale_info.maxclk;
-       decided_fs_idx = currentStep;
-
-       ld_up = pmali_plat->dvfs_table[currentStep].upthreshold;
-       ld_down = pmali_plat->dvfs_table[currentStep].downthreshold;
-       if (utilization >= ld_up) { /* go up */
-               if (currentStep < mali_up_limit) {
-                       change_mode = 1;
-                       if ((currentStep < pmali_plat->def_clock) && (utilization > pmali_plat->bst_gpu))
-                               decided_fs_idx = pmali_plat->def_clock;
-                       else
-                               decided_fs_idx++;
-               }
-               if ((data->utilization_pp >= ld_up) &&
-                               (num_cores_enabled < pmali_plat->scale_info.maxpp)) {
-                       if ((num_cores_enabled < pmali_plat->sc_mpp) && (data->utilization_pp >= pmali_plat->bst_pp)) {
-                               *pp_change_flag = 1;
-                               change_mode = 1;
-                       } else if (change_mode == 0) {
-                               *pp_change_flag = 2;
-                               change_mode = 1;
-                       }
-               }
+    u32 utilization, mali_up_limit, decided_fs_idx;
+    u32 ld_left, ld_right;
+    u32 ld_up, ld_down;
+    u32 change_mode;
+
+    *pp_change_flag = 0;
+    change_mode = 0;
+    utilization = data->utilization_gpu;
+
+    mali_up_limit = (scaling_mode ==  MALI_TURBO_MODE) ?
+        pmali_plat->turbo_clock : pmali_plat->scale_info.maxclk;
+    decided_fs_idx = currentStep;
+
+    ld_up = pmali_plat->dvfs_table[currentStep].upthreshold;
+    ld_down = pmali_plat->dvfs_table[currentStep].downthreshold;
+
+    scalingdbg(2, "utilization=%d,  ld_up=%d\n ", utilization,  ld_up);
+    if (utilization >= ld_up) { /* go up */
+
+        scalingdbg(2, "currentStep=%d,  mali_up_limit=%d\n ", currentStep, mali_up_limit);
+        if (currentStep < mali_up_limit) {
+            change_mode = 1;
+            if ((currentStep < pmali_plat->def_clock) && (utilization > pmali_plat->bst_gpu))
+                decided_fs_idx = pmali_plat->def_clock;
+            else
+                decided_fs_idx++;
+        }
+        if ((data->utilization_pp >= ld_up) &&
+                (num_cores_enabled < pmali_plat->scale_info.maxpp)) {
+            if ((num_cores_enabled < pmali_plat->sc_mpp) && (data->utilization_pp >= pmali_plat->bst_pp)) {
+                *pp_change_flag = 1;
+                change_mode = 1;
+            } else if (change_mode == 0) {
+                *pp_change_flag = 2;
+                change_mode = 1;
+            }
+        }
 #if LOG_MALI_SCALING
-                printk("[nexting..] [LD:%d]-> FS[CRNT:%d LMT:%d NEXT:%d] PP[NUM:%d LMT:%d MD:%d][F:%d]\n",
-                        data->utilization_pp, currentStep, mali_up_limit, decided_fs_idx,
-                        num_cores_enabled, pmali_plat->scale_info.maxpp, *pp_change_flag, change_mode);
+        printk("[nexting..] [LD:%d]-> FS[CRNT:%d LMT:%d NEXT:%d] PP[NUM:%d LMT:%d MD:%d][F:%d]\n",
+                data->utilization_pp, currentStep, mali_up_limit, decided_fs_idx,
+                num_cores_enabled, pmali_plat->scale_info.maxpp, *pp_change_flag, change_mode);
 #endif
-       } else if (utilization <= ld_down) { /* go down */
-               if (mali_stay_count > 0) {
-                       *next_fs_idx = decided_fs_idx;
-                       mali_stay_count--;
-                       return;
-               }
-
-               if (num_cores_enabled > pmali_plat->sc_mpp) {
-                       change_mode = 1;
-                       if (data->utilization_pp <= ld_down) {
-                               ld_left = data->utilization_pp * num_cores_enabled;
-                               ld_right = (pmali_plat->dvfs_table[currentStep].upthreshold) *
-                                                               (num_cores_enabled - 1);
-                               if (ld_left < ld_right) {
-                                       change_mode = 2;
-                               }
-                       }
-               } else if (currentStep > pmali_plat->scale_info.minpp) {
-                       change_mode = 1;
-               } else if (num_cores_enabled > 1) { /* decrease PPS */
-                       if (data->utilization_pp <= ld_down) {
-                               ld_left = data->utilization_pp * num_cores_enabled;
-                               ld_right = (pmali_plat->dvfs_table[currentStep].upthreshold) *
-                                                               (num_cores_enabled - 1);
-                               if (ld_left < ld_right) {
-                                       change_mode = 2;
-                               }
-                       }
-               }
-
-               if (change_mode == 1) {
-                       decided_fs_idx--;
-               } else if (change_mode == 2) { /* decrease PPS */
-                       *pp_change_flag = -1;
-               }
-       }
-       if (change_mode)
-               mali_stay_count = pmali_plat->dvfs_table[decided_fs_idx].keep_count;
-       *next_fs_idx = decided_fs_idx;
+    } else if (utilization <= ld_down) { /* go down */
+        if (mali_stay_count > 0) {
+            *next_fs_idx = decided_fs_idx;
+            mali_stay_count--;
+            return;
+        }
+
+        if (num_cores_enabled > pmali_plat->sc_mpp) {
+            change_mode = 1;
+            if (data->utilization_pp <= ld_down) {
+                ld_left = data->utilization_pp * num_cores_enabled;
+                ld_right = (pmali_plat->dvfs_table[currentStep].upthreshold) *
+                    (num_cores_enabled - 1);
+                if (ld_left < ld_right) {
+                    change_mode = 2;
+                }
+            }
+        } else if (currentStep > pmali_plat->scale_info.minclk) {
+            change_mode = 1;
+        } else if (num_cores_enabled > 1) { /* decrease PPS */
+            if (data->utilization_pp <= ld_down) {
+                ld_left = data->utilization_pp * num_cores_enabled;
+                ld_right = (pmali_plat->dvfs_table[currentStep].upthreshold) *
+                    (num_cores_enabled - 1);
+                scalingdbg(2, "ld_left=%d, ld_right=%d\n", ld_left, ld_right);
+                if (ld_left < ld_right) {
+                    change_mode = 2;
+                }
+            }
+        }
+
+        if (change_mode == 1) {
+            decided_fs_idx--;
+        } else if (change_mode == 2) { /* decrease PPS */
+            *pp_change_flag = -1;
+        }
+    }
+    if (change_mode)
+        mali_stay_count = pmali_plat->dvfs_table[decided_fs_idx].keep_count;
+    *next_fs_idx = decided_fs_idx;
 }
+#endif
 
 void mali_pp_fs_scaling_update(struct mali_gpu_utilization_data *data)
 {
-       int ret = 0;
-       int pp_change_flag = 0;
-       u32 next_idx = 0;
-       
+#ifndef CONFIG_MALI_DVFS
+    int ret = 0;
+    int pp_change_flag = 0;
+    u32 next_idx = 0;
+
 #if LOG_MALI_SCALING
-       u32 last_pp = num_cores_enabled;
+    u32 last_pp = num_cores_enabled;
 #endif
-       mali_decide_next_status(data, &next_idx, &pp_change_flag);
+    mali_decide_next_status(data, &next_idx, &pp_change_flag);
 
-       if (pp_change_flag == 1)
-               ret = enable_pp_cores(pmali_plat->sc_mpp);
-       else if (pp_change_flag == 2)
-               ret = enable_one_core();
-       else if (pp_change_flag == -1) {
-               ret = disable_one_core();
-       }
+    if (pp_change_flag == 1)
+        ret = enable_pp_cores(pmali_plat->sc_mpp);
+    else if (pp_change_flag == 2)
+        ret = enable_one_core();
+    else if (pp_change_flag == -1) {
+        ret = disable_one_core();
+    }
 
 #if LOG_MALI_SCALING
-       if (pp_change_flag || (next_idx != currentStep))
-               trace_utilization(data, currentStep, next_idx, last_pp, num_cores_enabled);
+    if (pp_change_flag || (next_idx != currentStep))
+        trace_utilization(data, currentStep, next_idx, last_pp, num_cores_enabled);
 #endif
 
-       if (next_idx != currentStep) {
-               ret = 1;
-               currentStep = next_idx;
-       }
+    if (next_idx != currentStep) {
+        ret = 1;
+        currentStep = next_idx;
+    }
 
-       if (ret == 1)
-               schedule_work(&wq_work);
+    if (ret == 1)
+        schedule_work(&wq_work);
 #ifdef CONFIG_MALI400_PROFILING
-       else
-               _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
-                                               MALI_PROFILING_EVENT_CHANNEL_GPU |
-                                               MALI_PROFILING_EVENT_REASON_SINGLE_GPU_FREQ_VOLT_CHANGE,
-                                               get_current_frequency(),
-                                               0,      0,      0,      0);
+    else
+        _mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |
+                MALI_PROFILING_EVENT_CHANNEL_GPU |
+                MALI_PROFILING_EVENT_REASON_SINGLE_GPU_FREQ_VOLT_CHANGE,
+                get_current_frequency(),
+                0,     0,      0,      0);
+#endif
 #endif
 }
 
 u32 get_mali_schel_mode(void)
 {
-       return scaling_mode;
+    return scaling_mode;
 }
 
 void set_mali_schel_mode(u32 mode)
 {
-       MALI_DEBUG_ASSERT(mode < MALI_SCALING_MODE_MAX);
-       if (mode >= MALI_SCALING_MODE_MAX)
-               return;
-       scaling_mode = mode;
-
-       /* set default performance range. */
-       pmali_plat->scale_info.minclk = pmali_plat->cfg_min_clock;
-       pmali_plat->scale_info.maxclk = pmali_plat->cfg_clock;
-       pmali_plat->scale_info.minpp = pmali_plat->cfg_min_pp;
-       pmali_plat->scale_info.maxpp = pmali_plat->cfg_pp;
-
-       /* set current status and tune max freq */
-       if (scaling_mode == MALI_PP_FS_SCALING) {
-               pmali_plat->scale_info.maxclk = pmali_plat->cfg_clock;
-               enable_pp_cores(pmali_plat->sc_mpp);
-       } else if (scaling_mode == MALI_SCALING_DISABLE) {
-               pmali_plat->scale_info.maxclk = pmali_plat->cfg_clock;
-               enable_max_num_cores();
-       } else if (scaling_mode == MALI_TURBO_MODE) {
-               pmali_plat->scale_info.maxclk = pmali_plat->turbo_clock;
-               enable_max_num_cores();
-       }
-       currentStep = pmali_plat->scale_info.maxclk;
-       schedule_work(&wq_work);
+#ifndef CONFIG_MALI_DVFS
+    MALI_DEBUG_ASSERT(mode < MALI_SCALING_MODE_MAX);
+    if (mode >= MALI_SCALING_MODE_MAX)
+        return;
+    scaling_mode = mode;
+
+    /* set default performance range. */
+    pmali_plat->scale_info.minclk = pmali_plat->cfg_min_clock;
+    pmali_plat->scale_info.maxclk = pmali_plat->cfg_clock;
+    pmali_plat->scale_info.minpp = pmali_plat->cfg_min_pp;
+    pmali_plat->scale_info.maxpp = pmali_plat->cfg_pp;
+
+    /* set current status and tune max freq */
+    if (scaling_mode == MALI_PP_FS_SCALING) {
+        pmali_plat->scale_info.maxclk = pmali_plat->cfg_clock;
+        enable_pp_cores(pmali_plat->sc_mpp);
+    } else if (scaling_mode == MALI_SCALING_DISABLE) {
+        pmali_plat->scale_info.maxclk = pmali_plat->cfg_clock;
+        enable_max_num_cores();
+    } else if (scaling_mode == MALI_TURBO_MODE) {
+        pmali_plat->scale_info.maxclk = pmali_plat->turbo_clock;
+        enable_max_num_cores();
+    }
+    currentStep = pmali_plat->scale_info.maxclk;
+    schedule_work(&wq_work);
+#endif
 }
 
 u32 get_current_frequency(void)
 {
-       return get_mali_freq(currentStep);
+    return get_mali_freq(currentStep);
 }
 
 void mali_gpu_utilization_callback(struct mali_gpu_utilization_data *data)
 {
-       if (mali_pm_statue)
-               return;
-
-       switch (scaling_mode) {
-       case MALI_PP_FS_SCALING:
-               mali_pp_fs_scaling_update(data);
-               break;
-       case MALI_PP_SCALING:
-               mali_pp_scaling_update(data);
-               break;
-       default:
-               break;
-       }
+#ifndef CONFIG_MALI_DVFS
+    if (mali_pm_statue)
+        return;
+
+    switch (scaling_mode) {
+        case MALI_PP_FS_SCALING:
+            mali_pp_fs_scaling_update(data);
+            break;
+        case MALI_PP_SCALING:
+            mali_pp_scaling_update(data);
+            break;
+        default:
+            break;
+    }
+#endif
 }
 
 void mali_dev_restore(void)
 {
-       mali_dvfs_threshold_table * pdvfs = pmali_plat->dvfs_table;
+#ifndef CONFIG_MALI_DVFS
+    mali_dvfs_threshold_table * pdvfs = pmali_plat->dvfs_table;
 
-       //mali_perf_set_num_pp_cores(num_cores_enabled);
-       mali_clock_set(pdvfs[currentStep].freq_index);
+    //mali_perf_set_num_pp_cores(num_cores_enabled);
+    mali_clock_set(pdvfs[currentStep].freq_index);
+#endif
 }
index 6dd3c8fd96579926d2c1aa0dfd2aa9e168a998e6..0f96fc78170f2d522ab8b360ea5b9aedbea5cd3d 100755 (executable)
@@ -35,9 +35,34 @@ u32 mali_core_timeout = 0;
 module_param(mali_core_timeout, int, S_IRUSR | S_IWUSR | S_IWGRP | S_IRGRP | S_IROTH); /* rw-rw-r-- */
 MODULE_PARM_DESC(mali_core_timeout, "times of failed to reset GP");
 
+static struct mali_gpu_device_data mali_gpu_data =
+{
+       .shared_mem_size = 1024 * 1024 * 1024,
+       .max_job_runtime = 60000, /* 60 seconds */
+       .pmu_switch_delay = 0xFFFF, /* do not have to be this high on FPGA, but it is good for testing to have a delay */
+       .pmu_domain_config = {0x1, 0x2, 0x4, 0x4,
+                          0x0, 0x8, 0x8, 0x8,
+                          0x0, 0x1, 0x2, 0x8},
+};
+
+static void mali_platform_device_release(struct device *device);
+static struct platform_device mali_gpu_device =
+{
+       .name = MALI_GPU_NAME_UTGARD,
+       .id = 0,
+       .dev.release = mali_platform_device_release,
+       .dev.coherent_dma_mask = DMA_BIT_MASK(32),
+       .dev.platform_data = &mali_gpu_data,
+       .dev.type = &mali_pm_device, /* We should probably use the pm_domain instead of type on newer kernels */
+};
+
 int mali_pdev_pre_init(struct platform_device* ptr_plt_dev)
 {
        MALI_DEBUG_PRINT(4, ("mali_platform_device_register() called\n"));
+       if (mali_gpu_data.shared_mem_size < 10) {
+               MALI_DEBUG_PRINT(2, ("mali os memory didn't configered, set to default(512M)\n"));
+               mali_gpu_data.shared_mem_size = 1024 * 1024 *1024;
+       }
        return mali_meson_init_start(ptr_plt_dev);
 }
 
@@ -55,33 +80,26 @@ void mali_pdev_post_init(struct platform_device* pdev)
        mali_meson_init_finish(pdev);
 }
 
-void mali_gpu_utilization_callback(struct mali_gpu_utilization_data *data);
-static struct mali_gpu_device_data mali_gpu_data =
+int mali_pdev_dts_init(struct platform_device* mali_gpu_device)
 {
-       .shared_mem_size = 1024 * 1024 * 1024,
-       .max_job_runtime = 60000, /* 60 seconds */
-       .pmu_switch_delay = 0xFFFF, /* do not have to be this high on FPGA, but it is good for testing to have a delay */
-
-       /* the following is for dvfs or utilization. */
-       .control_interval = 300, /* 1000ms */
-       .get_clock_info = NULL,
-       .get_freq = NULL,
-       .set_freq = NULL,
-       .utilization_callback = mali_gpu_utilization_callback,
-};
+       struct device_node     *cfg_node = mali_gpu_device->dev.of_node;
+       struct device_node     *child;
+       u32 prop_value;
+       int err;
+
+       for_each_child_of_node(cfg_node, child) {
+               err = of_property_read_u32(child, "shared_memory", &prop_value);
+               if (err == 0) {
+                       MALI_DEBUG_PRINT(2, ("shared_memory configurate  %d\n", prop_value));
+                       mali_gpu_data.shared_mem_size = prop_value * 1024 * 1024;
+               }
+       }
 
-#ifndef CONFIG_MALI_DT
-static void mali_platform_device_release(struct device *device);
-static struct platform_device mali_gpu_device =
-{
-       .name = MALI_GPU_NAME_UTGARD,
-       .id = 0,
-       .dev.release = mali_platform_device_release,
-       .dev.dma_mask = &mali_gpu_device.dev.coherent_dma_mask,
-       .dev.coherent_dma_mask = DMA_BIT_MASK(32),
-       .dev.platform_data = &mali_gpu_data,
-       .dev.type = &mali_pm_device, /* We should probably use the pm_domain instead of type on newer kernels */
-};
+       err = mali_pdev_pre_init(mali_gpu_device);
+       if (err == 0)
+               mali_pdev_post_init(mali_gpu_device);
+       return err;
+}
 
 int mali_platform_device_register(void)
 {
@@ -108,32 +126,4 @@ static void mali_platform_device_release(struct device *device)
        MALI_DEBUG_PRINT(4, ("mali_platform_device_release() called\n"));
 }
 
-#else /* CONFIG_MALI_DT */
-
-int mali_platform_device_init(struct platform_device *device)
-{
-       int err = 0;
-
-       ret = mali_pdev_pre_init(&mali_gpu_data);
-       if (ret < 0) goto exit;
-       err = platform_device_add_data(device, &mali_gpu_data, sizeof(mali_gpu_data));
-       if (ret < 0) goto exit;
-
-       mali_pdev_post_init(&mali_gpu_data);
-exit:
-       return err;
-}
-
-int mali_platform_device_deinit(struct platform_device *device)
-{
-       MALI_IGNORE(device);
-
-       MALI_DEBUG_PRINT(4, ("mali_platform_device_deinit() called\n"));
-
-       mali_core_scaling_term();
-
-       return 0;
-}
-
-#endif /* CONFIG_MALI_DT */
 
index e8c2cdddeb69299ce3750e24aa03def770d0bf4b..44c31c4b7be5e12553dc6eb2ea720af8544abf04 100755 (executable)
@@ -25,7 +25,6 @@ u32 get_max_mali_freq(void);
 
 int mali_meson_init_start(struct platform_device* ptr_plt_dev);
 int mali_meson_init_finish(struct platform_device* ptr_plt_dev);
-void mali_post_init(void);
 int mali_meson_uninit(struct platform_device* ptr_plt_dev);
 int mali_light_suspend(struct device *device);
 int mali_light_resume(struct device *device);