Merge tag 'v4.4-rc2'
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / arm / midgard / backend / gpu / mali_kbase_pm_demand.c
1 /*
2  *
3  * (C) COPYRIGHT 2010-2015 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  * @file mali_kbase_pm_demand.c
22  * A simple demand based power management policy
23  */
24
25 #include <mali_kbase.h>
26 #include <mali_kbase_pm.h>
27
28 static u64 demand_get_core_mask(struct kbase_device *kbdev)
29 {
30         u64 desired = kbdev->shader_needed_bitmap | kbdev->shader_inuse_bitmap;
31
32         if (0 == kbdev->pm.active_count)
33                 return 0;
34
35         return desired;
36 }
37
38 static bool demand_get_core_active(struct kbase_device *kbdev)
39 {
40         if (0 == kbdev->pm.active_count)
41                 return false;
42
43         return true;
44 }
45
46 static void demand_init(struct kbase_device *kbdev)
47 {
48         CSTD_UNUSED(kbdev);
49 }
50
51 static void demand_term(struct kbase_device *kbdev)
52 {
53         CSTD_UNUSED(kbdev);
54 }
55
56 /**
57  * The @ref struct kbase_pm_policy structure for the demand power policy.
58  *
59  * This is the static structure that defines the demand power policy's callback
60  * and name.
61  */
62 const struct kbase_pm_policy kbase_pm_demand_policy_ops = {
63         "demand",                       /* name */
64         demand_init,                    /* init */
65         demand_term,                    /* term */
66         demand_get_core_mask,           /* get_core_mask */
67         demand_get_core_active,         /* get_core_active */
68         0u,                             /* flags */
69         KBASE_PM_POLICY_ID_DEMAND,      /* id */
70 };
71
72 KBASE_EXPORT_TEST_API(kbase_pm_demand_policy_ops);