From cb70e86ac1d938abf5d215f6beb31790d33d1dee Mon Sep 17 00:00:00 2001 From: Debarshi Dutta Date: Fri, 11 Feb 2022 14:19:26 +0530 Subject: [PATCH] gpu: nvgpu: Allow SC7 suspend/resume Allow SC7 suspend/resume for platforms even if runtime pm is disabled. Currently, nvgpu can disable runtime pm by setting railgate_init field to false for platform_{gk20a/gv11b/ga10b) files. This is done by taking extra reference count in the PM Framework. However, device suspend would still fail. Fix this by checking for NVGPU_CAN_RAILGATE and removing the additional reference count taken as mentioned above. Take the extra refcount back at the end of the resume path. Bug 3458643 Signed-off-by: Debarshi Dutta Change-Id: I413e09e2f9f380d78c0ce30196591e9c5b7544f3 Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2668567 Reviewed-by: Sachin Nikam Reviewed-by: Vijayakumar Subbu GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/os/linux/module.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/gpu/nvgpu/os/linux/module.c b/drivers/gpu/nvgpu/os/linux/module.c index 59c0b3685..2c7e4d595 100644 --- a/drivers/gpu/nvgpu/os/linux/module.c +++ b/drivers/gpu/nvgpu/os/linux/module.c @@ -1432,6 +1432,16 @@ static int gk20a_pm_suspend(struct device *dev) goto fail_idle; } + /* For cases where we don't have railgate enabled, + * we acquire an extra refcount in PM framework. + * + * Release it here to unblock device suspend. + * The below method releases the extra refcount taken + * above and disables auto suspend. + */ + if (!nvgpu_is_enabled(g, NVGPU_CAN_RAILGATE)) + pm_runtime_dont_use_autosuspend(dev); + ret = gk20a_pm_runtime_suspend(dev); if (ret) goto fail_idle; @@ -1479,6 +1489,15 @@ static int gk20a_pm_resume(struct device *dev) if (ret) return ret; + /* For cases where we don't have railgate enabled, + * acquire extra reference in PM framework to prevent + * runtime suspend/resume. + */ + if (!nvgpu_is_enabled(g, NVGPU_CAN_RAILGATE)) { + pm_runtime_set_autosuspend_delay(dev, -1); + pm_runtime_use_autosuspend(dev); + } + g->suspended = false; nvgpu_channel_deterministic_unidle(g);