From 66a2511a366113fa4d42dc500c9df9b348d9f208 Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Tue, 23 May 2017 18:21:14 +0100 Subject: 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 Reviewed-on: http://git-master/r/1488049 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/gk20a/channel_gk20a.c | 5 +++-- drivers/gpu/nvgpu/gk20a/gk20a.c | 7 ++++--- drivers/gpu/nvgpu/gk20a/gk20a.h | 12 +++++++----- drivers/gpu/nvgpu/gk20a/gr_ctx_gk20a.c | 3 ++- drivers/gpu/nvgpu/gk20a/gr_gk20a.c | 9 +++++---- drivers/gpu/nvgpu/gk20a/ltc_common.c | 3 ++- drivers/gpu/nvgpu/gk20a/ltc_gk20a.c | 3 ++- drivers/gpu/nvgpu/gk20a/mm_gk20a.c | 7 ++++--- drivers/gpu/nvgpu/gk20a/priv_ring_gk20a.c | 5 +++-- drivers/gpu/nvgpu/gk20a/therm_gk20a.c | 4 +++- 10 files changed, 35 insertions(+), 23 deletions(-) (limited to 'drivers/gpu/nvgpu/gk20a') 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 @@ #include #include #include +#include #include "gk20a.h" #include "debug_gk20a.h" @@ -126,7 +127,7 @@ static void free_channel(struct fifo_gk20a *f, * On teardown it is not possible to dereference platform, but ignoring * this is fine then because no new channels would be created. */ - if (!g->driver_is_dying) { + if (!nvgpu_is_enabled(g, NVGPU_DRIVER_IS_DYING)) { if (g->aggressive_sync_destroy_thresh && (f->used_channels < g->aggressive_sync_destroy_thresh)) @@ -2418,7 +2419,7 @@ int gk20a_submit_channel_gpfifo(struct channel_gk20a *c, struct nvgpu_gpfifo __user *user_gpfifo = args ? (struct nvgpu_gpfifo __user *)(uintptr_t)args->gpfifo : NULL; - if (g->driver_is_dying) + if (nvgpu_is_enabled(g, NVGPU_DRIVER_IS_DYING)) return -ENODEV; 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 @@ #include #include #include +#include #include @@ -364,20 +365,20 @@ done: */ int gk20a_can_busy(struct gk20a *g) { - if (g->driver_is_dying) + if (nvgpu_is_enabled(g, NVGPU_DRIVER_IS_DYING)) return 0; return 1; } /* - * Start the process for unloading the driver. Set g->driver_is_dying. + * Start the process for unloading the driver. Set NVGPU_DRIVER_IS_DYING. */ void gk20a_driver_start_unload(struct gk20a *g) { gk20a_dbg(gpu_dbg_shutdown, "Driver is now going down!\n"); down_write(&g->busy_lock); - g->driver_is_dying = 1; + __nvgpu_set_enabled(g, NVGPU_DRIVER_IS_DYING, true); up_write(&g->busy_lock); 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 @@ /* - * GK20A Graphics - * * Copyright (c) 2011-2017, NVIDIA CORPORATION. All rights reserved. * + * GK20A Graphics + * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. @@ -971,15 +971,17 @@ struct gk20a { struct device *dev; struct platform_device *host1x_dev; + /* + * Used by . Do not access directly! + */ + unsigned long *enabled_flags; + atomic_t usage_count; - int driver_is_dying; atomic_t nonstall_ops; struct work_struct nonstall_fn_work; struct workqueue_struct *nonstall_work_queue; - bool is_fmodel; - struct kref refcount; 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 @@ #include #include #include +#include #include "gk20a.h" #include "gr_ctx_gk20a.h" @@ -442,7 +443,7 @@ done: int gr_gk20a_init_ctx_vars(struct gk20a *g, struct gr_gk20a *gr) { - if (g->is_fmodel) + if (nvgpu_is_enabled(g, NVGPU_IS_FMODEL)) return gr_gk20a_init_ctx_vars_sim(g, gr); else 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 @@ #include #include #include +#include #include "gk20a.h" #include "kind_gk20a.h" @@ -386,7 +387,7 @@ int gr_gk20a_wait_fe_idle(struct gk20a *g, unsigned long duration_ms, u32 delay = expect_delay; struct nvgpu_timeout timeout; - if (g->is_fmodel) + if (nvgpu_is_enabled(g, NVGPU_IS_FMODEL)) return 0; gk20a_dbg_fn(""); @@ -1597,7 +1598,7 @@ static int gr_gk20a_init_golden_ctx_image(struct gk20a *g, if (gr->ctx_vars.golden_image_initialized) { goto clean_up; } - if (!g->is_fmodel) { + if (!nvgpu_is_enabled(g, NVGPU_IS_FMODEL)) { struct nvgpu_timeout timeout; nvgpu_timeout_init(g, &timeout, @@ -1642,7 +1643,7 @@ static int gr_gk20a_init_golden_ctx_image(struct gk20a *g, gk20a_readl(g, gr_fecs_ctxsw_reset_ctl_r()); nvgpu_udelay(10); - if (!g->is_fmodel) { + if (!nvgpu_is_enabled(g, NVGPU_IS_FMODEL)) { struct nvgpu_timeout timeout; nvgpu_timeout_init(g, &timeout, @@ -2582,7 +2583,7 @@ int gr_gk20a_load_ctxsw_ucode(struct gk20a *g) gk20a_dbg_fn(""); - if (g->is_fmodel) { + if (nvgpu_is_enabled(g, NVGPU_IS_FMODEL)) { gk20a_writel(g, gr_fecs_ctxsw_mailbox_r(7), gr_fecs_ctxsw_mailbox_value_f(0xc0de7777)); 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 @@ */ #include +#include #include "gk20a.h" #include "gr_gk20a.h" @@ -92,7 +93,7 @@ static void gk20a_ltc_init_cbc(struct gk20a *g, struct gr_gk20a *gr) u64 compbit_store_iova; u64 compbit_base_post_divide64; - if (g->is_fmodel) + if (nvgpu_is_enabled(g, NVGPU_IS_FMODEL)) compbit_store_iova = gk20a_mem_phys(&gr->compbit_store.mem); else 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 @@ #include #include #include +#include #include "gk20a.h" #include "ltc_gk20a.h" @@ -83,7 +84,7 @@ static int gk20a_ltc_init_comptags(struct gk20a *g, struct gr_gk20a *gr) gk20a_dbg_info("max comptag lines : %d", max_comptag_lines); - if (g->is_fmodel) + if (nvgpu_is_enabled(g, NVGPU_IS_FMODEL)) err = gk20a_ltc_alloc_phys_cbc(g, compbit_backing_size); else 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 @@ #include #include #include +#include #include @@ -824,7 +825,7 @@ void free_gmmu_pages(struct vm_gk20a *vm, if (entry->woffset) /* fake shadow mem */ return; - if (g->is_fmodel) { + if (nvgpu_is_enabled(g, NVGPU_IS_FMODEL)) { free_gmmu_phys_pages(vm, entry); return; } @@ -836,7 +837,7 @@ int map_gmmu_pages(struct gk20a *g, struct gk20a_mm_entry *entry) { gk20a_dbg_fn(""); - if (g->is_fmodel) + if (nvgpu_is_enabled(g, NVGPU_IS_FMODEL)) return map_gmmu_phys_pages(entry); if (IS_ENABLED(CONFIG_ARM64)) { @@ -860,7 +861,7 @@ void unmap_gmmu_pages(struct gk20a *g, struct gk20a_mm_entry *entry) { gk20a_dbg_fn(""); - if (g->is_fmodel) { + if (nvgpu_is_enabled(g, NVGPU_IS_FMODEL)) { unmap_gmmu_phys_pages(entry); return; } 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 @@ #include #include +#include #include #include @@ -28,7 +29,7 @@ void gk20a_enable_priv_ring(struct gk20a *g) { - if (g->is_fmodel) + if (nvgpu_is_enabled(g, NVGPU_IS_FMODEL)) return; if (g->ops.clock_gating.slcg_priring_load_gating_prod) @@ -53,7 +54,7 @@ void gk20a_priv_ring_isr(struct gk20a *g) u32 gpc; u32 gpc_stride = nvgpu_get_litter_value(g, GPU_LIT_GPC_STRIDE); - if (g->is_fmodel) + if (nvgpu_is_enabled(g, NVGPU_IS_FMODEL)) return; 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 @@ * along with this program. If not, see . */ +#include + #include "gk20a.h" #include @@ -123,7 +125,7 @@ int gk20a_elcg_init_idle_filters(struct gk20a *g) active_engine_id = f->active_engines_list[engine_id]; gate_ctrl = gk20a_readl(g, therm_gate_ctrl_r(active_engine_id)); - if (g->is_fmodel) { + if (nvgpu_is_enabled(g, NVGPU_IS_FMODEL)) { gate_ctrl = set_field(gate_ctrl, therm_gate_ctrl_eng_delay_after_m(), therm_gate_ctrl_eng_delay_after_f(4)); -- cgit v1.2.2