From dd70aa47dbaa218f5fbafe26477d7cf17f094d21 Mon Sep 17 00:00:00 2001 From: Debarshi Dutta Date: Thu, 5 Sep 2019 16:44:29 +0530 Subject: gpu: nvgpu: fix gk20a_busy_noresume and gk20a_idle_nosuspend gk20a_idle can still race with gk20a_busy_noresume as the following pm_runtime's functions can run concurrently. i.e. pm_runtime_suspend and pm_runtime_get_noresume. pm_runtime_get_noresume simply increments the refcount without first acquiring the pm_runtime's power_lock. This can be resolved by the use of pm_runtime_get_if_in_use which acquires a the power lock of PM runtime. This prevents a potential use of register after power_off in the l2_ops ioctl path. We still call pm_runtime_get_noresume even if pm_runtime_get_if_in_use returns <= 0. This helps in the following ways. 1) The signature of the function gk20a_busy_noresume remains same w.r.t QNX code 2) Any calls to gk20a_busy_noresume() in the driver is followed by a check to g->power_on. When pm_runtime_get_if_in_use() returns <=0, g->power_on is false and would immediately call gk20a_suspend_noidle() thus keeping the original 'intent' of the gk20a_busy_noresume intact. Bug 200507468 Change-Id: Id46bf2124047bb0e9a299fda57441e425195468f Signed-off-by: Debarshi Dutta Reviewed-on: https://git-master.nvidia.com/r/2180787 Reviewed-by: Bibek Basu Reviewed-by: Deepak Nibade Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/os/linux/module.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/gpu/nvgpu/os/linux/module.c b/drivers/gpu/nvgpu/os/linux/module.c index 7653f607..18345ada 100644 --- a/drivers/gpu/nvgpu/os/linux/module.c +++ b/drivers/gpu/nvgpu/os/linux/module.c @@ -107,7 +107,10 @@ struct device_node *nvgpu_get_node(struct gk20a *g) void gk20a_busy_noresume(struct gk20a *g) { - pm_runtime_get_noresume(dev_from_gk20a(g)); + int ret = pm_runtime_get_if_in_use(dev_from_gk20a(g)); + + if (ret <= 0) + pm_runtime_get_noresume(dev_from_gk20a(g)); } /* -- cgit v1.2.2