+++ /dev/null
-/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2013-2014 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
- */
-
-/**
- * @file arm_core_scaling.c
- * Example core scaling policy.
- */
-
-/* #define ENABLE_DEBUG_LOG */
-#include "custom_log.h"
-
-#include "arm_core_scaling.h"
-
-#include <linux/mali/mali_utgard.h>
-#include "mali_kernel_common.h"
-
-#include <linux/workqueue.h>
-
-static int num_cores_total;
-static int num_cores_enabled;
-
-/**
- * 对连续的 request_to_disable_on_core 的计数.
- */
-static int count_of_requests_to_disable_one_core;
-/**
- * 在 count_of_requests_to_disable_one_core 等于本 value 的时候,
- * 将执行确实的 disable_one_core 操作.
- */
-#define NUM_OF_REQUESTS_TO_REALLY_DISABLE_ONE_CORE (10)
-
-static struct work_struct wq_work;
-
-static void set_num_cores(struct work_struct *work)
-{
- int err = mali_perf_set_num_pp_cores(num_cores_enabled);
-
- MALI_DEBUG_ASSERT(0 == err);
- MALI_IGNORE(err);
-}
-
-static void enable_one_core(void)
-{
- if (num_cores_enabled < num_cores_total) {
- ++num_cores_enabled;
- schedule_work(&wq_work);
- MALI_DEBUG_PRINT(3, ("Core scaling: Enabling one more core\n"));
- }
-
- MALI_DEBUG_ASSERT(1 <= num_cores_enabled);
- MALI_DEBUG_ASSERT(num_cores_total >= num_cores_enabled);
-}
-
-static void disable_one_core(void)
-{
- if (1 < num_cores_enabled) {
- --num_cores_enabled;
- schedule_work(&wq_work);
- MALI_DEBUG_PRINT(3, ("Core scaling: Disabling one core\n"));
- }
-
- MALI_DEBUG_ASSERT(1 <= num_cores_enabled);
- MALI_DEBUG_ASSERT(num_cores_total >= num_cores_enabled);
-}
-
-static void enable_max_num_cores(void)
-{
- if (num_cores_enabled < num_cores_total) {
- num_cores_enabled = num_cores_total;
- schedule_work(&wq_work);
- MALI_DEBUG_PRINT(3,
- ("Core scaling: Enabling max num of cores\n"));
- }
-
- MALI_DEBUG_ASSERT(num_cores_total == num_cores_enabled);
-}
-
-void mali_core_scaling_init(int num_pp_cores)
-{
- INIT_WORK(&wq_work, set_num_cores);
-
- num_cores_total = num_pp_cores;
- num_cores_enabled = num_pp_cores;
-
- /* NOTE: Mali is not fully initialized at this point. */
-}
-
-void mali_core_scaling_sync(int num_cores)
-{
- num_cores_enabled = num_cores;
-}
-
-void mali_core_scaling_term(void)
-{
- flush_scheduled_work();
-}
-
-#define PERCENT_OF(percent, max) ((int) ((percent)*(max)/100.0 + 0.5))
-
-void mali_core_scaling_update(struct mali_gpu_utilization_data *data)
-{
- /*
- * This function implements a very trivial PP core scaling algorithm.
- *
- * It is _NOT_ of production quality.
- * The only intention behind this algorithm is to exercise and test the
- * core scaling functionality of the driver.
- * It is _NOT_ tuned for neither power saving nor performance!
- *
- * Other metrics than PP utilization need to be considered as well
- * in order to make a good core scaling algorithm.
- */
-
- MALI_DEBUG_PRINT(3,
- ("Utilization:(%3d, %3d, %3d), cores enabled: %d/%d\n",
- data->utilization_gpu,
- data->utilization_gp,
- data->utilization_pp,
- num_cores_enabled,
- num_cores_total));
-
- /* NOTE:
- * this function
- * is normally called directly
- * from the utilization callback
- * which is in timer context. */
-
- if (PERCENT_OF(90, 256) < data->utilization_pp) {
- V("to enable max num of pp_cores.");
- enable_max_num_cores();
- count_of_requests_to_disable_one_core = 0;
- } else if (PERCENT_OF(50, 256) < data->utilization_pp) {
- V("to enable more one pp_core.");
- enable_one_core();
- count_of_requests_to_disable_one_core = 0;
- } else if (PERCENT_OF(40, 256) < data->utilization_pp) {
- count_of_requests_to_disable_one_core = 0;
- } else if (PERCENT_OF(0, 256) < data->utilization_pp) {
- count_of_requests_to_disable_one_core++;
- if (count_of_requests_to_disable_one_core
- >= NUM_OF_REQUESTS_TO_REALLY_DISABLE_ONE_CORE) {
- V("to disable a pp_core.");
- disable_one_core();
- count_of_requests_to_disable_one_core = 0;
- }
- } else {
- count_of_requests_to_disable_one_core = 0;
- }
-}
+++ /dev/null
-/*
- * This confidential and proprietary software may be used only as
- * authorised by a licensing agreement from ARM Limited
- * (C) COPYRIGHT 2013-2014 ARM Limited
- * ALL RIGHTS RESERVED
- * The entire notice above must be reproduced on all authorised
- * copies and copies may only be made to the extent permitted
- * by a licensing agreement from ARM Limited.
- */
-
-/**
- * @file arm_core_scaling.h
- * Example core scaling policy.
- */
-
-#ifndef __ARM_CORE_SCALING_H__
-#define __ARM_CORE_SCALING_H__
-
-struct mali_gpu_utilization_data;
-
-/**
- * Initialize core scaling policy.
- * .DP : core_scaling_policy, core_scaling_facility.
- *
- * @note
- * The core scaling policy will assume
- * that all PP cores are on initially.
- *
- * @param num_pp_cores
- * Total number of PP cores.
- */
-void mali_core_scaling_init(int num_pp_cores);
-
-/**
- * Terminate core scaling policy.
- */
-void mali_core_scaling_term(void);
-
-/**
- * Update core scaling policy
- * with new utilization data.
- *
- * @param data
- * Utilization data.
- */
-void mali_core_scaling_update(struct mali_gpu_utilization_data *data);
-
-void mali_core_scaling_sync(int num_cores);
-
-#endif /* __ARM_CORE_SCALING_H__ */
#include "mali_kernel_common.h"
#include "mali_osk.h"
-#include "arm_core_scaling.h"
#include "mali_platform.h"
-/*
- * 是否使能 core_scaling 机制.
- * .DP : core_scaling : 根据当前 mali_utilization_data,
- * 配置 mali_gpu 中具体使用的 pp_core 的个数.
- */
-static int mali_core_scaling_enable;
-
u32 mali_group_error;
/*
mali_drv_data->clock_set_lock =
_mali_osk_mutex_init(_MALI_OSK_LOCKFLAG_ORDERED,
_MALI_OSK_LOCK_ORDER_UTILIZATION);
- mali_core_scaling_enable = 1;
return 0;
term_clk:
mali_remove_sysfs(dev);
- mali_core_scaling_term();
mali_clock_term(dev);
_mali_osk_mutex_term(drv_data->clock_set_lock);
if (data->utilization_pp > 256)
return;
- if (mali_core_scaling_enable)
- mali_core_scaling_update(data);
-
/* dev_dbg(mali_dev, "utilization:%d\r\n", data->utilization_pp); */
mali_dvfs_event(mali_dev, data->utilization_pp);
#include <linux/mali/mali_utgard.h>
#include "mali_kernel_common.h"
#include "mali_platform.h"
-#include "arm_core_scaling.h"
#ifdef CONFIG_PM_RUNTIME
static int mali_runtime_suspend(struct device *device)
*/
int mali_platform_device_init(struct platform_device *pdev)
{
-// error
int err = 0;
- int num_pp_cores = 0;
-
- D("mali_platform_device_register() called\n");
-
- if (of_machine_is_compatible("rockchip,rk3036"))
- num_pp_cores = 1;
- else if (of_machine_is_compatible("rockchip,rk3228h"))
- num_pp_cores = 2;
- else if (of_machine_is_compatible("rockchip,rk3328h"))
- num_pp_cores = 2;
- else
- num_pp_cores = 2;
-
- D("to add config.");
- mali_platform_device_add_config(pdev);
D("to add data to platform_device..");
/* 将 platform_specific_data 添加到 platform_device_of_mali_gpu.
pm_runtime_use_autosuspend(&(pdev->dev));
pm_runtime_enable(&(pdev->dev));
#endif
- MALI_DEBUG_ASSERT(0 < num_pp_cores);
- mali_core_scaling_init(num_pp_cores);
return 0;
}
}