gpu: nvgpu: gpu railgate handling with runtime pm

Earlier implementation of railgate disable config is disabling
runtime pm during pm_init. This is causing multiple issues:
1. gpu rail will be on as soon as nvgpu driver probe is called.
   Actual gpu hw init may happen at much later point of time.
2. This is breaking railgate_enable sysfs node functionality.
   railgate_enable is not working if runtime pm is disabled.

To avoid all these issues for railgate disable, enable runtime pm
during pm_init and set auto-suspend delay to negative (-1), which
will disable runtime pm suspend calls.

Also fixed following issues along with this:
1. Updated railgate_enable debugfs implementation to use auto-suspend delay.
   To disable railgating:
   Set auto-suspend delay with negative value(-1) which will disable runtime
   pm suspend.
   To enable railgating:
   Set auto-suspend delay with railgate_delay value.
   Also removed redundant user_railgate_disabled gk20a device data and
   replaced with can_railgate, where ever it is applicable.
2. Initialized default railgate_delay to 500msec to avoid railgate
   on/off transitions with railigate enable from disabled state.
3. Created railgate_residency debug fs node irrespective of can_railgate
   initial state. This is helping with the case, where initial state of
   railgate state off and then railgate enable is done through sysfs node.

Bug 2073029

Change-Id: I531da6d93ba8907e806f65a1de2a447c1ec2665c
Signed-off-by: seshendra Gadagottu <sgadagottu@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1694944
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
seshendra Gadagottu
2018-03-20 12:28:04 -07:00
committed by Tejal Kudav
parent 0545465255
commit 40cefb666f
7 changed files with 30 additions and 36 deletions

View File

@@ -458,10 +458,10 @@ int __gk20a_do_idle(struct gk20a *g, bool force_reset)
* If User disables rail gating, we take one more
* extra refcount
*/
if (g->user_railgate_disabled)
target_ref_cnt = 2;
else
if (g->can_railgate)
target_ref_cnt = 1;
else
target_ref_cnt = 2;
nvgpu_mutex_acquire(&platform->railgate_lock);
nvgpu_timeout_init(g, &timeout, GK20A_WAIT_FOR_IDLE_MS,
@@ -964,7 +964,7 @@ static int gk20a_pm_suspend(struct device *dev)
struct gk20a_platform *platform = dev_get_drvdata(dev);
struct gk20a *g = get_gk20a(dev);
int ret = 0;
int idle_usage_count = g->user_railgate_disabled ? 1 : 0;
int idle_usage_count = 0;
if (!g->power_on) {
if (!pm_runtime_enabled(dev))
@@ -1020,23 +1020,19 @@ static int gk20a_pm_init(struct device *dev)
nvgpu_log_fn(g, " ");
/* Initialise pm runtime */
if (g->railgate_delay) {
/*
* Initialise pm runtime. For railgate disable
* case, set autosuspend delay to negative which
* will suspend runtime pm
*/
if (g->railgate_delay && g->can_railgate)
pm_runtime_set_autosuspend_delay(dev,
g->railgate_delay);
pm_runtime_use_autosuspend(dev);
}
else
pm_runtime_set_autosuspend_delay(dev, -1);
if (g->can_railgate) {
pm_runtime_enable(dev);
if (!pm_runtime_enabled(dev))
gk20a_pm_unrailgate(dev);
else
gk20a_pm_railgate(dev);
} else {
__pm_runtime_disable(dev, false);
gk20a_pm_unrailgate(dev);
}
pm_runtime_use_autosuspend(dev);
pm_runtime_enable(dev);
return err;
}