1 /*
2 * Copyright (C) 2010-2014, 2016-2017 ARM Limited. All rights reserved.
3 *
4 * This program is free software and is provided to you under the terms of the GNU General Public License version 2
5 * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
6 *
7 * A copy of the licence is included with the program, and can also be obtained from Free Software
8 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
9 */
10
11 #ifndef __MALI_PM_METRICS_H__
12 #define __MALI_PM_METRICS_H__
13
14 #ifdef CONFIG_MALI_DEVFREQ
15 #include "mali_osk_locks.h"
16 #include "mali_group.h"
17
18 struct mali_device;
19
20 /**
21 * Metrics data collected for use by the power management framework.
22 */
23 struct mali_pm_metrics_data {
24 ktime_t time_period_start;
25 u64 time_busy;
26 u64 time_idle;
27 u64 prev_busy;
28 u64 prev_idle;
29 u32 num_running_gp_cores;
30 u32 num_running_pp_cores;
31 ktime_t time_period_start_gp;
32 u64 time_busy_gp;
33 u64 time_idle_gp;
34 ktime_t time_period_start_pp;
35 u64 time_busy_pp[MALI_MAX_NUMBER_OF_PHYSICAL_PP_GROUPS];
36 u64 time_idle_pp[MALI_MAX_NUMBER_OF_PHYSICAL_PP_GROUPS];
37 mali_bool gpu_active;
38 _mali_osk_spinlock_irq_t *lock;
39 };
40
41 /**
42 * Initialize/start the Mali GPU pm_metrics metrics reporting.
43 *
44 * @return _MALI_OSK_ERR_OK on success, otherwise failure.
45 */
46 _mali_osk_errcode_t mali_pm_metrics_init(struct mali_device *mdev);
47
48 /**
49 * Terminate the Mali GPU pm_metrics metrics reporting
50 */
51 void mali_pm_metrics_term(struct mali_device *mdev);
52
53 /**
54 * Should be called when a job is about to execute a GPU job
55 */
56 void mali_pm_record_gpu_active(mali_bool is_gp);
57
58 /**
59 * Should be called when a job is finished
60 */
61 void mali_pm_record_gpu_idle(mali_bool is_gp);
62
63 void mali_pm_reset_dvfs_utilisation(struct mali_device *mdev);
64
65 void mali_pm_get_dvfs_utilisation(struct mali_device *mdev, unsigned long *total_out, unsigned long *busy_out);
66
67 void mali_pm_metrics_spin_lock(void);
68
69 void mali_pm_metrics_spin_unlock(void);
70 #else
mali_pm_record_gpu_idle(mali_bool is_gp)71 void mali_pm_record_gpu_idle(mali_bool is_gp) {}
mali_pm_record_gpu_active(mali_bool is_gp)72 void mali_pm_record_gpu_active(mali_bool is_gp) {}
73 #endif
74 #endif /* __MALI_PM_METRICS_H__ */
75