From 97c6a10928cc463825479911c3a6518ade34ebc0 Mon Sep 17 00:00:00 2001 From: Nitin Kumbhar Date: Wed, 4 Jul 2018 22:59:36 +0530 Subject: gpu: nvgpu: add pm_rumtime fixes Runtime PM is enabled only for iGPU and not for dGPU. For dGPU, the .probe() of driver pm_runtime_disable()s, if rail-gating is not enabled. With nvgpu kernel module load/unload, .probe() is called multiple times for same struct device *. This results in an overflow of disable_depth (3 bit refcount) and enables runtime PM on 8th iteration and calls RTPM routines even if it's disabled. To effectively manage pm_runtime_disable(), move it from common nvgpu_remove() to iGPU/dGPU specific routines. Also, add restore pm_runtime state of device on driver .remove(). Bug 1987855 Change-Id: I781278da546ef9c9ef7d7da7dbea0757df32716f Signed-off-by: Nitin Kumbhar Reviewed-on: https://git-master.nvidia.com/r/1770804 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/os/linux/module.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'drivers/gpu/nvgpu/os/linux/module.c') diff --git a/drivers/gpu/nvgpu/os/linux/module.c b/drivers/gpu/nvgpu/os/linux/module.c index a59ac1f1..e3667947 100644 --- a/drivers/gpu/nvgpu/os/linux/module.c +++ b/drivers/gpu/nvgpu/os/linux/module.c @@ -1060,6 +1060,13 @@ static int gk20a_pm_init(struct device *dev) return err; } +static int gk20a_pm_deinit(struct device *dev) +{ + pm_runtime_dont_use_autosuspend(dev); + pm_runtime_disable(dev); + return 0; +} + /* * Start the process for unloading the driver. Set NVGPU_DRIVER_IS_DYING. */ @@ -1309,9 +1316,6 @@ int nvgpu_remove(struct device *dev, struct class *class) platform->secure_buffer.destroy(g, &platform->secure_buffer); - if (pm_runtime_enabled(dev)) - pm_runtime_disable(dev); - if (platform->remove) platform->remove(dev); @@ -1332,8 +1336,11 @@ static int __exit gk20a_remove(struct platform_device *pdev) err = nvgpu_remove(dev, &nvgpu_class); set_gk20a(pdev, NULL); + gk20a_put(g); + gk20a_pm_deinit(dev); + return err; } -- cgit v1.2.2