From ca92c1f400f26703643251bc0052d9a23f60bd03 Mon Sep 17 00:00:00 2001 From: Thomas Fleury Date: Thu, 31 Aug 2017 15:08:43 -0700 Subject: gpu: nvgpu: allow suspend when jobs are pending We currently check that no job is pending before proceeding with suspend. This prevents suspend, when we could simply disable and preempt all channels. Moreover, pending jobs accounting is done using pm_runtime usage count, which is not updated for GPUs with pm_runtime disabled (e.g. vgpu). Replaced the check on pm_runtime usage count, with a check on gk20a handle usage count. Suspend is allowed when there is no task inside a busy/idle sequence. JIRA EVLR-1852 Change-Id: I79e71c8112182622dbd1c7c46cd84befa61a5c4d Signed-off-by: Thomas Fleury Reviewed-on: https://git-master.nvidia.com/r/1552348 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/linux/module.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) (limited to 'drivers/gpu/nvgpu/common/linux/module.c') diff --git a/drivers/gpu/nvgpu/common/linux/module.c b/drivers/gpu/nvgpu/common/linux/module.c index 51336c51..e7e79949 100644 --- a/drivers/gpu/nvgpu/common/linux/module.c +++ b/drivers/gpu/nvgpu/common/linux/module.c @@ -869,21 +869,17 @@ 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; - - if (g->user_railgate_disabled) - gk20a_idle_nosuspend(g); - - if (atomic_read(&dev->power.usage_count) > 1) { - ret = -EBUSY; - goto fail; - } + int idle_usage_count = g->user_railgate_disabled ? 1 : 0; if (!g->power_on) return 0; + if (nvgpu_atomic_read(&g->usage_count) > idle_usage_count) + return -EBUSY; + ret = gk20a_pm_runtime_suspend(dev); if (ret) - goto fail; + return ret; if (platform->suspend) platform->suspend(dev); @@ -891,12 +887,6 @@ static int gk20a_pm_suspend(struct device *dev) g->suspended = true; return 0; - -fail: - if (g->user_railgate_disabled) - gk20a_busy_noresume(g); - - return ret; } static int gk20a_pm_resume(struct device *dev) @@ -904,9 +894,6 @@ static int gk20a_pm_resume(struct device *dev) struct gk20a *g = get_gk20a(dev); int ret = 0; - if (g->user_railgate_disabled) - gk20a_busy_noresume(g); - if (!g->suspended) return 0; -- cgit v1.2.2