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 <tbergstrom@nvidia.com>
Reviewed-on: http://git-master/r/1463543
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Terje Bergstrom
2017-04-14 15:12:57 -07:00
committed by mobile promotions
parent ab22d66386
commit 7acc993cdb
13 changed files with 62 additions and 61 deletions

View File

@@ -113,6 +113,8 @@ static void nvgpu_init_pm_vars(struct gk20a *g)
g->has_syncpoints = platform->has_syncpoints; g->has_syncpoints = platform->has_syncpoints;
g->ptimer_src_freq = platform->ptimer_src_freq; g->ptimer_src_freq = platform->ptimer_src_freq;
g->support_pmu = support_gk20a_pmu(g->dev); 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 */ /* set default values to aelpg parameters */
g->pmu.aelpg_param[0] = APCTRL_SAMPLING_PERIOD_PG_DEFAULT_US; g->pmu.aelpg_param[0] = APCTRL_SAMPLING_PERIOD_PG_DEFAULT_US;

View File

@@ -312,7 +312,7 @@ int __gk20a_do_idle(struct device *dev, bool force_reset)
* If User disables rail gating, we take one more * If User disables rail gating, we take one more
* extra refcount * extra refcount
*/ */
if (platform->user_railgate_disabled) if (g->user_railgate_disabled)
target_ref_cnt = 2; target_ref_cnt = 2;
else else
target_ref_cnt = 1; 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_timeout_init(g, &timeout, GK20A_WAIT_FOR_IDLE_MS,
NVGPU_TIMER_CPU_TIMER); NVGPU_TIMER_CPU_TIMER);
if (platform->can_railgate && !force_reset) { if (g->can_railgate && !force_reset) {
/* /*
* Case 1 : GPU railgate is supported * 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); pm_runtime_put_sync(dev);
/* add sufficient delay to allow GPU to rail gate */ /* 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 */ /* check in loop if GPU is railgated or not */
do { do {
@@ -757,7 +757,7 @@ static int gk20a_pm_suspend(struct device *dev)
struct gk20a *g = get_gk20a(dev); struct gk20a *g = get_gk20a(dev);
int ret = 0; int ret = 0;
if (platform->user_railgate_disabled) if (g->user_railgate_disabled)
gk20a_idle_nosuspend(dev); gk20a_idle_nosuspend(dev);
if (atomic_read(&dev->power.usage_count) > 1) { if (atomic_read(&dev->power.usage_count) > 1) {
@@ -780,7 +780,7 @@ static int gk20a_pm_suspend(struct device *dev)
return 0; return 0;
fail: fail:
if (platform->user_railgate_disabled) if (g->user_railgate_disabled)
gk20a_busy_noresume(dev); gk20a_busy_noresume(dev);
return ret; return ret;
@@ -789,10 +789,9 @@ fail:
static int gk20a_pm_resume(struct device *dev) static int gk20a_pm_resume(struct device *dev)
{ {
struct gk20a *g = get_gk20a(dev); struct gk20a *g = get_gk20a(dev);
struct gk20a_platform *platform = dev_get_drvdata(dev);
int ret = 0; int ret = 0;
if (platform->user_railgate_disabled) if (g->user_railgate_disabled)
gk20a_busy_noresume(dev); gk20a_busy_noresume(dev);
if (!g->suspended) if (!g->suspended)
@@ -815,19 +814,19 @@ static const struct dev_pm_ops gk20a_pm_ops = {
int gk20a_pm_init(struct device *dev) int gk20a_pm_init(struct device *dev)
{ {
struct gk20a_platform *platform = dev_get_drvdata(dev); struct gk20a *g = get_gk20a(dev);
int err = 0; int err = 0;
gk20a_dbg_fn(""); gk20a_dbg_fn("");
/* Initialise pm runtime */ /* Initialise pm runtime */
if (platform->railgate_delay) { if (g->railgate_delay) {
pm_runtime_set_autosuspend_delay(dev, pm_runtime_set_autosuspend_delay(dev,
platform->railgate_delay); g->railgate_delay);
pm_runtime_use_autosuspend(dev); pm_runtime_use_autosuspend(dev);
} }
if (platform->can_railgate) { if (g->can_railgate) {
pm_runtime_enable(dev); pm_runtime_enable(dev);
if (!pm_runtime_enabled(dev)) if (!pm_runtime_enabled(dev))
gk20a_pm_unrailgate(dev); gk20a_pm_unrailgate(dev);

View File

@@ -64,8 +64,8 @@ static struct gk20a_platform nvgpu_pci_device[] = {
.remove = nvgpu_pci_tegra_remove, .remove = nvgpu_pci_tegra_remove,
/* power management configuration */ /* power management configuration */
.railgate_delay = 500, .railgate_delay_init = 500,
.can_railgate = false, .can_railgate_init = false,
.can_elpg = true, .can_elpg = true,
.enable_elpg = true, .enable_elpg = true,
.enable_elcg = false, .enable_elcg = false,
@@ -98,8 +98,8 @@ static struct gk20a_platform nvgpu_pci_device[] = {
.remove = nvgpu_pci_tegra_remove, .remove = nvgpu_pci_tegra_remove,
/* power management configuration */ /* power management configuration */
.railgate_delay = 500, .railgate_delay_init = 500,
.can_railgate = false, .can_railgate_init = false,
.can_elpg = true, .can_elpg = true,
.enable_elpg = true, .enable_elpg = true,
.enable_elcg = false, .enable_elcg = false,
@@ -132,8 +132,8 @@ static struct gk20a_platform nvgpu_pci_device[] = {
.remove = nvgpu_pci_tegra_remove, .remove = nvgpu_pci_tegra_remove,
/* power management configuration */ /* power management configuration */
.railgate_delay = 500, .railgate_delay_init = 500,
.can_railgate = false, .can_railgate_init = false,
.can_elpg = true, .can_elpg = true,
.enable_elpg = true, .enable_elpg = true,
.enable_elcg = false, .enable_elcg = false,
@@ -166,8 +166,8 @@ static struct gk20a_platform nvgpu_pci_device[] = {
.remove = nvgpu_pci_tegra_remove, .remove = nvgpu_pci_tegra_remove,
/* power management configuration */ /* power management configuration */
.railgate_delay = 500, .railgate_delay_init = 500,
.can_railgate = false, .can_railgate_init = false,
.can_elpg = true, .can_elpg = true,
.enable_elpg = true, .enable_elpg = true,
.enable_elcg = false, .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) static int nvgpu_pci_pm_init(struct device *dev)
{ {
#ifdef CONFIG_PM #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); pm_runtime_disable(dev);
} else { } else {
if (platform->railgate_delay) if (g->railgate_delay)
pm_runtime_set_autosuspend_delay(dev, pm_runtime_set_autosuspend_delay(dev,
platform->railgate_delay); g->railgate_delay);
/* /*
* Runtime PM for PCI devices is disabled by default, * Runtime PM for PCI devices is disabled by default,

View File

@@ -2454,7 +2454,7 @@ int gk20a_submit_channel_gpfifo(struct channel_gk20a *c,
need_job_tracking = (flags & NVGPU_SUBMIT_GPFIFO_FLAGS_FENCE_WAIT) || need_job_tracking = (flags & NVGPU_SUBMIT_GPFIFO_FLAGS_FENCE_WAIT) ||
(flags & NVGPU_SUBMIT_GPFIFO_FLAGS_FENCE_GET) || (flags & NVGPU_SUBMIT_GPFIFO_FLAGS_FENCE_GET) ||
c->wdt_enabled || c->wdt_enabled ||
platform->can_railgate || g->can_railgate ||
!skip_buffer_refcounting; !skip_buffer_refcounting;
if (need_job_tracking) { if (need_job_tracking) {
@@ -2492,7 +2492,7 @@ int gk20a_submit_channel_gpfifo(struct channel_gk20a *c,
need_deferred_cleanup = !c->deterministic || need_deferred_cleanup = !c->deterministic ||
need_sync_framework || need_sync_framework ||
c->wdt_enabled || c->wdt_enabled ||
platform->can_railgate || g->can_railgate ||
!skip_buffer_refcounting; !skip_buffer_refcounting;
/* /*

View File

@@ -285,8 +285,9 @@ int gk20a_railgating_debugfs_init(struct device *dev)
{ {
struct dentry *d; struct dentry *d;
struct gk20a_platform *platform = dev_get_drvdata(dev); struct gk20a_platform *platform = dev_get_drvdata(dev);
struct gk20a *g = get_gk20a(dev);
if (!platform->can_railgate) if (!g->can_railgate)
return 0; return 0;
d = debugfs_create_file( d = debugfs_create_file(

View File

@@ -397,15 +397,13 @@ void gk20a_driver_start_unload(struct gk20a *g)
int gk20a_wait_for_idle(struct device *dev) int gk20a_wait_for_idle(struct device *dev)
{ {
struct gk20a *g = get_gk20a(dev); struct gk20a *g = get_gk20a(dev);
struct gk20a_platform *platform;
int wait_length = 150; /* 3 second overall max wait. */ int wait_length = 150; /* 3 second overall max wait. */
int target_usage_count = 0; int target_usage_count = 0;
if (!g) if (!g)
return -ENODEV; return -ENODEV;
platform = dev_get_drvdata(dev); if (g->user_railgate_disabled)
if (platform->user_railgate_disabled)
target_usage_count = 1; target_usage_count = 1;
while ((atomic_read(&g->usage_count) != target_usage_count) 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 * that depends on job tracking. (Here, fast means strictly no
* metadata, just the gpfifo contents are copied and gp_put updated). * 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; 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 * provided that the user doesn't request anything that depends on
* deferred cleanup. * deferred cleanup.
*/ */
if (!platform->can_railgate if (!g->can_railgate
&& !gk20a_channel_sync_needs_sync_framework(g)) && !gk20a_channel_sync_needs_sync_framework(g))
gpu->flags |= NVGPU_GPU_FLAGS_SUPPORT_DETERMINISTIC_SUBMIT_FULL; gpu->flags |= NVGPU_GPU_FLAGS_SUPPORT_DETERMINISTIC_SUBMIT_FULL;

View File

@@ -1023,6 +1023,10 @@ struct gk20a {
u32 ptimer_src_freq; u32 ptimer_src_freq;
bool can_railgate;
bool user_railgate_disabled;
int railgate_delay;
unsigned int aggressive_sync_destroy_thresh; unsigned int aggressive_sync_destroy_thresh;
bool aggressive_sync_destroy; bool aggressive_sync_destroy;

View File

@@ -288,7 +288,6 @@ static DEVICE_ATTR(ptimer_src_freq,
static ssize_t railgate_enable_store(struct device *dev, static ssize_t railgate_enable_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count) struct device_attribute *attr, const char *buf, size_t count)
{ {
struct gk20a_platform *platform = dev_get_drvdata(dev);
unsigned long railgate_enable = 0; unsigned long railgate_enable = 0;
/* dev is guaranteed to be valid here. Ok to de-reference */ /* dev is guaranteed to be valid here. Ok to de-reference */
struct gk20a *g = get_gk20a(dev); 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) if (kstrtoul(buf, 10, &railgate_enable) < 0)
return -EINVAL; return -EINVAL;
if (railgate_enable && !platform->can_railgate) { if (railgate_enable && !g->can_railgate) {
/* release extra ref count */ /* release extra ref count */
gk20a_idle(g); gk20a_idle(g);
platform->can_railgate = true; g->can_railgate = true;
platform->user_railgate_disabled = false; g->user_railgate_disabled = false;
} else if (railgate_enable == 0 && platform->can_railgate) { } else if (railgate_enable == 0 && g->can_railgate) {
/* take extra ref count */ /* take extra ref count */
err = gk20a_busy(g); err = gk20a_busy(g);
if (err) if (err)
return err; return err;
platform->can_railgate = false; g->can_railgate = false;
platform->user_railgate_disabled = true; 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"); "enabled" : "disabled");
return count; return count;
@@ -320,9 +319,9 @@ static ssize_t railgate_enable_store(struct device *dev,
static ssize_t railgate_enable_read(struct device *dev, static ssize_t railgate_enable_read(struct device *dev,
struct device_attribute *attr, char *buf) 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, 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, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct gk20a_platform *platform = dev_get_drvdata(dev);
int railgate_delay = 0, ret = 0; int railgate_delay = 0, ret = 0;
struct gk20a *g = get_gk20a(dev); struct gk20a *g = get_gk20a(dev);
int err; int err;
if (!platform->can_railgate) { if (!g->can_railgate) {
dev_info(dev, "does not support power-gating\n"); dev_info(dev, "does not support power-gating\n");
return count; return count;
} }
ret = sscanf(buf, "%d", &railgate_delay); ret = sscanf(buf, "%d", &railgate_delay);
if (ret == 1 && railgate_delay >= 0) { if (ret == 1 && railgate_delay >= 0) {
platform->railgate_delay = railgate_delay; g->railgate_delay = railgate_delay;
pm_runtime_set_autosuspend_delay(dev, platform->railgate_delay); pm_runtime_set_autosuspend_delay(dev, g->railgate_delay);
} else } else
dev_err(dev, "Invalid powergate delay\n"); 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, static ssize_t railgate_delay_show(struct device *dev,
struct device_attribute *attr, char *buf) 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, static DEVICE_ATTR(railgate_delay, ROOTRW, railgate_delay_show,
railgate_delay_store); railgate_delay_store);

View File

@@ -39,10 +39,7 @@ struct gk20a_platform {
struct gk20a *g; struct gk20a *g;
/* Should be populated at probe. */ /* Should be populated at probe. */
bool can_railgate; bool can_railgate_init;
/* Set by User while disabling railgating */
bool user_railgate_disabled;
/* Should be populated at probe. */ /* Should be populated at probe. */
bool can_elpg; bool can_elpg;
@@ -77,7 +74,7 @@ struct gk20a_platform {
#endif #endif
/* Delay before rail gated */ /* Delay before rail gated */
int railgate_delay; int railgate_delay_init;
/* Second Level Clock Gating: true = enable false = disable */ /* Second Level Clock Gating: true = enable false = disable */
bool enable_slcg; bool enable_slcg;

View File

@@ -1,7 +1,7 @@
/* /*
* Tegra Virtualized GPU Platform Interface * 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 * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * 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, .aggressive_sync_destroy_thresh = 64,
/* power management configuration */ /* power management configuration */
.can_railgate = false, .can_railgate_init = false,
.can_elpg = false, .can_elpg = false,
.enable_slcg = false, .enable_slcg = false,
.enable_blcg = false, .enable_blcg = false,

View File

@@ -955,7 +955,7 @@ static int gk20a_tegra_probe(struct device *dev)
if (joint_xpu_rail) { if (joint_xpu_rail) {
gk20a_dbg_info("XPU rails are joint\n"); 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; platform->g->clk.gpc_pll.id = GK20A_GPC_PLL;
@@ -1051,8 +1051,8 @@ struct gk20a_platform gk20a_tegra_platform = {
.aggressive_sync_destroy_thresh = 64, .aggressive_sync_destroy_thresh = 64,
/* power management configuration */ /* power management configuration */
.railgate_delay = 500, .railgate_delay_init = 500,
.can_railgate = true, .can_railgate_init = true,
.can_elpg = true, .can_elpg = true,
.enable_slcg = true, .enable_slcg = true,
.enable_blcg = true, .enable_blcg = true,
@@ -1108,8 +1108,8 @@ struct gk20a_platform gm20b_tegra_platform = {
.aggressive_sync_destroy_thresh = 64, .aggressive_sync_destroy_thresh = 64,
/* power management configuration */ /* power management configuration */
.railgate_delay = 500, .railgate_delay_init = 500,
.can_railgate = true, .can_railgate_init = true,
.can_elpg = true, .can_elpg = true,
.enable_slcg = true, .enable_slcg = true,
.enable_blcg = true, .enable_blcg = true,

View File

@@ -382,10 +382,10 @@ struct gk20a_platform gp10b_tegra_platform = {
.has_syncpoints = true, .has_syncpoints = true,
/* power management configuration */ /* power management configuration */
.railgate_delay = 500, .railgate_delay_init = 500,
/* power management configuration */ /* power management configuration */
.can_railgate = true, .can_railgate_init = true,
.enable_elpg = true, .enable_elpg = true,
.can_elpg = true, .can_elpg = true,
.enable_blcg = true, .enable_blcg = true,

View File

@@ -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->aggressive_sync_destroy_thresh = platform->aggressive_sync_destroy_thresh;
g->has_syncpoints = platform->has_syncpoints; g->has_syncpoints = platform->has_syncpoints;
g->ptimer_src_freq = platform->ptimer_src_freq; 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) static int vgpu_init_support(struct platform_device *pdev)