From f403800dce923c8bac982291aee213e1e3afdab0 Mon Sep 17 00:00:00 2001 From: Konsta Holtta Date: Tue, 26 Jun 2018 17:18:17 +0300 Subject: gpu: nvgpu: move can_railgate to enabled.h The g->can_railgate flag is a global constant-ish property like the rest of the flags behind nvgpu_is_enabled() API, so move it there. Bug 200327089 Change-Id: Id1f2f16ea1975a03fb56f10c2f3c8c705574e341 Signed-off-by: Konsta Holtta Reviewed-on: https://git-master.nvidia.com/r/1764266 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/fifo/submit.c | 5 +++-- drivers/gpu/nvgpu/gk20a/gk20a.h | 1 - drivers/gpu/nvgpu/include/nvgpu/enabled.h | 1 + drivers/gpu/nvgpu/os/linux/driver_common.c | 2 +- drivers/gpu/nvgpu/os/linux/module.c | 6 +++--- drivers/gpu/nvgpu/os/linux/pci.c | 2 +- drivers/gpu/nvgpu/os/linux/platform_gk20a_tegra.c | 2 +- drivers/gpu/nvgpu/os/linux/sysfs.c | 19 +++++++++++-------- drivers/gpu/nvgpu/os/linux/vgpu/vgpu_linux.c | 2 +- 9 files changed, 22 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/nvgpu/common/fifo/submit.c b/drivers/gpu/nvgpu/common/fifo/submit.c index f6a79f80..00763036 100644 --- a/drivers/gpu/nvgpu/common/fifo/submit.c +++ b/drivers/gpu/nvgpu/common/fifo/submit.c @@ -368,7 +368,8 @@ static int nvgpu_submit_channel_gpfifo(struct channel_gk20a *c, need_job_tracking = (flags & NVGPU_SUBMIT_FLAGS_FENCE_WAIT) || (flags & NVGPU_SUBMIT_FLAGS_FENCE_GET) || c->timeout.enabled || - (g->can_railgate && !c->deterministic) || + (nvgpu_is_enabled(g, NVGPU_CAN_RAILGATE) + && !c->deterministic) || !skip_buffer_refcounting; if (need_job_tracking) { @@ -405,7 +406,7 @@ static int nvgpu_submit_channel_gpfifo(struct channel_gk20a *c, need_deferred_cleanup = !c->deterministic || need_sync_framework || c->timeout.enabled || - (g->can_railgate && + (nvgpu_is_enabled(g, NVGPU_CAN_RAILGATE) && !c->deterministic) || !skip_buffer_refcounting; diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h index 3c25f8fb..263d0632 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/gk20a.h @@ -1401,7 +1401,6 @@ struct gk20a { u32 ptimer_src_freq; - bool can_railgate; int railgate_delay; u8 ldiv_slowdown_factor; unsigned int aggressive_sync_destroy_thresh; diff --git a/drivers/gpu/nvgpu/include/nvgpu/enabled.h b/drivers/gpu/nvgpu/include/nvgpu/enabled.h index c352488c..c0fb9218 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/enabled.h +++ b/drivers/gpu/nvgpu/include/nvgpu/enabled.h @@ -35,6 +35,7 @@ struct gk20a; #define NVGPU_DRIVER_IS_DYING 2 #define NVGPU_GR_USE_DMA_FOR_FW_BOOTSTRAP 3 #define NVGPU_FECS_TRACE_VA 4 +#define NVGPU_CAN_RAILGATE 5 /* * ECC flags diff --git a/drivers/gpu/nvgpu/os/linux/driver_common.c b/drivers/gpu/nvgpu/os/linux/driver_common.c index c84c8439..8a7cf552 100644 --- a/drivers/gpu/nvgpu/os/linux/driver_common.c +++ b/drivers/gpu/nvgpu/os/linux/driver_common.c @@ -167,7 +167,7 @@ static void nvgpu_init_pm_vars(struct gk20a *g) #endif g->ptimer_src_freq = platform->ptimer_src_freq; g->support_pmu = support_gk20a_pmu(dev_from_gk20a(g)); - g->can_railgate = platform->can_railgate_init; + __nvgpu_set_enabled(g, NVGPU_CAN_RAILGATE, platform->can_railgate_init); g->ldiv_slowdown_factor = platform->ldiv_slowdown_factor_init; /* if default delay is not set, set default delay to 500msec */ if (platform->railgate_delay_init) diff --git a/drivers/gpu/nvgpu/os/linux/module.c b/drivers/gpu/nvgpu/os/linux/module.c index 4516490b..2df8ab42 100644 --- a/drivers/gpu/nvgpu/os/linux/module.c +++ b/drivers/gpu/nvgpu/os/linux/module.c @@ -458,7 +458,7 @@ int __gk20a_do_idle(struct gk20a *g, bool force_reset) * If User disables rail gating, we take one more * extra refcount */ - if (g->can_railgate) + if (nvgpu_is_enabled(g, NVGPU_CAN_RAILGATE)) target_ref_cnt = 1; else target_ref_cnt = 2; @@ -485,7 +485,7 @@ int __gk20a_do_idle(struct gk20a *g, bool force_reset) nvgpu_timeout_init(g, &timeout, GK20A_WAIT_FOR_IDLE_MS, NVGPU_TIMER_CPU_TIMER); - if (g->can_railgate && !force_reset) { + if (nvgpu_is_enabled(g, NVGPU_CAN_RAILGATE) && !force_reset) { /* * Case 1 : GPU railgate is supported * @@ -1047,7 +1047,7 @@ static int gk20a_pm_init(struct device *dev) * case, set autosuspend delay to negative which * will suspend runtime pm */ - if (g->railgate_delay && g->can_railgate) + if (g->railgate_delay && nvgpu_is_enabled(g, NVGPU_CAN_RAILGATE)) pm_runtime_set_autosuspend_delay(dev, g->railgate_delay); else diff --git a/drivers/gpu/nvgpu/os/linux/pci.c b/drivers/gpu/nvgpu/os/linux/pci.c index 1011b441..205986ec 100644 --- a/drivers/gpu/nvgpu/os/linux/pci.c +++ b/drivers/gpu/nvgpu/os/linux/pci.c @@ -605,7 +605,7 @@ static int nvgpu_pci_pm_init(struct device *dev) #ifdef CONFIG_PM struct gk20a *g = get_gk20a(dev); - if (!g->can_railgate) { + if (!nvgpu_is_enabled(g, NVGPU_CAN_RAILGATE)) { pm_runtime_disable(dev); } else { if (g->railgate_delay) diff --git a/drivers/gpu/nvgpu/os/linux/platform_gk20a_tegra.c b/drivers/gpu/nvgpu/os/linux/platform_gk20a_tegra.c index af55e5b6..432af108 100644 --- a/drivers/gpu/nvgpu/os/linux/platform_gk20a_tegra.c +++ b/drivers/gpu/nvgpu/os/linux/platform_gk20a_tegra.c @@ -792,7 +792,7 @@ static int gk20a_tegra_probe(struct device *dev) if (joint_xpu_rail) { nvgpu_log_info(g, "XPU rails are joint\n"); - platform->g->can_railgate = false; + __nvgpu_set_enabled(g, NVGPU_CAN_RAILGATE, false); } platform->g->clk.gpc_pll.id = GK20A_GPC_PLL; diff --git a/drivers/gpu/nvgpu/os/linux/sysfs.c b/drivers/gpu/nvgpu/os/linux/sysfs.c index e5995bb8..1b84e2e2 100644 --- a/drivers/gpu/nvgpu/os/linux/sysfs.c +++ b/drivers/gpu/nvgpu/os/linux/sysfs.c @@ -305,16 +305,17 @@ static ssize_t railgate_enable_store(struct device *dev, unsigned long railgate_enable = 0; /* dev is guaranteed to be valid here. Ok to de-reference */ struct gk20a *g = get_gk20a(dev); + bool enabled = nvgpu_is_enabled(g, NVGPU_CAN_RAILGATE); int err; if (kstrtoul(buf, 10, &railgate_enable) < 0) return -EINVAL; - if (railgate_enable && !g->can_railgate) { - g->can_railgate = true; + if (railgate_enable && !enabled) { + __nvgpu_set_enabled(g, NVGPU_CAN_RAILGATE, true); pm_runtime_set_autosuspend_delay(dev, g->railgate_delay); - } else if (railgate_enable == 0 && g->can_railgate) { - g->can_railgate = false; + } else if (railgate_enable == 0 && enabled) { + __nvgpu_set_enabled(g, NVGPU_CAN_RAILGATE, false); pm_runtime_set_autosuspend_delay(dev, -1); } /* wake-up system to make rail-gating setting effective */ @@ -323,8 +324,9 @@ static ssize_t railgate_enable_store(struct device *dev, return err; gk20a_idle(g); - nvgpu_info(g, "railgate is %s.", g->can_railgate ? - "enabled" : "disabled"); + nvgpu_info(g, "railgate is %s.", + nvgpu_is_enabled(g, NVGPU_CAN_RAILGATE) ? + "enabled" : "disabled"); return count; } @@ -334,7 +336,8 @@ static ssize_t railgate_enable_read(struct device *dev, { struct gk20a *g = get_gk20a(dev); - return snprintf(buf, PAGE_SIZE, "%d\n", g->can_railgate ? 1 : 0); + return snprintf(buf, PAGE_SIZE, "%d\n", + nvgpu_is_enabled(g, NVGPU_CAN_RAILGATE) ? 1 : 0); } static DEVICE_ATTR(railgate_enable, ROOTRW, railgate_enable_read, @@ -349,7 +352,7 @@ static ssize_t railgate_delay_store(struct device *dev, struct gk20a *g = get_gk20a(dev); int err; - if (!g->can_railgate) { + if (!nvgpu_is_enabled(g, NVGPU_CAN_RAILGATE)) { nvgpu_info(g, "does not support power-gating"); return count; } diff --git a/drivers/gpu/nvgpu/os/linux/vgpu/vgpu_linux.c b/drivers/gpu/nvgpu/os/linux/vgpu/vgpu_linux.c index 25024e7d..83191316 100644 --- a/drivers/gpu/nvgpu/os/linux/vgpu/vgpu_linux.c +++ b/drivers/gpu/nvgpu/os/linux/vgpu/vgpu_linux.c @@ -84,7 +84,7 @@ static void vgpu_init_vars(struct gk20a *g, struct gk20a_platform *platform) g->aggressive_sync_destroy_thresh = platform->aggressive_sync_destroy_thresh; g->has_syncpoints = platform->has_syncpoints; g->ptimer_src_freq = platform->ptimer_src_freq; - g->can_railgate = platform->can_railgate_init; + __nvgpu_set_enabled(g, NVGPU_CAN_RAILGATE, platform->can_railgate_init); g->railgate_delay = platform->railgate_delay_init; __nvgpu_set_enabled(g, NVGPU_MM_UNIFY_ADDRESS_SPACES, -- cgit v1.2.2