From 7acc993cdbcc202854f188e7f53646f387573a09 Mon Sep 17 00:00:00 2001 From: Terje Bergstrom Date: Fri, 14 Apr 2017 15:12:57 -0700 Subject: gpu: nvgpu: Move can_railgate & railgate_delay to gk20a Copy can_railgate and railgate_delay to struct gk20a at probe time, and access them from gk20a instead of platform_gk20a. JIRA NVGPU-16 Change-Id: I63d4f4aff7eb17a167775fd7982a1b548bbca3a5 Signed-off-by: Terje Bergstrom Reviewed-on: http://git-master/r/1463543 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/linux/driver_common.c | 2 ++ drivers/gpu/nvgpu/common/linux/module.c | 21 ++++++++------- drivers/gpu/nvgpu/common/linux/pci.c | 24 ++++++++--------- drivers/gpu/nvgpu/gk20a/channel_gk20a.c | 4 +-- drivers/gpu/nvgpu/gk20a/debug_gk20a.c | 3 ++- drivers/gpu/nvgpu/gk20a/gk20a.c | 8 +++--- drivers/gpu/nvgpu/gk20a/gk20a.h | 4 +++ drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c | 30 ++++++++++------------ drivers/gpu/nvgpu/gk20a/platform_gk20a.h | 7 ++--- drivers/gpu/nvgpu/gk20a/platform_vgpu_tegra.c | 4 +-- .../gpu/nvgpu/tegra/linux/platform_gk20a_tegra.c | 10 ++++---- .../gpu/nvgpu/tegra/linux/platform_gp10b_tegra.c | 4 +-- drivers/gpu/nvgpu/vgpu/vgpu.c | 2 ++ 13 files changed, 62 insertions(+), 61 deletions(-) diff --git a/drivers/gpu/nvgpu/common/linux/driver_common.c b/drivers/gpu/nvgpu/common/linux/driver_common.c index 7d6acf91..c2f31afc 100644 --- a/drivers/gpu/nvgpu/common/linux/driver_common.c +++ b/drivers/gpu/nvgpu/common/linux/driver_common.c @@ -113,6 +113,8 @@ static void nvgpu_init_pm_vars(struct gk20a *g) g->has_syncpoints = platform->has_syncpoints; g->ptimer_src_freq = platform->ptimer_src_freq; g->support_pmu = support_gk20a_pmu(g->dev); + g->can_railgate = platform->can_railgate_init; + g->railgate_delay = platform->railgate_delay_init; /* set default values to aelpg parameters */ g->pmu.aelpg_param[0] = APCTRL_SAMPLING_PERIOD_PG_DEFAULT_US; diff --git a/drivers/gpu/nvgpu/common/linux/module.c b/drivers/gpu/nvgpu/common/linux/module.c index ebc25a26..708190f2 100644 --- a/drivers/gpu/nvgpu/common/linux/module.c +++ b/drivers/gpu/nvgpu/common/linux/module.c @@ -312,7 +312,7 @@ int __gk20a_do_idle(struct device *dev, bool force_reset) * If User disables rail gating, we take one more * extra refcount */ - if (platform->user_railgate_disabled) + if (g->user_railgate_disabled) target_ref_cnt = 2; else target_ref_cnt = 1; @@ -339,7 +339,7 @@ int __gk20a_do_idle(struct device *dev, bool force_reset) nvgpu_timeout_init(g, &timeout, GK20A_WAIT_FOR_IDLE_MS, NVGPU_TIMER_CPU_TIMER); - if (platform->can_railgate && !force_reset) { + if (g->can_railgate && !force_reset) { /* * Case 1 : GPU railgate is supported * @@ -349,7 +349,7 @@ int __gk20a_do_idle(struct device *dev, bool force_reset) pm_runtime_put_sync(dev); /* add sufficient delay to allow GPU to rail gate */ - nvgpu_msleep(platform->railgate_delay); + nvgpu_msleep(g->railgate_delay); /* check in loop if GPU is railgated or not */ do { @@ -757,7 +757,7 @@ static int gk20a_pm_suspend(struct device *dev) struct gk20a *g = get_gk20a(dev); int ret = 0; - if (platform->user_railgate_disabled) + if (g->user_railgate_disabled) gk20a_idle_nosuspend(dev); if (atomic_read(&dev->power.usage_count) > 1) { @@ -780,7 +780,7 @@ static int gk20a_pm_suspend(struct device *dev) return 0; fail: - if (platform->user_railgate_disabled) + if (g->user_railgate_disabled) gk20a_busy_noresume(dev); return ret; @@ -789,10 +789,9 @@ fail: static int gk20a_pm_resume(struct device *dev) { struct gk20a *g = get_gk20a(dev); - struct gk20a_platform *platform = dev_get_drvdata(dev); int ret = 0; - if (platform->user_railgate_disabled) + if (g->user_railgate_disabled) gk20a_busy_noresume(dev); if (!g->suspended) @@ -815,19 +814,19 @@ static const struct dev_pm_ops gk20a_pm_ops = { int gk20a_pm_init(struct device *dev) { - struct gk20a_platform *platform = dev_get_drvdata(dev); + struct gk20a *g = get_gk20a(dev); int err = 0; gk20a_dbg_fn(""); /* Initialise pm runtime */ - if (platform->railgate_delay) { + if (g->railgate_delay) { pm_runtime_set_autosuspend_delay(dev, - platform->railgate_delay); + g->railgate_delay); pm_runtime_use_autosuspend(dev); } - if (platform->can_railgate) { + if (g->can_railgate) { pm_runtime_enable(dev); if (!pm_runtime_enabled(dev)) gk20a_pm_unrailgate(dev); diff --git a/drivers/gpu/nvgpu/common/linux/pci.c b/drivers/gpu/nvgpu/common/linux/pci.c index b4e6cb7c..a603135f 100644 --- a/drivers/gpu/nvgpu/common/linux/pci.c +++ b/drivers/gpu/nvgpu/common/linux/pci.c @@ -64,8 +64,8 @@ static struct gk20a_platform nvgpu_pci_device[] = { .remove = nvgpu_pci_tegra_remove, /* power management configuration */ - .railgate_delay = 500, - .can_railgate = false, + .railgate_delay_init = 500, + .can_railgate_init = false, .can_elpg = true, .enable_elpg = true, .enable_elcg = false, @@ -98,8 +98,8 @@ static struct gk20a_platform nvgpu_pci_device[] = { .remove = nvgpu_pci_tegra_remove, /* power management configuration */ - .railgate_delay = 500, - .can_railgate = false, + .railgate_delay_init = 500, + .can_railgate_init = false, .can_elpg = true, .enable_elpg = true, .enable_elcg = false, @@ -132,8 +132,8 @@ static struct gk20a_platform nvgpu_pci_device[] = { .remove = nvgpu_pci_tegra_remove, /* power management configuration */ - .railgate_delay = 500, - .can_railgate = false, + .railgate_delay_init = 500, + .can_railgate_init = false, .can_elpg = true, .enable_elpg = true, .enable_elcg = false, @@ -166,8 +166,8 @@ static struct gk20a_platform nvgpu_pci_device[] = { .remove = nvgpu_pci_tegra_remove, /* power management configuration */ - .railgate_delay = 500, - .can_railgate = false, + .railgate_delay_init = 500, + .can_railgate_init = false, .can_elpg = true, .enable_elpg = true, .enable_elcg = false, @@ -311,14 +311,14 @@ static const struct dev_pm_ops nvgpu_pci_pm_ops = { static int nvgpu_pci_pm_init(struct device *dev) { #ifdef CONFIG_PM - struct gk20a_platform *platform = gk20a_get_platform(dev); + struct gk20a *g = get_gk20a(dev); - if (!platform->can_railgate) { + if (!g->can_railgate) { pm_runtime_disable(dev); } else { - if (platform->railgate_delay) + if (g->railgate_delay) pm_runtime_set_autosuspend_delay(dev, - platform->railgate_delay); + g->railgate_delay); /* * Runtime PM for PCI devices is disabled by default, diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c index 04765eea..0d615d65 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c @@ -2454,7 +2454,7 @@ int gk20a_submit_channel_gpfifo(struct channel_gk20a *c, need_job_tracking = (flags & NVGPU_SUBMIT_GPFIFO_FLAGS_FENCE_WAIT) || (flags & NVGPU_SUBMIT_GPFIFO_FLAGS_FENCE_GET) || c->wdt_enabled || - platform->can_railgate || + g->can_railgate || !skip_buffer_refcounting; if (need_job_tracking) { @@ -2492,7 +2492,7 @@ int gk20a_submit_channel_gpfifo(struct channel_gk20a *c, need_deferred_cleanup = !c->deterministic || need_sync_framework || c->wdt_enabled || - platform->can_railgate || + g->can_railgate || !skip_buffer_refcounting; /* diff --git a/drivers/gpu/nvgpu/gk20a/debug_gk20a.c b/drivers/gpu/nvgpu/gk20a/debug_gk20a.c index cd5c646f..f863b056 100644 --- a/drivers/gpu/nvgpu/gk20a/debug_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/debug_gk20a.c @@ -285,8 +285,9 @@ int gk20a_railgating_debugfs_init(struct device *dev) { struct dentry *d; struct gk20a_platform *platform = dev_get_drvdata(dev); + struct gk20a *g = get_gk20a(dev); - if (!platform->can_railgate) + if (!g->can_railgate) return 0; d = debugfs_create_file( diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.c b/drivers/gpu/nvgpu/gk20a/gk20a.c index 7f110821..ea03ba98 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a.c @@ -397,15 +397,13 @@ void gk20a_driver_start_unload(struct gk20a *g) int gk20a_wait_for_idle(struct device *dev) { struct gk20a *g = get_gk20a(dev); - struct gk20a_platform *platform; int wait_length = 150; /* 3 second overall max wait. */ int target_usage_count = 0; if (!g) return -ENODEV; - platform = dev_get_drvdata(dev); - if (platform->user_railgate_disabled) + if (g->user_railgate_disabled) target_usage_count = 1; while ((atomic_read(&g->usage_count) != target_usage_count) @@ -467,7 +465,7 @@ int gk20a_init_gpu_characteristics(struct gk20a *g) * that depends on job tracking. (Here, fast means strictly no * metadata, just the gpfifo contents are copied and gp_put updated). */ - if (!platform->can_railgate) + if (!g->can_railgate) gpu->flags |= NVGPU_GPU_FLAGS_SUPPORT_DETERMINISTIC_SUBMIT_NO_JOBTRACKING; /* @@ -476,7 +474,7 @@ int gk20a_init_gpu_characteristics(struct gk20a *g) * provided that the user doesn't request anything that depends on * deferred cleanup. */ - if (!platform->can_railgate + if (!g->can_railgate && !gk20a_channel_sync_needs_sync_framework(g)) gpu->flags |= NVGPU_GPU_FLAGS_SUPPORT_DETERMINISTIC_SUBMIT_FULL; diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h index 626ed2bd..6d1707a6 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/gk20a.h @@ -1023,6 +1023,10 @@ struct gk20a { u32 ptimer_src_freq; + bool can_railgate; + bool user_railgate_disabled; + int railgate_delay; + unsigned int aggressive_sync_destroy_thresh; bool aggressive_sync_destroy; diff --git a/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c b/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c index 4d5854d4..783ff6fb 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c @@ -288,7 +288,6 @@ static DEVICE_ATTR(ptimer_src_freq, static ssize_t railgate_enable_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - struct gk20a_platform *platform = dev_get_drvdata(dev); unsigned long railgate_enable = 0; /* dev is guaranteed to be valid here. Ok to de-reference */ struct gk20a *g = get_gk20a(dev); @@ -297,21 +296,21 @@ static ssize_t railgate_enable_store(struct device *dev, if (kstrtoul(buf, 10, &railgate_enable) < 0) return -EINVAL; - if (railgate_enable && !platform->can_railgate) { + if (railgate_enable && !g->can_railgate) { /* release extra ref count */ gk20a_idle(g); - platform->can_railgate = true; - platform->user_railgate_disabled = false; - } else if (railgate_enable == 0 && platform->can_railgate) { + g->can_railgate = true; + g->user_railgate_disabled = false; + } else if (railgate_enable == 0 && g->can_railgate) { /* take extra ref count */ err = gk20a_busy(g); if (err) return err; - platform->can_railgate = false; - platform->user_railgate_disabled = true; + g->can_railgate = false; + g->user_railgate_disabled = true; } - dev_info(dev, "railgate is %s.\n", platform->can_railgate ? + dev_info(dev, "railgate is %s.\n", g->can_railgate ? "enabled" : "disabled"); return count; @@ -320,9 +319,9 @@ static ssize_t railgate_enable_store(struct device *dev, static ssize_t railgate_enable_read(struct device *dev, struct device_attribute *attr, char *buf) { - struct gk20a_platform *platform = dev_get_drvdata(dev); + struct gk20a *g = get_gk20a(dev); - return snprintf(buf, PAGE_SIZE, "%d\n", platform->can_railgate ? 1 : 0); + return snprintf(buf, PAGE_SIZE, "%d\n", g->can_railgate ? 1 : 0); } static DEVICE_ATTR(railgate_enable, ROOTRW, railgate_enable_read, @@ -333,20 +332,19 @@ static ssize_t railgate_delay_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - struct gk20a_platform *platform = dev_get_drvdata(dev); int railgate_delay = 0, ret = 0; struct gk20a *g = get_gk20a(dev); int err; - if (!platform->can_railgate) { + if (!g->can_railgate) { dev_info(dev, "does not support power-gating\n"); return count; } ret = sscanf(buf, "%d", &railgate_delay); if (ret == 1 && railgate_delay >= 0) { - platform->railgate_delay = railgate_delay; - pm_runtime_set_autosuspend_delay(dev, platform->railgate_delay); + g->railgate_delay = railgate_delay; + pm_runtime_set_autosuspend_delay(dev, g->railgate_delay); } else dev_err(dev, "Invalid powergate delay\n"); @@ -361,9 +359,9 @@ static ssize_t railgate_delay_store(struct device *dev, static ssize_t railgate_delay_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct gk20a_platform *platform = dev_get_drvdata(dev); + struct gk20a *g = get_gk20a(dev); - return snprintf(buf, PAGE_SIZE, "%d\n", platform->railgate_delay); + return snprintf(buf, PAGE_SIZE, "%d\n", g->railgate_delay); } static DEVICE_ATTR(railgate_delay, ROOTRW, railgate_delay_show, railgate_delay_store); diff --git a/drivers/gpu/nvgpu/gk20a/platform_gk20a.h b/drivers/gpu/nvgpu/gk20a/platform_gk20a.h index 44277abf..2cbc1056 100644 --- a/drivers/gpu/nvgpu/gk20a/platform_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/platform_gk20a.h @@ -39,10 +39,7 @@ struct gk20a_platform { struct gk20a *g; /* Should be populated at probe. */ - bool can_railgate; - - /* Set by User while disabling railgating */ - bool user_railgate_disabled; + bool can_railgate_init; /* Should be populated at probe. */ bool can_elpg; @@ -77,7 +74,7 @@ struct gk20a_platform { #endif /* Delay before rail gated */ - int railgate_delay; + int railgate_delay_init; /* Second Level Clock Gating: true = enable false = disable */ bool enable_slcg; diff --git a/drivers/gpu/nvgpu/gk20a/platform_vgpu_tegra.c b/drivers/gpu/nvgpu/gk20a/platform_vgpu_tegra.c index 8c424065..e38ad506 100644 --- a/drivers/gpu/nvgpu/gk20a/platform_vgpu_tegra.c +++ b/drivers/gpu/nvgpu/gk20a/platform_vgpu_tegra.c @@ -1,7 +1,7 @@ /* * Tegra Virtualized GPU Platform Interface * - * Copyright (c) 2014-2016, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2014-2017, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -52,7 +52,7 @@ struct gk20a_platform vgpu_tegra_platform = { .aggressive_sync_destroy_thresh = 64, /* power management configuration */ - .can_railgate = false, + .can_railgate_init = false, .can_elpg = false, .enable_slcg = false, .enable_blcg = false, diff --git a/drivers/gpu/nvgpu/tegra/linux/platform_gk20a_tegra.c b/drivers/gpu/nvgpu/tegra/linux/platform_gk20a_tegra.c index 5a178960..4ff4804f 100644 --- a/drivers/gpu/nvgpu/tegra/linux/platform_gk20a_tegra.c +++ b/drivers/gpu/nvgpu/tegra/linux/platform_gk20a_tegra.c @@ -955,7 +955,7 @@ static int gk20a_tegra_probe(struct device *dev) if (joint_xpu_rail) { gk20a_dbg_info("XPU rails are joint\n"); - platform->can_railgate = false; + platform->g->can_railgate = false; } platform->g->clk.gpc_pll.id = GK20A_GPC_PLL; @@ -1051,8 +1051,8 @@ struct gk20a_platform gk20a_tegra_platform = { .aggressive_sync_destroy_thresh = 64, /* power management configuration */ - .railgate_delay = 500, - .can_railgate = true, + .railgate_delay_init = 500, + .can_railgate_init = true, .can_elpg = true, .enable_slcg = true, .enable_blcg = true, @@ -1108,8 +1108,8 @@ struct gk20a_platform gm20b_tegra_platform = { .aggressive_sync_destroy_thresh = 64, /* power management configuration */ - .railgate_delay = 500, - .can_railgate = true, + .railgate_delay_init = 500, + .can_railgate_init = true, .can_elpg = true, .enable_slcg = true, .enable_blcg = true, diff --git a/drivers/gpu/nvgpu/tegra/linux/platform_gp10b_tegra.c b/drivers/gpu/nvgpu/tegra/linux/platform_gp10b_tegra.c index 138b8fda..2587d5fa 100644 --- a/drivers/gpu/nvgpu/tegra/linux/platform_gp10b_tegra.c +++ b/drivers/gpu/nvgpu/tegra/linux/platform_gp10b_tegra.c @@ -382,10 +382,10 @@ struct gk20a_platform gp10b_tegra_platform = { .has_syncpoints = true, /* power management configuration */ - .railgate_delay = 500, + .railgate_delay_init = 500, /* power management configuration */ - .can_railgate = true, + .can_railgate_init = true, .enable_elpg = true, .can_elpg = true, .enable_blcg = true, diff --git a/drivers/gpu/nvgpu/vgpu/vgpu.c b/drivers/gpu/nvgpu/vgpu/vgpu.c index 7e012fb0..248d2a1b 100644 --- a/drivers/gpu/nvgpu/vgpu/vgpu.c +++ b/drivers/gpu/nvgpu/vgpu/vgpu.c @@ -242,6 +242,8 @@ 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; + g->railgate_delay = platform->railgate_delay_init; } static int vgpu_init_support(struct platform_device *pdev) -- cgit v1.2.2