summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/common
diff options
context:
space:
mode:
authorDebarshi Dutta <ddutta@nvidia.com>2019-05-03 04:41:52 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2019-05-09 17:42:14 -0400
commit4d8ad643d67ac4044f76976c4085a35fcc5d4095 (patch)
tree6b829f294bf4a6ff453cf08edd11bdaf5e620abb /drivers/gpu/nvgpu/common
parentbdaacf544127fcfaa474ccb5466aa93f81382416 (diff)
gpu: nvgpu: wait for gr.initialized before changing cg/pg
set gr.initialized to false in the beginning of gk20a_gr_reset() and set it to true at the end of successful execution of gk20a_gr_reset. Use gk20a_gr_wait_initialized() to enable/disable cg/pg functions to make sure engine is out of reset and initialized. Bug 2092051 Bug 2429295 Bug 2484211 Bug 1890287 Change-Id: Ic7b0b71382c6d852a625c603dad8609c43b7f20f Signed-off-by: Seema Khowala <seemaj@nvidia.com> Signed-off-by: Debarshi Dutta <ddutta@nvidia.com> (cherry-picked from 7e2f124fd12caf37172f12da8de65093622941a5 in dev-kernel) Reviewed-on: https://git-master.nvidia.com/r/2111038 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')
-rw-r--r--drivers/gpu/nvgpu/common/power_features/cg/cg.c50
-rw-r--r--drivers/gpu/nvgpu/common/power_features/pg/pg.c6
-rw-r--r--drivers/gpu/nvgpu/common/power_features/power_features.c4
3 files changed, 60 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/common/power_features/cg/cg.c b/drivers/gpu/nvgpu/common/power_features/cg/cg.c
index 66b95226..a538c44b 100644
--- a/drivers/gpu/nvgpu/common/power_features/cg/cg.c
+++ b/drivers/gpu/nvgpu/common/power_features/cg/cg.c
@@ -54,6 +54,36 @@ static void nvgpu_cg_set_mode(struct gk20a *g, int cgmode, int mode_config)
54 } 54 }
55} 55}
56 56
57void nvgpu_cg_elcg_enable_no_wait(struct gk20a *g)
58{
59 nvgpu_log_fn(g, " ");
60
61 if (!nvgpu_is_enabled(g, NVGPU_GPU_CAN_ELCG)) {
62 return;
63 }
64
65 nvgpu_mutex_acquire(&g->cg_pg_lock);
66 if (g->elcg_enabled) {
67 nvgpu_cg_set_mode(g, ELCG_MODE, ELCG_AUTO);
68 }
69 nvgpu_mutex_release(&g->cg_pg_lock);
70}
71
72void nvgpu_cg_elcg_disable_no_wait(struct gk20a *g)
73{
74 nvgpu_log_fn(g, " ");
75
76 if (!nvgpu_is_enabled(g, NVGPU_GPU_CAN_ELCG)) {
77 return;
78 }
79
80 nvgpu_mutex_acquire(&g->cg_pg_lock);
81 if (g->elcg_enabled) {
82 nvgpu_cg_set_mode(g, ELCG_MODE, ELCG_RUN);
83 }
84 nvgpu_mutex_release(&g->cg_pg_lock);
85}
86
57void nvgpu_cg_elcg_enable(struct gk20a *g) 87void nvgpu_cg_elcg_enable(struct gk20a *g)
58{ 88{
59 nvgpu_log_fn(g, " "); 89 nvgpu_log_fn(g, " ");
@@ -62,6 +92,8 @@ void nvgpu_cg_elcg_enable(struct gk20a *g)
62 return; 92 return;
63 } 93 }
64 94
95 gk20a_gr_wait_initialized(g);
96
65 nvgpu_mutex_acquire(&g->cg_pg_lock); 97 nvgpu_mutex_acquire(&g->cg_pg_lock);
66 if (g->elcg_enabled) { 98 if (g->elcg_enabled) {
67 nvgpu_cg_set_mode(g, ELCG_MODE, ELCG_AUTO); 99 nvgpu_cg_set_mode(g, ELCG_MODE, ELCG_AUTO);
@@ -77,6 +109,8 @@ void nvgpu_cg_elcg_disable(struct gk20a *g)
77 return; 109 return;
78 } 110 }
79 111
112 gk20a_gr_wait_initialized(g);
113
80 nvgpu_mutex_acquire(&g->cg_pg_lock); 114 nvgpu_mutex_acquire(&g->cg_pg_lock);
81 if (g->elcg_enabled) { 115 if (g->elcg_enabled) {
82 nvgpu_cg_set_mode(g, ELCG_MODE, ELCG_RUN); 116 nvgpu_cg_set_mode(g, ELCG_MODE, ELCG_RUN);
@@ -93,6 +127,8 @@ void nvgpu_cg_blcg_mode_enable(struct gk20a *g)
93 return; 127 return;
94 } 128 }
95 129
130 gk20a_gr_wait_initialized(g);
131
96 nvgpu_mutex_acquire(&g->cg_pg_lock); 132 nvgpu_mutex_acquire(&g->cg_pg_lock);
97 if (g->blcg_enabled) { 133 if (g->blcg_enabled) {
98 nvgpu_cg_set_mode(g, BLCG_MODE, BLCG_AUTO); 134 nvgpu_cg_set_mode(g, BLCG_MODE, BLCG_AUTO);
@@ -109,6 +145,8 @@ void nvgpu_cg_blcg_mode_disable(struct gk20a *g)
109 return; 145 return;
110 } 146 }
111 147
148 gk20a_gr_wait_initialized(g);
149
112 nvgpu_mutex_acquire(&g->cg_pg_lock); 150 nvgpu_mutex_acquire(&g->cg_pg_lock);
113 if (g->blcg_enabled) { 151 if (g->blcg_enabled) {
114 nvgpu_cg_set_mode(g, BLCG_MODE, BLCG_RUN); 152 nvgpu_cg_set_mode(g, BLCG_MODE, BLCG_RUN);
@@ -257,6 +295,9 @@ void nvgpu_cg_slcg_gr_perf_ltc_load_enable(struct gk20a *g)
257 if (!nvgpu_is_enabled(g, NVGPU_GPU_CAN_SLCG)) { 295 if (!nvgpu_is_enabled(g, NVGPU_GPU_CAN_SLCG)) {
258 return; 296 return;
259 } 297 }
298
299 gk20a_gr_wait_initialized(g);
300
260 nvgpu_mutex_acquire(&g->cg_pg_lock); 301 nvgpu_mutex_acquire(&g->cg_pg_lock);
261 if (!g->slcg_enabled) { 302 if (!g->slcg_enabled) {
262 goto done; 303 goto done;
@@ -281,6 +322,9 @@ void nvgpu_cg_slcg_gr_perf_ltc_load_disable(struct gk20a *g)
281 if (!nvgpu_is_enabled(g, NVGPU_GPU_CAN_SLCG)) { 322 if (!nvgpu_is_enabled(g, NVGPU_GPU_CAN_SLCG)) {
282 return; 323 return;
283 } 324 }
325
326 gk20a_gr_wait_initialized(g);
327
284 nvgpu_mutex_acquire(&g->cg_pg_lock); 328 nvgpu_mutex_acquire(&g->cg_pg_lock);
285 if (!g->slcg_enabled) { 329 if (!g->slcg_enabled) {
286 goto done; 330 goto done;
@@ -421,6 +465,8 @@ void nvgpu_cg_elcg_set_elcg_enabled(struct gk20a *g, bool enable)
421 return; 465 return;
422 } 466 }
423 467
468 gk20a_gr_wait_initialized(g);
469
424 nvgpu_mutex_release(&g->cg_pg_lock); 470 nvgpu_mutex_release(&g->cg_pg_lock);
425 if (enable) { 471 if (enable) {
426 if (!g->elcg_enabled) { 472 if (!g->elcg_enabled) {
@@ -446,6 +492,8 @@ void nvgpu_cg_blcg_set_blcg_enabled(struct gk20a *g, bool enable)
446 return; 492 return;
447 } 493 }
448 494
495 gk20a_gr_wait_initialized(g);
496
449 nvgpu_mutex_acquire(&g->cg_pg_lock); 497 nvgpu_mutex_acquire(&g->cg_pg_lock);
450 if (enable) { 498 if (enable) {
451 if (!g->blcg_enabled) { 499 if (!g->blcg_enabled) {
@@ -505,6 +553,8 @@ void nvgpu_cg_slcg_set_slcg_enabled(struct gk20a *g, bool enable)
505 return; 553 return;
506 } 554 }
507 555
556 gk20a_gr_wait_initialized(g);
557
508 nvgpu_mutex_acquire(&g->cg_pg_lock); 558 nvgpu_mutex_acquire(&g->cg_pg_lock);
509 if (enable) { 559 if (enable) {
510 if (!g->slcg_enabled) { 560 if (!g->slcg_enabled) {
diff --git a/drivers/gpu/nvgpu/common/power_features/pg/pg.c b/drivers/gpu/nvgpu/common/power_features/pg/pg.c
index fa31f4e3..394c0824 100644
--- a/drivers/gpu/nvgpu/common/power_features/pg/pg.c
+++ b/drivers/gpu/nvgpu/common/power_features/pg/pg.c
@@ -46,6 +46,8 @@ int nvgpu_pg_elpg_enable(struct gk20a *g)
46 return 0; 46 return 0;
47 } 47 }
48 48
49 gk20a_gr_wait_initialized(g);
50
49 nvgpu_mutex_acquire(&g->cg_pg_lock); 51 nvgpu_mutex_acquire(&g->cg_pg_lock);
50 if (g->elpg_enabled) { 52 if (g->elpg_enabled) {
51 err = nvgpu_pmu_pg_global_enable(g, true); 53 err = nvgpu_pmu_pg_global_enable(g, true);
@@ -64,6 +66,8 @@ int nvgpu_pg_elpg_disable(struct gk20a *g)
64 return 0; 66 return 0;
65 } 67 }
66 68
69 gk20a_gr_wait_initialized(g);
70
67 nvgpu_mutex_acquire(&g->cg_pg_lock); 71 nvgpu_mutex_acquire(&g->cg_pg_lock);
68 if (g->elpg_enabled) { 72 if (g->elpg_enabled) {
69 err = nvgpu_pmu_pg_global_enable(g, false); 73 err = nvgpu_pmu_pg_global_enable(g, false);
@@ -83,6 +87,8 @@ int nvgpu_pg_elpg_set_elpg_enabled(struct gk20a *g, bool enable)
83 return 0; 87 return 0;
84 } 88 }
85 89
90 gk20a_gr_wait_initialized(g);
91
86 nvgpu_mutex_acquire(&g->cg_pg_lock); 92 nvgpu_mutex_acquire(&g->cg_pg_lock);
87 if (enable) { 93 if (enable) {
88 if (!g->elpg_enabled) { 94 if (!g->elpg_enabled) {
diff --git a/drivers/gpu/nvgpu/common/power_features/power_features.c b/drivers/gpu/nvgpu/common/power_features/power_features.c
index 792fdc01..7f52ba8e 100644
--- a/drivers/gpu/nvgpu/common/power_features/power_features.c
+++ b/drivers/gpu/nvgpu/common/power_features/power_features.c
@@ -31,6 +31,8 @@ int nvgpu_cg_pg_disable(struct gk20a *g)
31 31
32 nvgpu_log_fn(g, " "); 32 nvgpu_log_fn(g, " ");
33 33
34 gk20a_gr_wait_initialized(g);
35
34 /* disable elpg before clock gating */ 36 /* disable elpg before clock gating */
35 err = nvgpu_pg_elpg_disable(g); 37 err = nvgpu_pg_elpg_disable(g);
36 if (err != 0) { 38 if (err != 0) {
@@ -51,6 +53,8 @@ int nvgpu_cg_pg_enable(struct gk20a *g)
51 53
52 nvgpu_log_fn(g, " "); 54 nvgpu_log_fn(g, " ");
53 55
56 gk20a_gr_wait_initialized(g);
57
54 nvgpu_cg_elcg_enable(g); 58 nvgpu_cg_elcg_enable(g);
55 59
56 nvgpu_cg_blcg_mode_enable(g); 60 nvgpu_cg_blcg_mode_enable(g);