xref: /OK3568_Linux_fs/kernel/drivers/gpu/arm/midgard/backend/gpu/mali_kbase_pm_demand.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  *
3  * (C) COPYRIGHT 2010-2016 ARM Limited. All rights reserved.
4  *
5  * This program is free software and is provided to you under the terms of the
6  * GNU General Public License version 2 as published by the Free Software
7  * Foundation, and any use by you of this program is subject to the terms
8  * of such GNU licence.
9  *
10  * A copy of the licence is included with the program, and can also be obtained
11  * from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
12  * Boston, MA  02110-1301, USA.
13  *
14  */
15 
16 
17 
18 
19 
20 /*
21  * A simple demand based power management policy
22  */
23 
24 #include <mali_kbase.h>
25 #include <mali_kbase_pm.h>
26 
demand_get_core_mask(struct kbase_device * kbdev)27 static u64 demand_get_core_mask(struct kbase_device *kbdev)
28 {
29 	u64 desired = kbdev->shader_needed_bitmap | kbdev->shader_inuse_bitmap;
30 
31 	if (0 == kbdev->pm.active_count)
32 		return 0;
33 
34 	return desired;
35 }
36 
demand_get_core_active(struct kbase_device * kbdev)37 static bool demand_get_core_active(struct kbase_device *kbdev)
38 {
39 	if (0 == kbdev->pm.active_count && !(kbdev->shader_needed_bitmap |
40 			kbdev->shader_inuse_bitmap) && !kbdev->tiler_needed_cnt
41 			&& !kbdev->tiler_inuse_cnt)
42 		return false;
43 
44 	return true;
45 }
46 
demand_init(struct kbase_device * kbdev)47 static void demand_init(struct kbase_device *kbdev)
48 {
49 	CSTD_UNUSED(kbdev);
50 }
51 
demand_term(struct kbase_device * kbdev)52 static void demand_term(struct kbase_device *kbdev)
53 {
54 	CSTD_UNUSED(kbdev);
55 }
56 
57 /*
58  * The struct kbase_pm_policy structure for the demand power policy.
59  *
60  * This is the static structure that defines the demand power policy's callback
61  * and name.
62  */
63 const struct kbase_pm_policy kbase_pm_demand_policy_ops = {
64 	"demand",			/* name */
65 	demand_init,			/* init */
66 	demand_term,			/* term */
67 	demand_get_core_mask,		/* get_core_mask */
68 	demand_get_core_active,		/* get_core_active */
69 	0u,				/* flags */
70 	KBASE_PM_POLICY_ID_DEMAND,	/* id */
71 };
72 
73 KBASE_EXPORT_TEST_API(kbase_pm_demand_policy_ops);
74