summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2017-05-23 13:21:14 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-05-30 16:24:35 -0400
commit66a2511a366113fa4d42dc500c9df9b348d9f208 (patch)
tree5d2367412887214d040d9ade1f1d48c93c434a46 /drivers/gpu/nvgpu/gk20a
parentb817e9e207cca88698d28b6b4ab410f03d715171 (diff)
gpu: nvgpu: Begin removing variables in struct gk20a
Begin removing all of the myriad flag variables in struct gk20a and replace that with one API that checks for flags being enabled or disabled. The API is as follows: bool nvgpu_is_enabled(struct gk20a *g, int flag); bool __nvgpu_set_enabled(struct gk20a *g, int flag, bool state); These APIs allow many of the gk20a flags to be replaced by defines. This makes flag usage consistent and saves a small amount of memory in struct gk20a. Also it makes struct gk20a easier to read since there's less clutter scattered through out. JIRA NVGPU-84 Change-Id: I6525cecbe97c4e8379e5f53e29ef0b4dbd1a7fc2 Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: http://git-master/r/1488049 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a')
-rw-r--r--drivers/gpu/nvgpu/gk20a/channel_gk20a.c5
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a.c7
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a.h12
-rw-r--r--drivers/gpu/nvgpu/gk20a/gr_ctx_gk20a.c3
-rw-r--r--drivers/gpu/nvgpu/gk20a/gr_gk20a.c9
-rw-r--r--drivers/gpu/nvgpu/gk20a/ltc_common.c3
-rw-r--r--drivers/gpu/nvgpu/gk20a/ltc_gk20a.c3
-rw-r--r--drivers/gpu/nvgpu/gk20a/mm_gk20a.c7
-rw-r--r--drivers/gpu/nvgpu/gk20a/priv_ring_gk20a.c5
-rw-r--r--drivers/gpu/nvgpu/gk20a/therm_gk20a.c4
10 files changed, 35 insertions, 23 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c
index 936e4d04..571570d8 100644
--- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c
@@ -29,6 +29,7 @@
29#include <nvgpu/list.h> 29#include <nvgpu/list.h>
30#include <nvgpu/circ_buf.h> 30#include <nvgpu/circ_buf.h>
31#include <nvgpu/cond.h> 31#include <nvgpu/cond.h>
32#include <nvgpu/enabled.h>
32 33
33#include "gk20a.h" 34#include "gk20a.h"
34#include "debug_gk20a.h" 35#include "debug_gk20a.h"
@@ -126,7 +127,7 @@ static void free_channel(struct fifo_gk20a *f,
126 * On teardown it is not possible to dereference platform, but ignoring 127 * On teardown it is not possible to dereference platform, but ignoring
127 * this is fine then because no new channels would be created. 128 * this is fine then because no new channels would be created.
128 */ 129 */
129 if (!g->driver_is_dying) { 130 if (!nvgpu_is_enabled(g, NVGPU_DRIVER_IS_DYING)) {
130 if (g->aggressive_sync_destroy_thresh && 131 if (g->aggressive_sync_destroy_thresh &&
131 (f->used_channels < 132 (f->used_channels <
132 g->aggressive_sync_destroy_thresh)) 133 g->aggressive_sync_destroy_thresh))
@@ -2418,7 +2419,7 @@ int gk20a_submit_channel_gpfifo(struct channel_gk20a *c,
2418 struct nvgpu_gpfifo __user *user_gpfifo = args ? 2419 struct nvgpu_gpfifo __user *user_gpfifo = args ?
2419 (struct nvgpu_gpfifo __user *)(uintptr_t)args->gpfifo : NULL; 2420 (struct nvgpu_gpfifo __user *)(uintptr_t)args->gpfifo : NULL;
2420 2421
2421 if (g->driver_is_dying) 2422 if (nvgpu_is_enabled(g, NVGPU_DRIVER_IS_DYING))
2422 return -ENODEV; 2423 return -ENODEV;
2423 2424
2424 if (c->has_timedout) 2425 if (c->has_timedout)
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.c b/drivers/gpu/nvgpu/gk20a/gk20a.c
index f4e7fe45..31b0a771 100644
--- a/drivers/gpu/nvgpu/gk20a/gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/gk20a.c
@@ -23,6 +23,7 @@
23#include <nvgpu/allocator.h> 23#include <nvgpu/allocator.h>
24#include <nvgpu/timers.h> 24#include <nvgpu/timers.h>
25#include <nvgpu/soc.h> 25#include <nvgpu/soc.h>
26#include <nvgpu/enabled.h>
26 27
27#include <trace/events/gk20a.h> 28#include <trace/events/gk20a.h>
28 29
@@ -364,20 +365,20 @@ done:
364 */ 365 */
365int gk20a_can_busy(struct gk20a *g) 366int gk20a_can_busy(struct gk20a *g)
366{ 367{
367 if (g->driver_is_dying) 368 if (nvgpu_is_enabled(g, NVGPU_DRIVER_IS_DYING))
368 return 0; 369 return 0;
369 return 1; 370 return 1;
370} 371}
371 372
372/* 373/*
373 * Start the process for unloading the driver. Set g->driver_is_dying. 374 * Start the process for unloading the driver. Set NVGPU_DRIVER_IS_DYING.
374 */ 375 */
375void gk20a_driver_start_unload(struct gk20a *g) 376void gk20a_driver_start_unload(struct gk20a *g)
376{ 377{
377 gk20a_dbg(gpu_dbg_shutdown, "Driver is now going down!\n"); 378 gk20a_dbg(gpu_dbg_shutdown, "Driver is now going down!\n");
378 379
379 down_write(&g->busy_lock); 380 down_write(&g->busy_lock);
380 g->driver_is_dying = 1; 381 __nvgpu_set_enabled(g, NVGPU_DRIVER_IS_DYING, true);
381 up_write(&g->busy_lock); 382 up_write(&g->busy_lock);
382 383
383 if (g->is_virtual) 384 if (g->is_virtual)
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h
index 10417084..689fafb1 100644
--- a/drivers/gpu/nvgpu/gk20a/gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/gk20a.h
@@ -1,8 +1,8 @@
1/* 1/*
2 * GK20A Graphics
3 *
4 * Copyright (c) 2011-2017, NVIDIA CORPORATION. All rights reserved. 2 * Copyright (c) 2011-2017, NVIDIA CORPORATION. All rights reserved.
5 * 3 *
4 * GK20A Graphics
5 *
6 * This program is free software; you can redistribute it and/or modify it 6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License, 7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation. 8 * version 2, as published by the Free Software Foundation.
@@ -971,15 +971,17 @@ struct gk20a {
971 struct device *dev; 971 struct device *dev;
972 struct platform_device *host1x_dev; 972 struct platform_device *host1x_dev;
973 973
974 /*
975 * Used by <nvgpu/enabled.h>. Do not access directly!
976 */
977 unsigned long *enabled_flags;
978
974 atomic_t usage_count; 979 atomic_t usage_count;
975 int driver_is_dying;
976 980
977 atomic_t nonstall_ops; 981 atomic_t nonstall_ops;
978 struct work_struct nonstall_fn_work; 982 struct work_struct nonstall_fn_work;
979 struct workqueue_struct *nonstall_work_queue; 983 struct workqueue_struct *nonstall_work_queue;
980 984
981 bool is_fmodel;
982
983 struct kref refcount; 985 struct kref refcount;
984 986
985 struct resource *reg_mem; 987 struct resource *reg_mem;
diff --git a/drivers/gpu/nvgpu/gk20a/gr_ctx_gk20a.c b/drivers/gpu/nvgpu/gk20a/gr_ctx_gk20a.c
index 32c95e2f..b0a90fc8 100644
--- a/drivers/gpu/nvgpu/gk20a/gr_ctx_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/gr_ctx_gk20a.c
@@ -23,6 +23,7 @@
23#include <nvgpu/kmem.h> 23#include <nvgpu/kmem.h>
24#include <nvgpu/log.h> 24#include <nvgpu/log.h>
25#include <nvgpu/firmware.h> 25#include <nvgpu/firmware.h>
26#include <nvgpu/enabled.h>
26 27
27#include "gk20a.h" 28#include "gk20a.h"
28#include "gr_ctx_gk20a.h" 29#include "gr_ctx_gk20a.h"
@@ -442,7 +443,7 @@ done:
442 443
443int gr_gk20a_init_ctx_vars(struct gk20a *g, struct gr_gk20a *gr) 444int gr_gk20a_init_ctx_vars(struct gk20a *g, struct gr_gk20a *gr)
444{ 445{
445 if (g->is_fmodel) 446 if (nvgpu_is_enabled(g, NVGPU_IS_FMODEL))
446 return gr_gk20a_init_ctx_vars_sim(g, gr); 447 return gr_gk20a_init_ctx_vars_sim(g, gr);
447 else 448 else
448 return gr_gk20a_init_ctx_vars_fw(g, gr); 449 return gr_gk20a_init_ctx_vars_fw(g, gr);
diff --git a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c
index 2b5d809f..c12f49ac 100644
--- a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c
@@ -29,6 +29,7 @@
29#include <nvgpu/sort.h> 29#include <nvgpu/sort.h>
30#include <nvgpu/bug.h> 30#include <nvgpu/bug.h>
31#include <nvgpu/firmware.h> 31#include <nvgpu/firmware.h>
32#include <nvgpu/enabled.h>
32 33
33#include "gk20a.h" 34#include "gk20a.h"
34#include "kind_gk20a.h" 35#include "kind_gk20a.h"
@@ -386,7 +387,7 @@ int gr_gk20a_wait_fe_idle(struct gk20a *g, unsigned long duration_ms,
386 u32 delay = expect_delay; 387 u32 delay = expect_delay;
387 struct nvgpu_timeout timeout; 388 struct nvgpu_timeout timeout;
388 389
389 if (g->is_fmodel) 390 if (nvgpu_is_enabled(g, NVGPU_IS_FMODEL))
390 return 0; 391 return 0;
391 392
392 gk20a_dbg_fn(""); 393 gk20a_dbg_fn("");
@@ -1597,7 +1598,7 @@ static int gr_gk20a_init_golden_ctx_image(struct gk20a *g,
1597 if (gr->ctx_vars.golden_image_initialized) { 1598 if (gr->ctx_vars.golden_image_initialized) {
1598 goto clean_up; 1599 goto clean_up;
1599 } 1600 }
1600 if (!g->is_fmodel) { 1601 if (!nvgpu_is_enabled(g, NVGPU_IS_FMODEL)) {
1601 struct nvgpu_timeout timeout; 1602 struct nvgpu_timeout timeout;
1602 1603
1603 nvgpu_timeout_init(g, &timeout, 1604 nvgpu_timeout_init(g, &timeout,
@@ -1642,7 +1643,7 @@ static int gr_gk20a_init_golden_ctx_image(struct gk20a *g,
1642 gk20a_readl(g, gr_fecs_ctxsw_reset_ctl_r()); 1643 gk20a_readl(g, gr_fecs_ctxsw_reset_ctl_r());
1643 nvgpu_udelay(10); 1644 nvgpu_udelay(10);
1644 1645
1645 if (!g->is_fmodel) { 1646 if (!nvgpu_is_enabled(g, NVGPU_IS_FMODEL)) {
1646 struct nvgpu_timeout timeout; 1647 struct nvgpu_timeout timeout;
1647 1648
1648 nvgpu_timeout_init(g, &timeout, 1649 nvgpu_timeout_init(g, &timeout,
@@ -2582,7 +2583,7 @@ int gr_gk20a_load_ctxsw_ucode(struct gk20a *g)
2582 2583
2583 gk20a_dbg_fn(""); 2584 gk20a_dbg_fn("");
2584 2585
2585 if (g->is_fmodel) { 2586 if (nvgpu_is_enabled(g, NVGPU_IS_FMODEL)) {
2586 gk20a_writel(g, gr_fecs_ctxsw_mailbox_r(7), 2587 gk20a_writel(g, gr_fecs_ctxsw_mailbox_r(7),
2587 gr_fecs_ctxsw_mailbox_value_f(0xc0de7777)); 2588 gr_fecs_ctxsw_mailbox_value_f(0xc0de7777));
2588 gk20a_writel(g, gr_gpccs_ctxsw_mailbox_r(7), 2589 gk20a_writel(g, gr_gpccs_ctxsw_mailbox_r(7),
diff --git a/drivers/gpu/nvgpu/gk20a/ltc_common.c b/drivers/gpu/nvgpu/gk20a/ltc_common.c
index 1958c11c..2b015fa0 100644
--- a/drivers/gpu/nvgpu/gk20a/ltc_common.c
+++ b/drivers/gpu/nvgpu/gk20a/ltc_common.c
@@ -19,6 +19,7 @@
19 */ 19 */
20 20
21#include <nvgpu/dma.h> 21#include <nvgpu/dma.h>
22#include <nvgpu/enabled.h>
22 23
23#include "gk20a.h" 24#include "gk20a.h"
24#include "gr_gk20a.h" 25#include "gr_gk20a.h"
@@ -92,7 +93,7 @@ static void gk20a_ltc_init_cbc(struct gk20a *g, struct gr_gk20a *gr)
92 u64 compbit_store_iova; 93 u64 compbit_store_iova;
93 u64 compbit_base_post_divide64; 94 u64 compbit_base_post_divide64;
94 95
95 if (g->is_fmodel) 96 if (nvgpu_is_enabled(g, NVGPU_IS_FMODEL))
96 compbit_store_iova = gk20a_mem_phys(&gr->compbit_store.mem); 97 compbit_store_iova = gk20a_mem_phys(&gr->compbit_store.mem);
97 else 98 else
98 compbit_store_iova = g->ops.mm.get_iova_addr(g, 99 compbit_store_iova = g->ops.mm.get_iova_addr(g,
diff --git a/drivers/gpu/nvgpu/gk20a/ltc_gk20a.c b/drivers/gpu/nvgpu/gk20a/ltc_gk20a.c
index 23576ce0..8867202f 100644
--- a/drivers/gpu/nvgpu/gk20a/ltc_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/ltc_gk20a.c
@@ -20,6 +20,7 @@
20#include <nvgpu/timers.h> 20#include <nvgpu/timers.h>
21#include <nvgpu/log.h> 21#include <nvgpu/log.h>
22#include <nvgpu/bug.h> 22#include <nvgpu/bug.h>
23#include <nvgpu/enabled.h>
23 24
24#include "gk20a.h" 25#include "gk20a.h"
25#include "ltc_gk20a.h" 26#include "ltc_gk20a.h"
@@ -83,7 +84,7 @@ static int gk20a_ltc_init_comptags(struct gk20a *g, struct gr_gk20a *gr)
83 gk20a_dbg_info("max comptag lines : %d", 84 gk20a_dbg_info("max comptag lines : %d",
84 max_comptag_lines); 85 max_comptag_lines);
85 86
86 if (g->is_fmodel) 87 if (nvgpu_is_enabled(g, NVGPU_IS_FMODEL))
87 err = gk20a_ltc_alloc_phys_cbc(g, compbit_backing_size); 88 err = gk20a_ltc_alloc_phys_cbc(g, compbit_backing_size);
88 else 89 else
89 err = gk20a_ltc_alloc_virt_cbc(g, compbit_backing_size); 90 err = gk20a_ltc_alloc_virt_cbc(g, compbit_backing_size);
diff --git a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
index 17fa0c17..786a6693 100644
--- a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c
@@ -39,6 +39,7 @@
39#include <nvgpu/log.h> 39#include <nvgpu/log.h>
40#include <nvgpu/bug.h> 40#include <nvgpu/bug.h>
41#include <nvgpu/log2.h> 41#include <nvgpu/log2.h>
42#include <nvgpu/enabled.h>
42 43
43#include <nvgpu/linux/dma.h> 44#include <nvgpu/linux/dma.h>
44 45
@@ -824,7 +825,7 @@ void free_gmmu_pages(struct vm_gk20a *vm,
824 if (entry->woffset) /* fake shadow mem */ 825 if (entry->woffset) /* fake shadow mem */
825 return; 826 return;
826 827
827 if (g->is_fmodel) { 828 if (nvgpu_is_enabled(g, NVGPU_IS_FMODEL)) {
828 free_gmmu_phys_pages(vm, entry); 829 free_gmmu_phys_pages(vm, entry);
829 return; 830 return;
830 } 831 }
@@ -836,7 +837,7 @@ int map_gmmu_pages(struct gk20a *g, struct gk20a_mm_entry *entry)
836{ 837{
837 gk20a_dbg_fn(""); 838 gk20a_dbg_fn("");
838 839
839 if (g->is_fmodel) 840 if (nvgpu_is_enabled(g, NVGPU_IS_FMODEL))
840 return map_gmmu_phys_pages(entry); 841 return map_gmmu_phys_pages(entry);
841 842
842 if (IS_ENABLED(CONFIG_ARM64)) { 843 if (IS_ENABLED(CONFIG_ARM64)) {
@@ -860,7 +861,7 @@ void unmap_gmmu_pages(struct gk20a *g, struct gk20a_mm_entry *entry)
860{ 861{
861 gk20a_dbg_fn(""); 862 gk20a_dbg_fn("");
862 863
863 if (g->is_fmodel) { 864 if (nvgpu_is_enabled(g, NVGPU_IS_FMODEL)) {
864 unmap_gmmu_phys_pages(entry); 865 unmap_gmmu_phys_pages(entry);
865 return; 866 return;
866 } 867 }
diff --git a/drivers/gpu/nvgpu/gk20a/priv_ring_gk20a.c b/drivers/gpu/nvgpu/gk20a/priv_ring_gk20a.c
index 2f837bfc..dbab6b4b 100644
--- a/drivers/gpu/nvgpu/gk20a/priv_ring_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/priv_ring_gk20a.c
@@ -20,6 +20,7 @@
20 20
21#include <nvgpu/log.h> 21#include <nvgpu/log.h>
22#include <nvgpu/timers.h> 22#include <nvgpu/timers.h>
23#include <nvgpu/enabled.h>
23 24
24#include <nvgpu/hw/gk20a/hw_mc_gk20a.h> 25#include <nvgpu/hw/gk20a/hw_mc_gk20a.h>
25#include <nvgpu/hw/gk20a/hw_pri_ringmaster_gk20a.h> 26#include <nvgpu/hw/gk20a/hw_pri_ringmaster_gk20a.h>
@@ -28,7 +29,7 @@
28 29
29void gk20a_enable_priv_ring(struct gk20a *g) 30void gk20a_enable_priv_ring(struct gk20a *g)
30{ 31{
31 if (g->is_fmodel) 32 if (nvgpu_is_enabled(g, NVGPU_IS_FMODEL))
32 return; 33 return;
33 34
34 if (g->ops.clock_gating.slcg_priring_load_gating_prod) 35 if (g->ops.clock_gating.slcg_priring_load_gating_prod)
@@ -53,7 +54,7 @@ void gk20a_priv_ring_isr(struct gk20a *g)
53 u32 gpc; 54 u32 gpc;
54 u32 gpc_stride = nvgpu_get_litter_value(g, GPU_LIT_GPC_STRIDE); 55 u32 gpc_stride = nvgpu_get_litter_value(g, GPU_LIT_GPC_STRIDE);
55 56
56 if (g->is_fmodel) 57 if (nvgpu_is_enabled(g, NVGPU_IS_FMODEL))
57 return; 58 return;
58 59
59 status0 = gk20a_readl(g, pri_ringmaster_intr_status0_r()); 60 status0 = gk20a_readl(g, pri_ringmaster_intr_status0_r());
diff --git a/drivers/gpu/nvgpu/gk20a/therm_gk20a.c b/drivers/gpu/nvgpu/gk20a/therm_gk20a.c
index b700c735..00159fae 100644
--- a/drivers/gpu/nvgpu/gk20a/therm_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/therm_gk20a.c
@@ -16,6 +16,8 @@
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */ 17 */
18 18
19#include <nvgpu/enabled.h>
20
19#include "gk20a.h" 21#include "gk20a.h"
20 22
21#include <nvgpu/hw/gk20a/hw_gr_gk20a.h> 23#include <nvgpu/hw/gk20a/hw_gr_gk20a.h>
@@ -123,7 +125,7 @@ int gk20a_elcg_init_idle_filters(struct gk20a *g)
123 active_engine_id = f->active_engines_list[engine_id]; 125 active_engine_id = f->active_engines_list[engine_id];
124 gate_ctrl = gk20a_readl(g, therm_gate_ctrl_r(active_engine_id)); 126 gate_ctrl = gk20a_readl(g, therm_gate_ctrl_r(active_engine_id));
125 127
126 if (g->is_fmodel) { 128 if (nvgpu_is_enabled(g, NVGPU_IS_FMODEL)) {
127 gate_ctrl = set_field(gate_ctrl, 129 gate_ctrl = set_field(gate_ctrl,
128 therm_gate_ctrl_eng_delay_after_m(), 130 therm_gate_ctrl_eng_delay_after_m(),
129 therm_gate_ctrl_eng_delay_after_f(4)); 131 therm_gate_ctrl_eng_delay_after_f(4));