diff options
author | Debarshi Dutta <ddutta@nvidia.com> | 2019-04-30 04:24:08 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2019-05-09 17:41:30 -0400 |
commit | c81cc032c48a1b25e095b17b77399166c9091ff3 (patch) | |
tree | ace7d238c55bbb5e96fb6fd74deb156f3c513bae /drivers/gpu/nvgpu/common/power_features/pg | |
parent | f495f52c70c6bd7b7a4e6897270e4696efa57d5c (diff) |
gpu: nvgpu: add cg and pg function
Add new power/clock gating functions that can be called by
other units.
New clock_gating functions will reside in cg.c under
common/power_features/cg unit.
New power gating functions will reside in pg.c under
common/power_features/pg unit.
Use nvgpu_pg_elpg_disable and nvgpu_pg_elpg_enable to disable/enable
elpg and also in gr_gk20a_elpg_protected macro to access gr registers.
Add cg_pg_lock to make elpg_enabled, elcg_enabled, blcg_enabled
and slcg_enabled thread safe.
JIRA NVGPU-2014
Change-Id: I00d124c2ee16242c9a3ef82e7620fbb7f1297aff
Signed-off-by: Seema Khowala <seemaj@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2025493
Signed-off-by: Debarshi Dutta <ddutta@nvidia.com>
(cherry-picked from c90585856567a547173a8b207365b3a4a3ccdd57 in
dev-kernel)
Reviewed-on: https://git-master.nvidia.com/r/2108406
GVS: Gerrit_Virtual_Submit
Reviewed-by: Bibek Basu <bbasu@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/common/power_features/pg')
-rw-r--r-- | drivers/gpu/nvgpu/common/power_features/pg/pg.c | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/common/power_features/pg/pg.c b/drivers/gpu/nvgpu/common/power_features/pg/pg.c new file mode 100644 index 00000000..fa31f4e3 --- /dev/null +++ b/drivers/gpu/nvgpu/common/power_features/pg/pg.c | |||
@@ -0,0 +1,106 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
20 | * DEALINGS IN THE SOFTWARE. | ||
21 | */ | ||
22 | |||
23 | #include <nvgpu/gk20a.h> | ||
24 | #include <nvgpu/pmu.h> | ||
25 | #include <nvgpu/power_features/pg.h> | ||
26 | |||
27 | bool nvgpu_pg_elpg_is_enabled(struct gk20a *g) | ||
28 | { | ||
29 | bool elpg_enabled; | ||
30 | |||
31 | nvgpu_log_fn(g, " "); | ||
32 | |||
33 | nvgpu_mutex_acquire(&g->cg_pg_lock); | ||
34 | elpg_enabled = g->elpg_enabled; | ||
35 | nvgpu_mutex_release(&g->cg_pg_lock); | ||
36 | return elpg_enabled; | ||
37 | } | ||
38 | |||
39 | int nvgpu_pg_elpg_enable(struct gk20a *g) | ||
40 | { | ||
41 | int err = 0; | ||
42 | |||
43 | nvgpu_log_fn(g, " "); | ||
44 | |||
45 | if (!g->can_elpg) { | ||
46 | return 0; | ||
47 | } | ||
48 | |||
49 | nvgpu_mutex_acquire(&g->cg_pg_lock); | ||
50 | if (g->elpg_enabled) { | ||
51 | err = nvgpu_pmu_pg_global_enable(g, true); | ||
52 | } | ||
53 | nvgpu_mutex_release(&g->cg_pg_lock); | ||
54 | return err; | ||
55 | } | ||
56 | |||
57 | int nvgpu_pg_elpg_disable(struct gk20a *g) | ||
58 | { | ||
59 | int err = 0; | ||
60 | |||
61 | nvgpu_log_fn(g, " "); | ||
62 | |||
63 | if (!g->can_elpg) { | ||
64 | return 0; | ||
65 | } | ||
66 | |||
67 | nvgpu_mutex_acquire(&g->cg_pg_lock); | ||
68 | if (g->elpg_enabled) { | ||
69 | err = nvgpu_pmu_pg_global_enable(g, false); | ||
70 | } | ||
71 | nvgpu_mutex_release(&g->cg_pg_lock); | ||
72 | return err; | ||
73 | } | ||
74 | |||
75 | int nvgpu_pg_elpg_set_elpg_enabled(struct gk20a *g, bool enable) | ||
76 | { | ||
77 | int err = 0; | ||
78 | bool change_mode = false; | ||
79 | |||
80 | nvgpu_log_fn(g, " "); | ||
81 | |||
82 | if (!g->can_elpg) { | ||
83 | return 0; | ||
84 | } | ||
85 | |||
86 | nvgpu_mutex_acquire(&g->cg_pg_lock); | ||
87 | if (enable) { | ||
88 | if (!g->elpg_enabled) { | ||
89 | change_mode = true; | ||
90 | g->elpg_enabled = true; | ||
91 | } | ||
92 | } else { | ||
93 | if (g->elpg_enabled) { | ||
94 | change_mode = true; | ||
95 | g->elpg_enabled = false; | ||
96 | } | ||
97 | } | ||
98 | if (!change_mode) { | ||
99 | goto done; | ||
100 | } | ||
101 | |||
102 | err = nvgpu_pmu_pg_global_enable(g, enable); | ||
103 | done: | ||
104 | nvgpu_mutex_release(&g->cg_pg_lock); | ||
105 | return err; | ||
106 | } | ||